//创建有向图的邻接表 #include using namespace std; const int MaxVnum=100;//顶点数最大值 typedef char VexType;//顶点的数据类型为字符型 typedef struct AdjNode{ //定义邻接点类型 int v; //邻接点下标 struct AdjNode *next; //指向下一个邻接点 }AdjNode; typedef struct VexNode{ //定义顶点类型 VexType data; // VexType为顶点的数据类型,根据需要定义 AdjNode *first; //指向第一个邻接点 }VexNode; typedef struct{//定义邻接表类型 VexNode Vex[MaxVnum]; int vexnum,edgenum; //顶点数,边数 }ALGragh; int locatevex(ALGragh G,VexType x) { for(int i=0;iv=j; s->next=G.Vex[i].first; G.Vex[i].first=s; } void printg(ALGragh G)//输出邻接表 { cout<<"----------邻接表如下:----------"<v<<"] "; t=t->next; } cout<>G.vexnum>>G.edgenum; cout << "请输入顶点信息:"<>G.Vex[i].data; for(i=0;i>u>>v; i=locatevex(G,u);//查找顶点u的存储下标 j=locatevex(G,v);//查找顶点v的存储下标 if(i!=-1&&j!=-1) insertedge(G,i,j); else { cout << "输入顶点信息错!请重新输入!"<