代码运行不到输入两个顶点的时候就结束了
#include<stdio.h>
#include<stdlib.h>
#define MAX_SIZE 100
typedef char MapType;
typedef struct EdgeNode
{
int adjvex;
MapType info;
struct EdgeNode* next;
}EdgeNode;
typedef struct MapHat
{
MapType data;
struct EdgeNode* firstchild;
}AdjList[MAX_SIZE], MapHat;
typedef struct
{
AdjList adjList;
int numEdge, numNodes;
}GraphAdjList;
void CreatALGraph(GraphAdjList* G);
void CreatALGraph(GraphAdjList* G)
{
printf("请输入边数和端点数\n");
scanf("%d %d", &(G->numEdge), &(G->numNodes));
printf("请输入端点\n");
for (int i = 0; i < G->numNodes; i++)
{
scanf("%c ", &((G->adjList[i]).data));
G->adjList[i].firstchild = NULL;
}
EdgeNode* e;
printf("请输入有连线两点\n");
for (int k = 0; k < G->numEdge; k++)
{
int h, j;
scanf("%d %d", &h, &j);
e = (EdgeNode*)malloc(sizeof(EdgeNode));
e->adjvex = h;
e->next = G->adjList[j].firstchild;
G->adjList[j].firstchild = e;
e = (EdgeNode*)malloc(sizeof(EdgeNode));
e->adjvex = j;
e->next = G->adjList[h].firstchild;
G->adjList[h].firstchild = e;
}
}
int main()
{
GraphAdjList M;
CreatALGraph(&M);
return 0;
}