求大神帮忙
输入
若干行整数
第一行为两个整数,分别为图的顶点数和边数
第二行开始是该图的邻接矩阵,主对角线统一用0表示,无直接路径的两点用100来表示(保证各边权值小于100)
输出
若干用空格隔开的整数
样例输入
6 10
0 6 1 5 100 100
6 0 5 100 3 100
1 5 0 5 6 4
5 100 5 0 100 2
100 3 6 100 0 6
100 100 4 2 6 0
样例输出
1 4 2 5 3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MaxSize 6
#define INF 100
typedef struct{
int no; //askjfkajsdf
int w;
int name;
}VertexType;
typedef struct{
int edges[MaxSize][MaxSize];
int n,e;
VertexType point[MaxSize];
}MGraph;
void CreateMGraph(MGraph &M)
{
int i,j,n;
int edges[MaxSize][MaxSize];
printf("input 边数:");
scanf("%d",&n);//nnnnn
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&edges[i][j]);
}
}
}
typedef struct node{
int adjvex;
struct node *next;
}ArcNode;
typedef struct Vnode{
int w;
int name;
ArcNode *firstarc;
}VNode;
typedef VNode AdjList[MaxSize];
typedef struct{
AdjList adjlist;
int n,e;
}ALGraph;
void CreateALGraph(ALGraph *G,MGraph M)
{
int i,j,n=M.n;
ArcNode *p;
G=(ALGraph*)malloc(sizeof(ALGraph));
for(i=0;i<G->n;i++){
G->adjlist[i].firstarc=NULL;
}
for(i=0;i<n;i++)
{
for(j=n-1;j>=0;j--)
{
if(M.edges[i][j]!=0){
p=(ArcNode*)malloc(sizeof(ArcNode));
p->adjvex=j;
p->next=G->adjlist[i].firstarc;
G->adjlist[i].firstarc=p;
}
G->n=n;
G->e=M.e;
}
}
}
void Prim(MGraph M,int v)
{
int lowcost[MaxSize];
int min;
int closest[MaxSize],i,j,k;
for(i=0;i<M.n;i++)
{
lowcost[i]=M.edges[v][i];
closest[i]=v;
}
for(i=1;i<M.n;i++)
{
min='100';
for(j=0;j<M.n;j++)
{if(lowcost[j]!=0&&lowcost[j]<min)
{
min=lowcost[j];
k=j;
}
printf("bian(%d,%d):%d\n",closest[k],k,min);
lowcost[k]=0;
for(j=0;j<M.n;j++)
if(M.edges[k][j]!=0&&M.edges[k][j]<lowcost[j])
{
lowcost[j]=M.edges[k][j];
closest[j]=k;
}
}
}
}
int main()
{
ALGraph *G;
MGraph M;
CreateMGraph(M);
Prim(M,M.n);
return 0;
}
只能完成到输入矩阵,后面就无法输入最小生成树的序列了 还请各位大神帮忙,谢谢