无向图最小生成树
2017-05-15 09:26:42 0 举报
无向图最小生成树
作者其他创作
大纲/内容
printf(\"最小成本为:%d\\
list[i] == 0 && close[i].cost g-arcs[v][i]
T
printf(\"请输给定的数字!\\");
close[i].node = v;\t\t\t\tclose[i].cost = g-arcs[v][i];
i15
minimum = g-arcs[v][i];pv = v;tmp = i;
v++
i++
v = tmp;\t\tlist[v] = 1;
chsoe==2
F
struct closedge{int node;int cost;};
print_node(gra);
list[i] = 0;close[i].node = 0;\t\tclose[i].cost = g-arcs[0][i];v = 0;i++
jnum_node
i=1
j=1
printf(\"\\");i++
输入chose
printf(\"创建图失败\\");exit(0);
inum_node;
void prim(Graph *g)
gra-arcs[i][j] = newarcs[i][j];j++;
i=0
i num_node;
其他
printf_s(\"%c-%c\\
chose==1
j15
jnum_node;
#define NUM 20 //顶点个数#define MAXNUM 100#define INF 65535
i9
void print_node(Graph *s)
gra = (Graph*)malloc(sizeof(Graph));/
sum_cost = 0;\tlist[0] = 1;
printf(\"%d \
v=0
inum_node
vnum_node;
gra-num_node = 9;gra-num_arc = 15;
gra == NULL
sum_cost += g-arcs[pv][v];
prim(gra);
m
j=0
gra-node[i] = newnode[i];i++;
0 条评论
下一页