typedef int elemtype; typedef struct { elemtype v1; elemtype v2; int cost; } EdgeType; void Kruskal(EdgeType edges[ ],int n) /*用Kruskal 方法构造有n 个顶点的图edges 的最小生成树*/ { int father[MAXEDGE]; int i,j,vf1,vf2; for ( i=0; i<n; i++ ) father[i]=-1; i=0; j=0; while ( i<MAXEDGE && j<n-1 ) { vf1=Find ( father,edges[i].v1 ); vf2=Find ( father,edges[i].v2 ); if ( vf1!=vf2 ) { father[vf2]=vf1; j++; printf ( “%3d%3d\n”,edges[i].v1,edges[i].v2 ); } i++; } }