#include<stdio.h>
#include<malloc.h>
struct MGraph
{
char vexs[20];
int vexnum,arcnum;
int AdjMatrix[20];
};
struct
{
char adjvex;
int lowcost;
}closedge[20];
struct CSNode
{
char data;
struct CSNode *firstchild,*nextsibling;
};
int MiniSpanTree_PRIM(struct MGraph *s,char u,struct CSNode *root);
void main()
{
struct MGraph *s;
struct CSNode *root;
root=(struct CSNode *)malloc(sizeof(struct CSNode *));
s=(struct MGraph *)malloc(sizeof(struct MGraph *));
creatUDN(s);//没写地方不够,建立一个图,邻接矩阵;
MiniSpanTree_PRIM(s,s->vexs[0],root);
}
int MiniSpanTree_PRIM(struct MGraph *s,char u,struct CSNode *root)
{
struct CSNode *p,*p2,*q,*g[20];
int i,j,k,flag,m,n;
char da,fla;
for(i=0;i<s->vexnum;i++)
{
g[i]=(struct CSNode *)malloc(sizeof(struct CS Node));
g[i]->data=s->vexs[i];//再这错误
g[i]->firstchild=NULL;g[i]->nextsibling=NULL;
}
return1;
}
将那一部分放到main函数里可以输出正确结果
谢谢!