1、邻接矩阵
1.1:邻接矩阵的概念

1.2:用邻接矩阵存储图对应的代码

cpp
#define Max_Vertex_Num 20 //定义最大顶点数量
typedef char VertexType;
typedef int EdgeType;
typedef struct{
int vexnum,arcnum; //图中的顶点数和边数
VertexType vexs[Max_Vertex_Num]; //存放顶点中的值
EdgeType edges[Max_Vertex_Num][Max_Vertex_Num]; // 邻接矩阵
}MGraph; // 图的结构
1.3:通过邻接矩阵求顶点的度

1.4:通过邻接矩阵判断两个顶点之间是否有边

1.5 习题
习题1(易)

2.邻接表
2.1:邻接表的概念

2.2:通过邻接表求顶点的度

2.3:用邻接表存储图对应的代码(难)
cpp
// 边结点
typedef struct ArcNode {
int adjvex; // 邻接点的下标(顶点编号)
struct ArcNode *nextarc; // 指向下一条边的指针
} ArcNode;
// 顶点结构(邻接表头结点)
typedef struct ArcNode {
int adjvex; // 邻接点的下标(顶点编号)
ArcNode *nextarc; // 指向下一条边的指针
} ArcNode,AdjList[MaxVertexNum];
// 表示可以用AdjList定义一个长度为MaxVertexNum,每个元素的类型为struct ArcNode类型的数组。
// 即AdjList a等价于struct ArcNode a[MaxVertexNum]
// 邻接表表示的图
typedef struct {
AdjList a;//等价于struct ArcNode a[MaxVertexNum] // 顶点数组
int vexnum, arcnum; // 顶点数、边数
} ALGraph;
3.邻接表和邻接矩阵的对比
