(四)圖的基本應用
【釋】普裡姆應用的是集合論的思想
void MiniSpanTree_PRIM(Mgraph G
//用普裡姆算法從第U個頂點出發構造網G的最小生成樹T
//記錄從頂點集U到V
struct{
vertexType adjvex;
VRType lovcost;
}closedge[MAX_VERTEX_NUM];
k=LocateVex(G
for(j=
if(j!=k)closedge[j]={u
closedge[k]
for(i=
k=mininum(closedge);
//此時closedge[k]
printf(closedge[k]
closedge[k]
for(j=
if(G
closedge[j]={G
}
}//MiniSpanTree
【釋】權值由小到大
返回《數據結構》考研復習精編
[
From:http://tw.wingwit.com/Article/program/sjjg/201311/23292.html