最短路径课程设计(安阳旅游导航系统)C语言完整代码
功能:
1.显示地图
2.输入起始点和目的地序号
3.最短路径长度
4.最短路径
5.退出
#include<stdio.h>
#include <string.h>
#include <stdlib.h>#define wuqiongda 10000//假设无穷大为10000
//存储最短路径值
int ShortestPathvalue[10][10] = { 0 };
//存储具体路径
int ShortestPathmatrix[10][10] = { 0 };
//地点信息
char _mapName[10][50] = { "殷墟","袁林","文字博物馆","长春观","羑里城","岳飞庙","红旗渠",
"太行大峡谷","二帝陵","明福寺"
};//距离信息,_distance[0][1] = 50;代表从下标为0到下表为1地点距离为50
int _distance[10][10] = { 0 };
//边表结点
typedef struct EdgeNode {//顶点对应的下标int adjvex;//权值int weight;//指向下一个邻接点struct EdgeNode* next;
} edgeNode;//顶点表结点
typedef struct VertexNode {//顶点数据char data[50];//边表头指针edgeNode* firstedge;
}AdjList[100];//集合
typedef struct {AdjList adjList;//顶点数和边数int numVertexes, numEdges;
} GraphAdjList;void ShowALGraph(GraphAdjList* G);void Test();//初始化地图void InitMap(GraphAdjList* G);//创建地图void CreateALGraph(GraphAdjList* G);//计算各个顶点之间最短路径void ShortestPath_Floyd(GraphAdjList* G, int P[10][10], int D[10][10]);//输出最短路径void ShowShortestResult(int begin, int end);//创建地图
void CreateALGraph(GraphAdjList* G) {edgeNode* e;int i,j;//读入顶点信息,建立顶点表for ( i = 0; i < G->numVertexes; i++){//读入顶点信息strcpy(G->adjList[i].data, _mapName[i]);//将边表置为空表G->adjList[i].firstedge = NULL;}//建立边表(头插法)for ( i = 0