#include<cstdio>
const int MAX = 10000;
const int INF = 1000000;
int clo[MAX];
int low[MAX];
int c[MAX][MAX];
bool flag[MAX];
int beg[MAX],end[MAX];//记录生成树的每条边的两个顶点
int Prim(int n)
{
int i, j, k, ans = 0, pair = 0;
flag[1] = true;
for(i = 2; i <= n; i++)
{
low[i] = c[1][i];
clo[i] = 1;
flag[i] = false;
}
for(i = 1; i < n; i++)
{
j = 1;
int min = INF;
for(k = 2; k <=n; k++)
{
if(low[k] < min && !flag[k])
{
min = low[k];
j = k;
}
}
flag[j] = true;
beg[i] = j;
end[i] = clo[j];
ans += c[j][clo[j]];
for(k = 2; k <= n; k++)
{
if(c[j][k] < low[k] && !flag[k])
{
low[k] = c[j][k];
clo[k] = j;
}
}
}
return ans;
}
int main()
{
int i, j, n, m;
scanf("%d%d",&n,&m);
for(i = 1; i <= n; i++)
{
for(j = 1; j <=n; j++)
{
c[i][j]=INF;
}
}
return 0;
}
posted on 2006-10-13 23:48
beyonlin 阅读(3045)
评论(4) 编辑 收藏 引用 所属分类:
acm之路