#include<stdio.h>
#include<stdlib.h>
#define MAX_VERTEX_NUM 20
typedef struct ArcNode{
int adjvex;
struct ArcNode *nextarc;
string *info;
}ArcNode,*ArcList;
typedef struct VNode{
char data;
ArcNode *fristarc;
}VNode;
typedef struct{
VNode vertces[MAX_VERTEX_NUM];
int vexnum,arcnum;
}ALGraph;
void InsertArc(ALGraph *p,int head,int tail)
{
ArcList aList;
ArcNode *aNode;
aNode=(ArcNode *)malloc(sizeof(ArcNode));
aNode->adjvex=tail;
aNode->nextarc=NULL;
aList=p->vertces[head].fristarc;
if(aList==NULL)
p->vertces[head].fristarc=aNode;
else{
while(aList->nextarc!=NULL){
aList=aNode->nextarc;
aList->nextarc=aNode;
}
}
}
ALGraph *CreatGraph()
{
int i,j,head,tail;
ALGraph *p;
p=(ALGraph *)malloc(sizeof(ALGraph));
puts("Please input the number of the point:");
scanf("%d",&p->vexnum);
for(i=0;i<p->vexnum;i++)
p->vertces[i].fristarc=NULL;
puts("\nPlease input the number of the arc:");
scanf("%d",&p->arcnum);
puts("Please input the arcnode like 0,1 2,6...");
for(j=0;j<p->arcnum;j++)
{
scanf("%d,%d",&head,&tail);
InsertArc(p,head,tail);
}
}
void main(){
ALGraph *p=CreatGraph();
}
write by 猫猫