sarexpine 2021-12-08 16:50 采纳率: 100%
浏览 26
已结题

关于邻接表中的结构问题

以下是邻接表表示图的数据结构代码

问题:

  1. 代码中顶点表结点使用 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;
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月16日
    • 修改了问题 12月8日
    • 创建了问题 12月8日