#include "stdio.h"
#include "stdlib.h"
#include "io.h"
#include "math.h"
#include "time.h"
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define MAXVEX 100
typedef int Status;
typedef char VertexType;
typedef int EdgeType;
typedef struct EdgeNode
{
int adjvex;
EdgeType info;
struct EdgeNode next;
}EdgeNode ;
EdgeNode hahaha;/在这里多加了一行*/
typedef struct VertexNode
{
VertexType data;
EdgeNode *firstedge;
}VertexNode,AdjList[MAXVEX];
typedef struct
{
AdjList adjList;
int numNodes,numEdges;
}GraphAdjList;
void CreateALGraph(GraphAdjList G)
{
int i,j,k;
EdgeNode *e;
printf("输入顶点数和边数");
scanf("%d,%d",&G->numNodes,&G->numEdges);
for(i=0;inumNodes;i++)
{
scanf(&G->adjList[i].data);
G->adjList[i].firstedge=NULL;
}
for(k=0;knumEdges;k++)
{
printf("输入边vivj上的顶点序号");
scanf("%d,%d",&i,&j);
e=(hahaha)malloc(sizeof(EdgeNode));/将e改为了hahaha就出现了报*/ /* 错的情况*/
e->adjvex=j;
e->next=G->adjList[i].firstedge;
G->adjList[i].firstedge=e;
e=(EdgeNode *)malloc(sizeof(EdgeNode));
e->adjvex=i;
e->next=G->adjList[j].firstedge;
G->adjList[j].firstedge=e;
}
}
int main()
{
GraphAdjList G;
CreateALGraph(&G);
return 0;
}