> # ♻️ 资源
> **大小:** 829KB
> **文档链接:**[**https://www.yuque.com/sxbn/ks/100010776**](https://www.yuque.com/sxbn/ks/100010776)
> **➡️ 资源下载:**[**https://download.csdn.net/download/s1t16/87450312**](https://download.csdn.net/download/s1t16/87450312)
> **注:更多内容可关注微信公众号【神仙别闹】,如当前文章或代码侵犯了您的权益,请私信作者删除!**
> ![qrcode_for_gh_d52056803b9a_344.jpg](https://cdn.nlark.com/yuque/0/2023/jpeg/2469055/1692147256036-49ec7e0c-5434-4963-b805-47e7295c9cbc.jpeg#averageHue=%23a3a3a3&clientId=u8fb96484-770e-4&from=paste&height=140&id=u237e511a&originHeight=344&originWidth=344&originalType=binary&ratio=1.25&rotation=0&showTitle=false&size=8270&status=done&style=none&taskId=ud96bf5f7-fe85-4848-b9c2-82251181297&title=&width=140.1999969482422)
# 全国交通咨询系统
# 数据结构课程设计报告
## 设计目的
全国交通咨询模拟。处于不同目的的旅客对交通工具有不同的要求。例如,因公出差的旅客希望在旅途中的时间尽可能的短,出门旅游的游客则期望旅费尽可能省,而老年旅客则需要中转次数最少。编制一个全国城市间的交通咨询程序,为旅客提供两种或三种最优决策的交通咨询。
## 设计内容
提供用户以及管理员功能,用户可以对交通图进行查询,而管理员可以对交通图进行增删查改,同时管理员可以登陆、修改密码等待操作,界面采用字符界面。这样操作,更加真实地模拟了交通咨询系统。关于要求的功能,实现了城市线路的增加、删除、显示,基于 Dijkstra 的从源点到汇点的最小费用算法与最小时间算法。
概要设计
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562738579-0362c98c-d09a-48d5-aabb-80a8faccf9c9.png#averageHue=%23141312&from=url&id=JyXkK&originHeight=973&originWidth=1205&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
### 功能模块图
各个模块详细的功能描述。
查询城市编号:头结点建立顶点表时存储的是城市对应的序号手动添加城市从文件读取以添加城市删除城市:删除城市时需要删除与该城市相关的所有线路输出所有城市更新城市列表:当新建城市个数加原本已存在城市个数大于 MAXSIZE 时,需要开辟空间存储新城市并 ++MAXSIZE 手动添加线路插入线路:由于线路信息存于表结点里,所以需要新建表结点并加入对应起始城市的边表从文件中读取线路
删除线路求最少花费路径求最少时间路径
详细设计
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562738712-b373de6f-74a3-4c9a-9325-468de42bcf48.png#averageHue=%23010101&from=url&id=d1QG2&originHeight=975&originWidth=2020&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
功能函数的调用关系图
### 各功能函数的数据流程图
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562738789-b7af4885-3173-490c-824b-90587aa8e8d3.png#averageHue=%23ededed&from=url&id=VfamS&originHeight=185&originWidth=198&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562738852-7fdebf5c-8434-4137-9a34-936812cf5ce5.png#averageHue=%23eeeeee&from=url&id=TtzIn&originHeight=187&originWidth=186&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562738948-e5cef378-7def-4d3e-9b25-0b82a7c61684.png#averageHue=%23ededed&from=url&id=pDhWW&originHeight=174&originWidth=191&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739033-6d82050c-2882-4a41-86e7-e69d90a1b5f7.png#averageHue=%23ececec&from=url&id=UeLJk&originHeight=280&originWidth=193&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739102-665c3871-3953-40db-9c6e-34638ead9e83.png#averageHue=%23e7e7e7&from=url&id=l1b1E&originHeight=280&originWidth=185&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739172-d1446704-d234-4ff7-8855-8da6252764d2.png#averageHue=%23e2e2e2&from=url&id=hWizl&originHeight=386&originWidth=210&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739250-da339ab9-7e87-4c3f-982f-a636918bd320.png#averageHue=%23ebebeb&from=url&id=l2mFc&originHeight=376&originWidth=216&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739332-1f19e1c9-42fe-4b5d-ba6e-49a5e3c5cd65.png#averageHue=%23e6e6e6&from=url&id=FONSg&originHeight=508&originWidth=193&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739392-91db4a22-c0c0-4585-b351-0393d42b936f.png#averageHue=%23e9e9e9&from=url&id=oHjyb&originHeight=286&originWidth=219&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739470-4347b3dc-4b90-4dcc-8910-771bbe504ffa.png#averageHue=%23ebebeb&from=url&id=kFfnQ&originHeight=289&originWidth=233&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739532-e7cb05a6-f9ff-4fef-afee-d48fd7c67d96.png#averageHue=%23e0e0e0&from=url&id=nFctW&originHeight=429&originWidth=226&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739602-4e00dfd8-7ae9-4d40-9564-c7694aa6d992.png#averageHue=%23eeeeee&from=url&id=Ef4fF&originHeight=179&originWidth=212&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739684-20eddfba-214f-4b57-8bb0-ab79d9675e85.png#averageHue=%23efefef&from=url&id=j08eF&originHeight=188&originWidth=196&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739757-59af6863-6826-47e3-88d9-4ebed3966fbd.png#averageHue=%23ececec&from=url&id=tLo0V&originHeight=188&originWidth=208&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739825-aea015e9-5bae-4a22-b3dc-6d8e56ebfb66.png#averageHue=%23e0e0e0&from=url&id=QCyRE&originHeight=508&originWidth=159&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739894-f5ef2aee-0cce-47ea-8bb5-50777043a8c1.png#averageHue=%23e5e5e5&from=url&id=ixzYx&originHeight=171&originWidth=128&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562739985-d52a6e34-7ca5-4464-9e08-29145c13ad79.png#averageHue=%23e0e0e0&from=url&id=nuFBj&originHeight=594&originWidth=197&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
![](https://cdn.nlark.com/yuque/0/2024/png/2469055/1715562740048-f5d71aee-a2fd-4092-a75b-dc1cd01c4a4d.png#averageHue=%23e7e7e7&from=url&id=X9V57&originHeight=389&originWidth=290&originalType=binary&ratio=1&rotation=0&showTitle=false&status=done&style=none&title=)
### 重点设计及编码
用优先队列优化的基于 dijkstra 算法的最小费用与最小时间算法,代码如下:
```
//最少花费路径 struct Node { int id; //源顶点 id float money; //估算距离(费用)
//由于 stl 中