#include
#include
#define max 50
using
namespace std;
typedef
struct student
edge;
typedef
struct ss
*graph,graph;
intget_parent
(int v,
int p)
;//對於節點p求其父節點
void
init_graph
(graph &l)
;void
creat_graph
(graph &l,
int vex)
;void
build_graph
(graph &l)
;void
insert_edge
(graph &l,edge s)
;void
printlist
(graph l)
;void
sort_weight
(graph l)
;//按照權值的順序從小到大排序
void
kruskal
(graph l,
int&sum)
;int
main()
cout
(l);
cout
kruskal
(l,sum)
;//克魯斯卡爾演算法
cout<<
"最小權值之和為"
}void
init_graph
(graph &l)
void
creat_graph
(graph &l,
int vex)
else
}void
build_graph
(graph &l)
void
insert_edge
(graph &l,edge s)
l->a[l-
>arc]
=s; l-
>arc++;}
void
printlist
(graph l)
}void
sort_weight
(graph l)
//按照權值的順序從小到大排序}}
}int
get_parent
(int v,
int p)
//對於節點p求其父節點
return p;
//返回其父節點
}void
kruskal
(graph l,
int&sum)
}}
最小生成樹 克魯斯卡爾演算法
c node.h檔案 儲存頂點資訊 class c node c node c node c node p node c node c node c node c node char p data node.h檔案,儲存邊資訊 include class link node link node li...
最小生成樹( 克魯斯卡爾演算法)
name author date 01 12 14 20 17 description 最小生成樹 克魯斯卡爾演算法 關於並查集的演算法,參見 一種簡單而有趣的資料結構 並查集 include include define maxn 1000 最大頂點數量 define max 20000 最大邊數...
克魯斯卡爾 最小生成樹集錦
狀態是1的兩個分量直接聯通,然後套模板。include include include include include include include include include include using namespace std define maxn 1e 9 int pa 10000 ...