1. The minimum spanning tree refers to the sum of the paths of all points connected;
The 2.prim algorithm is extended from one point to all points, starting in the spanning tree with only one node V, the first extension, the node closest to the smallest spanning tree is added to the minimum spanning tree, while the minimum spanning tree is updated to the shortest path to the other nodes, and so on until all nodes are joined to the minimum spanning tree.
3. Taking poj2485 as an example,
Test instructions: The maximum edge length in the minimum spanning tree is obtained;
Source:
#include <iostream>
#include <stdio.h>
#define MAX 999999
using namespace Std;
int mapp[510][510];
int check ()
{
int i,j,n;
int maxx=0;
BOOL v[600];
int dist[600];
cin>>n;
for (i=1;i<=n;i++)
for (j=1;j<=n;j++) {
scanf ("%d", &mapp[i][j]);
if (mapp[i][j]==0) Mapp[i][j]=max;
}
for (i=1;i<=600;i++) V[i]=false;
Extend from the first node
V[1]=true;
for (i=1;i<=n;i++) {
Dist[i]=mapp[1][i];
}
Need to add a n-1 point
for (i=1;i<=n-1;i++)
{
int Mini=0,minn=max;
for (j=1;j<=n;j++)
if (!v[j]&&minn>dist[j])
{
MINN=DIST[J];
Mini=j;
}
if (Maxx<minn) Maxx=minn;
V[mini]=true;
for (j=1;j<=n;j++)
if (!v[j]&&dist[j]>mapp[mini][j]) {
DIST[J]=MAPP[MINI][J];
}
}
Return Maxx;
}
int main ()
{
int t,i;
cin>>t;
for (i=1;i<=t;i++)
{
Cout<<check () <<endl;
}
return 0;
}
Minimum spanning Tree prim () algorithm;