#include<iostream.h>
#include<malloc.h>
#define MAXVEX 30
typedef struct vertextype
{
char nam[10];
}name;
typedef struct edgenode
{
int adjvex;
int value;
struct edgenode *next;
}arcnode;
typedef struct vexnode
{
name data;
arcnode *firstarc;
}vheadnode;
typedef struct
{
int n,e;
vheadnode vhnode[MAXVEX];
}adjlist;
int count=0;
int createadjlist(adjlist *&g)
{
int i,b,t,w;
arcnode *p,*q;
g=(adjlist *)malloc(sizeof(adjlist));
cout<<"请输入顶点数,边数:";
cin>>g->n>>g->e;
for(i=0;i<g->n;i++)
{
cout<<" 序号为"<<i<<"的顶点信息:";
cin>>g->vhnode[i].data.nam;
g->vhnode[i].firstarc=NULL;
cout<<endl;
}
for(i=0;i<g->e;i++)
{
cout<<" 序号为"<<i<<"边=>";
cout<<" 起点序号 终点序号 权值:";
cin>>b>>t>>w;
if(b<0||b>g->n)
{
cout<<"输入的起点序号不存在!"<<endl;
return 0;
}
if(t<0||t>g->n)
{
cout<<"输入的重点序号不存在!"<<endl;
return 0;
}
p=(arcnode *)malloc(sizeof(arcnode));
p->value=w;p->adjvex=t;