邻接表的数据结构,最为常考的结构;邻接矩阵,十字链表,邻接多重表不常考,定义放在文章的最后
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;