迪杰斯特算法
2017-05-15 13:15:28 0 举报
迪杰斯特算法
作者其他创作
大纲/内容
T
其他
printf(\"请输给定的数字!\\");
printf(\"%d\
j4
F
i++;
i++
j++;
i = 0
开始
k = index
index++;\t\t\t\t\tlist[index] = Path[i][k];k = Path[i][k];
i4
#define NUM 20 //顶点个数#define MAX 100
shiyan-num_arc = 8;shiyan-num_node = 4;
j = 0
printf(\"--%d\\
k = 0
i 4
i num_node
v0 num_node
shiyan-arcs[i][j] = newarcs[i][j];i++:
j++:
shiyan-node[i] = node[i];i++;
i=0
printf(\"--%d\
D[v0][i] MAX
初始化
v = j;\t\t\t\t\tmin = D[v0][j];
void ShortestPath_DIJ(Graph *g)
chose=1
shiyan = (Graph *)malloc(sizeof(Graph));
min = MAX;
jnum_node
int list[NUM];int index;
ShortestPath_DIJ(shiyan)
j=0
j num_node;
S[v0][i] = 0;D[v0][i] = g-arcs[v0][i];
D[v0][j] = g-arcs[v][j] + D[v0][v];\t\t\t\t\tPath[v0][j] = v;
Path[v0][i] = v0;
S[v0][v0] = 1;D[v0][v0] = 0;
Path[v0][i] = -1;\t
T
S[v0][j] == 0 && D[v0][j] min
Path[i][k] != i
]
printf(\"%d--%d的最短距离为:%d\\
shiyan == NULL
printf(\"分配空间失败!\\");exit(0);
j++
i != j
j num_node;
v0=0
inum_node;
S[v0][v] = 1;
j = 0;
0 条评论
下一页