⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graph.h

📁 一个能求图中任两顶点之间的最短距离的程序
💻 H
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -