东北大学考研cs专业课学习笔记——图的算法题

邻接表的数据结构,最为常考的结构;邻接矩阵,十字链表,邻接多重表不常考,定义放在文章的最后

typedef struct ArcNode {
    int adjvex;
    struct ArcNode* next;
}ArcNode;

typedef struct {
    VertexType data;
    ArcNode* first;
}VexNode;

typedef struct {
    VexNode vexlist[MaxVexNum];
    int vexnum, arcnum;
}ALGraph;

邻接矩阵

typedef struct {
    VertexType vexlist[MaxVexNum];
    ArcType arcTable[MaxVexNum][MaxVexNum];
    int vexnum, arcnum;
}MGraph;

十字链表,有向图

typedef struct ArcNode {
    int tailvex, headvex;
    struct ArcNode* tlink, * hlink;
}ArcNode;

typedef struct {
    VertexType data;
    ArcNode* firstin, * firstout;
}VexNode;

typedef struct {
    VexNode vexlist[MaxVexNum];
    int vexnum, arcnum;
}GLGraph;

邻接多重表,无向图

typedef struct ArcNode {
    //int marked; 访问标记
    int ivex, jvex;
    struct ArcNode* ilink, * jlink;
}ArcNode;

typedef struct {
    VertexType data;
    ArcNode* first;
}VexNode;

typedef struct {
    VexNode vexlist[MaxVexNum];
    int vexnum, arcnum;
}AMLGraph;

猜你喜欢

转载自www.cnblogs.com/vergilwu/p/11669526.html
今日推荐