这个程序哪里错了,求大神指教???邻接表建图
#include<iostream>using namespace std;
//======================================
#define MAX_VERTEX_NUM 20
struct ArcNode
{
int adjvex;
struct ArcNode *nextarc;
};//定义边结点类型
typedef struct VNode//定义定点结点类型
{
char data;
ArcNode *firstarc;
}VNode,AdjList[MAX_VERTEX_NUM];
typedef struct
{
AdjList vertices;
int vexnum,arcnum;
}ALGragh;
//图的邻接表定义
//=============================
void CreateGragh(ALGragh &G);
int LocateVex(ALGragh G,char vi);
//=============================
int main()
{
ALGragh myGragh;
CreateGragh(myGragh);
//print(myGragh);
return 1;
}
//============================
void CreateGragh(ALGragh &G)
{
int i,j,k;
cout<<"请输入顶点数和边数"<<endl;
cin>>G.vexnum>>G.arcnum;
cout<<"请输入顶点数据"<<endl;
for(k=0;k<G.vexnum;k++)
{
cin>>G.vertices[i].data;
G.vertices[i].firstarc=NULL;
}
cout<<"请输入各边"<<endl;
char vi,vj;
for(k=0;k<G.arcnum;k++)
{
cin>>vi>>vj;
i=LocateVex(G,vi);
j=LocateVex(G,vj);
ArcNode *p=new ArcNode;
p->adjvex=j;
p->nextarc=G.vertices[i].firstarc;//头插法
G.vertices[i].firstarc=p;
}
}
//图G用邻接表表示,创建图
//================================
int LocateVex(ALGragh G,char vi)
{
int i;
for(i=0;i<G.vexnum;i++)
{
G.vertices[i].data==vi;
return i;
}
}