摘要:
1.Prim算法:cost[a][b]和cost[b][a]都得赋值。 /* Prim算法 Prim求MST 耗费矩阵cost[][],标号从0开始,0~n-1 返回最小生成树的权值,返回-1表示原图不连通 */ #include<iostream> #include<stdio.h> #inclu 阅读全文
摘要:
c. /* 并查集模板 */ #include<iostream> #include<stdio.h> #include<string.h> using namespace std; #define MAXN 1024 int fa[MAXN]; int set_find(int d){ if(fa 阅读全文