【文件属性】:
文件名称:校园最短路径问题的求解
文件大小:42KB
文件格式:DOC
更新时间:2013-07-11 08:04:14
路径
#include
#include
#include
#define INFINITY 10000 //最大值
#define MAX_V 30 //最大顶点个数
typedef struct{
char* vexs[MAX_V]; //顶点向量
int arcs[MAX_V][MAX_V];//邻接矩阵
int vexnum,arcnum;//图的当前顶点数和弧数
}MGraph;
int have[30];
int CreateUDN(MGraph &G)
{//采用数组(邻接矩阵)表示法,构造无向网G.
int i = 0,j=0;
G.vexnum = 17; G.arcnum = 10;
G.vexs[0] = "银杏苑"; G.vexs[1] = "邓安堂楼"; G.vexs[2] = "紫荆苑";
G.vexs[3] = "紫薇苑"; G.vexs[4] = "碧桂苑"; G.vexs[5] = "东楼(美术楼)";
G.vexs[6] = "行政楼"; G.vexs[7] = "西楼(中文楼)"; G.vexs[8] = "第四饭堂";
G.vexs[9] = "图书馆"; G.vexs[10] = "黎灿活动中心"; G.vexs[11] ="英东生物工程学院";
G.vexs[12] = "青年湖"; G.vexs[13] = "信息工程学院"; G.vexs[14] = "体育馆";
G.vexs[15] = "丹桂苑"; G.vexs[16] = "南区大门";
for(i=0;i>v0>>end;
ShortPath(G,v0,P,D);
cout<<"最短路径: ";
for(i=0;i";
}
cout<