watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" />
下表记录S到每一个节点的距离:
第一次迭代,
S->A = 4 ,由于S->A眼下为INF。因此更新MIN(S->A)为4
S->B = 6。由于S->B眼下为INF。因此更新MIN(S->B)为6
S->C=INF(表示不可达)
S->D=INF
MIN(S->S) |
MIN(S->A) |
MIN(S->B) |
MIN(S->C) |
MIN(S->D) |
0 |
4 |
6 |
INF |
INF |
第二次从A開始迭代:
A->C=3。由于S->C眼下为INF,因此更新MIN(S->C)为7
MIN(S->S) |
MIN(S->A) |
MIN(S->B) |
MIN(S->C) |
MIN(S->D) |
0 |
4 |
6 |
7 |
INF |
第二次从B開始迭代,
B->A= -5 ,由于S->A=4 S->B=6,因此S->B->A=1 < S->A = 4。故更新MIN(S->A)=1
由于更新了S->A,而A可达点集有C,因此须要对这些可达点集进行递归:
MIN(S->C) 此时为7。而MIN(S->A)->C为1+3=4。故须要更新MIN(S->C)=4
B->D = 1。由于MIN(S->D) = INF。故MIN(S->D)需更新为7
MIN(S->S) |
MIN(S->A) |
MIN(S->B) |
MIN(S->C) |
MIN(S->D) |
0 |
1 |
6 |
4 |
7 |
从C点開始迭代:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" />
C可达点集仅仅有D,由于MIN(S->D)为7,而MIN(S->C)->D为4+2=6,因此MIN(S->D)须要更新为6
得到最后结果为:
MIN(S->S) |
MIN(S->A) |
MIN(S->B) |
MIN(S->C) |
MIN(S->D) |
0 |
1 |
6 |
4 |
6 |
时间: 2024-10-29 19:10:12