武汉理工大学数据结构与算法综合实验--- 图与景区信息管理系统
软件zy1702 HJ
//main.cpp
#include <iostream>
#include "Tourism.h";
#include "Graph.h"
struct Graph m_Graph;
using namespace std;
void show_menu() {
cout << "=====景区信息管理系统=====" << endl;
cout << "1.创建景区景点图" << endl;
cout << "2.查询景点信息" << endl;
cout << "3.旅游景点导肮" << endl;
cout << "4.搜索最短路径" << endl;
cout << "5.铺设电路规划" << endl;
cout << "0.退出" << endl;
cout << "请输入操作编号(0~5):";
}
int main() {
char option[20];
while (true) {
system("pause");
system("cls");
show_menu();
cin >> option;
if (strcmp(option, "1") == 0) {
CreateGraph();
}
else if (strcmp(option, "2") == 0) {
GetSpotInfo();
}
else if (strcmp(option, "3") == 0) {
TravelPath();
}
else if (strcmp(option, "4") == 0) {
FindShortPath();
}
else if (strcmp(option, "5") == 0) {
DesignPath();
}
else if (strcmp(option, "0") == 0) {
break;
}
}
return 0;
}
//Graph.cpp
#include <iostream>
#include <bits/stdc++.h>
#include "Graph.h"
#include "Tourism.h"
extern struct Graph m_Graph;
using namespace std;
void Init(void) {
m_Graph.m_nVexNum = 0;
for (int i = 0; i < 20; i++) {
strcpy(m_Graph.m_aVexs[i].name, "");
strcpy(m_Graph.m_aVexs[i].desc, "");
m_Graph.m_aVexs[i].num = -1;
for (int j = 0; j < 20; j++) {
if (i == j) m_Graph.m_aAdjMatrix[i][j] = 0;
else m_Graph.m_aAdjMatrix[i][j] = MAX;
}
}
}// 初始化图结构。
void InsertVex(Vex sVex,int i) {
m_Graph.m_aVexs[i].num =sVex.num;
strcpy(m_Graph.m_aVexs[i].name, sVex.name);
strcpy(m_Graph.m_aVexs[i].desc, sVex.desc);
}// 将顶点添加到顶点数组中。
void InsertEdge(Edge sEdge) {
m_Graph.m_aAdjMatrix[sEdge.vex1][sEdge.vex2] = sEdge.weight;
m_Graph.m_aAdjMatrix[sEdge.vex2][sEdge.vex1] = sEdge.weight;
}// 将边保存到邻接矩阵中。
void GetVex(int nVex) {
cout << m_Graph.m_aVexs[nVex].name << endl;
cout << m_Graph.m_aVexs[nVex].desc << endl;
cout << "-----周边景区-----" << endl;
FindEdge(nVex);
}// 查询指定顶点信息。
int FindEdge(int nVex) {