First, understand the project
1. Design requirements: command line program under way subway trip planning (shortest path)
2. Design tools: JAVA Eclipse compiler
3. Data processing: Data written text importer, will fall into text files stored in different
4. Test program: adequate test sample (10) to ensure the correct operation of the program
5. Program input: to enter the station 1. 2. inbound
6: Design Language: java
Second, the text format design
1. The input text using the format json
1 { 2 "line1": [ 3 { 4 "station1": "苹果园站", 5 "status": "enable" 6 “transfer”: "station2" 7 }, 8 { 9 "station2": "古城站", 10 "status": "enable" 11 “transfer”: "null" 12 { 13 "station3": "八角游乐园站", 14 "status": "enable" 15 “transfer”: "null" 16 } 17 ] 18 }
2.输入设计
起始站点:xxx
目标站点:xxx
3.输出设计:
1号线
站点x
站点y
站点z
……
站点h(站内换乘x号线)
2号线(换乘)
站点a
站点b
站点c
……
二、算法思路
这个地铁行程规划项目可以将地铁线路图看成是图里面的节点和距离。所以我将会把每个节点之间的距离设定成1,那么问题就会转变成一个高级数据结构中的最小路径算法
通常最小路径算法会有Dijkstra算法与Floyd算法两种,因为本人较为熟悉Dijkstra算法,所以本项目中我们将会采用Dijkstra算法所以集体如下
1.Dijkstra算法实现
2.实现错误提示
3.根据地铁线输出站名
4.换乘情况下的最短路径与非换乘情况显得最短路径
5.使用java类进行封装,使用邻接表进行站点的存储