问题 问答题

图的邻接表的类型定义如下所示:

#define MaxVertexNum 50

typedef struct node{

int adjvex;

struct node*next;

}EdgeNode;

typedef struct{

VertexType vertex;

EdgeNode*firstedge;

}VertexNode;

typedef VertexNode A djList[MaxVertexNum];

typedef struct{

AdjList adjiist;

int n,e;

}ALGraph;

为便于删除和插入图的顶点的操作,可将邻接表的表头向量定义为链式结构,两种定义的存储表示实例如下图所示,请写出重新定义的类型说明。

 

答案

参考答案:

typeclef struct ArcNode{ VNode*adjvex; //该弧所指向的顶点的位置 struct ArcNode*nextarc; //指向下一条弧的指针 }ArcNode; typedef struct VNode{ VertexType data; //顶点信息 struct VNode*nextVertex; //指向下一个顶点的指针 ArcNode*firstarc; //指向第一条依附该顶点的弧 }VNode.*AdjList; typedef struct{ AdjList adjList; int n,e; }ALGraph;

单项选择题
填空题 案例分析题