最短路径(迪杰斯特拉算法)

#include
using namespace std;
#include
#define maxSize 100
#define INF 0x3f3f3f3f
typedef struct 
{
	int no;        //顶点编号 
	char info;     //顶点其他信息 
}VertexType;
typedef struct 
{
	int edges[maxSize][maxSize];
	int n,e;                  //分别为顶点数和边数 
	VertexType vex[maxSize];  //存放结点信息 
}MGraph;
void printfPath(int path[],int a)
{
	int stack[maxSize],top=-1;
	while(path[a]!=-1)
	{
		stack[++top]=a;
		a=path[a];
	}
	stack[++top]=a;
	while(top!=-1)
		cout<>n>>e; 
	g.n=n,g.e=e;
	memset(g.edges,INF,sizeof(g.edges));
	for(int i=0;i>a>>b>>w;
		g.edges[i][i]=0;
		g.edges[a][b]=w;
	}
	int dist[maxSize],path[maxSize];
	Dijkstra(g,0,dist,path);
	for(int i=0;i

 

你可能感兴趣的:(图,数据结构(天勤代码实现))