#include
#include
# define INFIN 32767
20 # define N
Typedef char VexType;
Typedef struct
{
Int vexnum arcnum;
VexType vexs [N].
Int arcs [N] [N].
} MGraph;
Typedef struct Edge
{
Int v1, v2,
int weight;
} Edge;
Edge edges [N].
Int flag [N].
Void CreateMGraph (MGraph * g)
{
Int I, j, u, k=1;
Char v.
i=0;
While ((v=getchar ())!='#')
{
G - & gt; Vexs [I]=v;
i++;
}
G - & gt; Vexnum=I;
for(i=0; i
The scanf (" % d, % d, % d ", & amp; I, & amp; J., & amp; U);
getchar();
While ((I!=1) & amp; & (j!=1) & amp; & (u!=1))
{
G - & gt; Arcs [I] [j]=u;
G - & gt; Arcs [j] [I]=u;
The scanf (" % d, % d, % d ", & amp; I, & amp; J., & amp; U);
getchar();
k++;
}
G - & gt; Arcnum=k;
}
Void SortEdges (MGraph * g)
{
Int I, j, k, L=0;
for(i=1; i
{
K=L;
While (k> 0 & amp; & Edges [k - 1]. Weight> G - & gt; Arcs [I] [j])
{
Edges [k]=edges [k - 1);
K -;
}
Edges [k]. Weight=g - & gt; Arcs [I] [j];
Edges [k]. V1=I;
Edges [k]. V2=j;
L++;
}
}
Void Kruskal (MGraph * g)
{
Int I, j, factor, temp;
for(i=0; i
{
Printf (" \ n (% % c, c), % d ", the g & gt; Vexs [edges [I]. V2], g - & gt; Vexs [edges [I]. V1], edges [I] weight);
Factor=flag [edges [I]. V1];
Temp=flag [edges [I]. V2];
for(j=0; j
Flag [j]=factor;
}
}
Int main ()
{
MGraph g;
CreateMGraph (& amp; G);
SortEdges (& amp; G);
Kruskal (& amp; G);
return 0;
}