graph.h

来自「一个能求图中任两顶点之间的最短距离的程序」· C头文件 代码 · 共 76 行

H
76
字号
#ifndef GRAPH_H_H
#define GRAPH_H_H

#include"Queue.h"



#define UDG 1	//无向图
#define DG 2	//有向图
#define UDN 3	//无向网
#define DN 4	//有向网

typedef int InfoType;
typedef char VertexType[50];

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

typedef struct VNode
{
	VertexType data;
	ArcNode *firstarc;
}VNode;

typedef struct 
{
	int vexnum,arcnum;
	int kind;
	VNode *pVNode;
}ALGraph;


typedef struct PathNode
{
	int index;//路经中顶点在邻接表里的下标
	struct PathNode *next;//路经中的下一顶点
}PathNode,*Path;

typedef struct PPath
{
	Path head;//路经投指针
	struct PPath * next;//下一条路经
}PPath;

typedef struct DestNode
{
	int index;
	int MinPath;
	bool forever;
	PPath *pallpath;
	struct DestNode *next;
}DestNode;

void MinPath(ALGraph &G,VertexType source);

void CreateG(ALGraph &G,int kind);//kind为图类型

bool CreateGraph(ALGraph &G);

void DFSTraverse(ALGraph &G,void (*visit)(VNode &vnode));

void BFSTraverse(ALGraph &G,void (*visit)(VNode &vnode));

void SaveToFile(ALGraph &G,char filename[50]);

void ReadFromFile(ALGraph &G,char filename[50]);

void ToAdjMatrix(ALGraph &G,VertexType *&a,int **&pmatrix);

void MinPath(ALGraph &G,VertexType v0);
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?