#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define MaxVertexNum 1000
bool Visited[MaxVertexNum]; /**< 记录顶点是否已经被访问了 */
typedef int Vertex;
typedef int WeightType;
typedef char DataType;
/**< 边的定义 */
typedef struct ENode *PtrToENode;
struct ENode
{
Vertex V1, V2;
WeightType Weight;
};
typedef PtrToENode Edge;
/**< 邻接点的定义 */
typedef struct AdjVNode *PtrToAdjVNode;
struct AdjVNode
{
Vertex AdjV;
WeightType Weight;
PtrToAdjVNode Next;
};
typedef PtrToAdjVNode AdjVertex;
/**< 顶点表头结点的定义 */
typedef struct Vnode
{
AdjVertex FirstEdge;
DataType Data;
}AdjList[MaxVertexNum];
/**< 图结点定义 */
typedef struct GNode *PtrToGNode;
struct GNode
{
int Nv;
int Ne;
AdjList G;
};
typedef PtrToGNode LGraph;
LGraph CreateGraph(int VertexNum);
LGraph CreateGraph(int VertexNum)
{
LGraph Graph = (LGraph)malloc(siz
邻接表形式的图的深度优先搜索
最新推荐文章于 2023-06-05 04:56:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)