图的存储

来源:互联网 发布:海口seo外包公司 编辑:程序博客网 时间:2024/05/16 16:58
#pragma once#include"stdafx.h"#define MaxVertexNum 100//图的存储---邻接矩阵法(有向图、无向图)typedef char VertexType;typedef int EdgeType;typedef struct {VertexType Vex[MaxVertexNum];int vexnum, arcnum;}MGraph;     //图的存储---邻接表法(有向图、无向图)typedef struct ArcNode { //边表结点int adjvex;struct ArcNode * next;//InfoType info;}ArcNode;typedef struct VNode {//顶点表结点VertexType data;ArcNode *first;}VNode,AdjList[MaxVertexNum];typedef struct AlGraph{//邻接表AdjList vertices;int vexnum, arcnum;}ALGraph;//图的存储---十字链表(有向图)typedef struct ArcNodeT {//边表结点//以该点作为尾巴 指向其他点作为箭头int tailvex, headvex;struct ArcNodeT *hlink, *tlink;//InfoType info;}ArcNodeT;typedef struct VNodeT {//顶点表结点VertexType data;ArcNodeT *firstin, *firstout;}VNodeT;typedef struct GLGraph {//邻接表VNodeT xlist[MaxVertexNum];int vexnum, arcnum;}GLGraph;//图的存储---邻接多重表(无向图)typedef struct ArcNodeTr { //边表结点bool mark;int ivex, jvex;struct ArcNodeTr *ilink, *jlink;//InfoType info;}ArcNodeTr;typedef struct VNodeTr {//顶点表结点VertexType data;ArcNodeTr *firstedge;}VNodeTr;typedef struct AMLGraph {//邻接表VNodeTr adjmulist[MaxVertexNum];int vexnum, arcnum;}AMLGraph;

原创粉丝点击