#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define INF 10000
#define MAXV 6
#define MAXSIZE 10;
typrdef struct
{
int no;//顶点编号
InFoType into;
}VertexType;
typedef struct
{
int edge[MAXV][MAXV];
int n,e;
VertexType vexs[MAXV];
}MatGraph;
typedef struct
{
int u;
int v;
int w;
}Edge;
typedef struct
{
int key;
int a;
int b;
}ReeType;
int partition(RecType R[],int s,int t)
{
int i=s,j=t;
RecType base=R[i];
while(i<j)
{
while(j>i&&R[i].key>=base.key)
j--;
if(i<j)
{
R[i]=R[j];
i++;
}
while(j>i&&R[i].key<base.key)
i++;
if(i<j)
{
R[i]=R[j];
j--;
}
}
R[i]=base;
return i;
}
void QuickSort(RecType R[],int s,int t)
{
int i;
if(s<t)
{
i=partition(R,s,t);
QuickSort(R,s,i-1);
QuickSort(R,i+1,t);
}
}
void Kruskal(MatGraph g)
{
int i,j,u1,v1,sn1,sn2,k;
int vest[MAXV];
Edge E[10];
k=0;
for(i=0;i<g.n;i++)
{
for(j=0;j<=i;j++)
if(g.edge[i][j]!=0&&g.edge[i][j]!=INF)
{
E[k].u=i;
E[k].v=j;
E[k].w=g.edge[i][j];
k++;
}
}
QuickSort(E,u,v);
for(i=0;i<g.n;i++)
vest[i]-i;
k=1;
j=0;
while(k=g.n)
{
u1=E[j].u;
v1=E[j].v;
sn1=vset[u1];
sn2=vset[v1];
if(sn1!=sn2)
{
printf("(%d,%d):%d\n",u1,v1,E[j],w);
k++;
for(i=0;i<g.n;i++)
if(vset[i]==sn2)
vset[i]=sn1;
}
j++;
}
}
int main()
{
MatGraph g;
MatGraph.edge={{0,6,1,5,10000,10000},{6,0,3,10000,3,10000},{1,3,0,5,6,4},{5,10000,5,0,10000,2},{10000,3,6,10000,0,6},{10000,10000,4,2,6,0}};
int n=5,e=10;
MatGraph.vexs={1,2,3,4,5,6};
Kruskal(g);
};
这是一个用快排和kruskal算法的求最小树的代码,帮忙修改一下