|
|
|
@ -29,6 +29,10 @@ int pre[N]; // 前驱结点
|
|
|
|
|
|
|
|
|
|
// 普利姆算法求最小生成树
|
|
|
|
|
int prim() {
|
|
|
|
|
memset(dis, 0x3f, sizeof dis);
|
|
|
|
|
memset(pre, -1, sizeof pre); // 记录前驱路径
|
|
|
|
|
dis[1] = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < n; i++) { // 迭代n次
|
|
|
|
|
int t = -1;
|
|
|
|
|
for (int j = 1; j <= n; j++)
|
|
|
|
@ -48,8 +52,6 @@ int prim() {
|
|
|
|
|
int main() {
|
|
|
|
|
cin >> n >> m;
|
|
|
|
|
memset(g, 0x3f, sizeof g);
|
|
|
|
|
memset(dis, 0x3f, sizeof dis);
|
|
|
|
|
memset(pre, -1, sizeof pre); // 记录前驱路径
|
|
|
|
|
|
|
|
|
|
// 读入数据
|
|
|
|
|
while (m--) {
|
|
|
|
|