以下是邻接表表示图的数据结构代码
问题:
- 代码中顶点表结点使用
typedef
定义后,出现的AdjList[MVNum]
是否等价于下方邻接表部分的注释代码?
- 如果不是,可以写一下等价的代码,感谢!😭
typedef int Weight;
typedef char VertexType;
#define MVNum 100
//-----图的邻接表存储结构-----
//边结点 adjvex
struct ArcNode
{
int adjvex; //边结点的下标
ArcNode* next; //边结点的next域
Weight value; //定义权值
};
typedef struct ArcNode ArcNode;
//顶点表结点
struct VexNode
{
VertexType data; //顶点信息
ArcNode* firstedge; //表头指针
};
typedef struct VexNode VexNode;
typedef struct VexNode AdjList[MVNum];
//邻接表
struct ALGraph
{
//VexNode AdjList[100];
AdjList adjlist; //定义顶点表
int vexNum; //当前顶点数
int arcNum; //当前边/弧数
};
typedef struct ALGraph ALGraph;