First, the recommendation related articles
Recommended articles (there are illustrated, there is a simple code description), easier to understand Dijkstra (Dijkstra) algorithm.
https://www.jianshu.com/p/ff6db00ad866
Two, PSP table
Third, Item Description
1, in order to avoid the cmd run error, write test under TestMain have test cases.
2, the entity class
Station to station class, Result is the result of class
Sites like Station contains a variable: the name of the site, owned subway lines, adjacent to the site collection.
Results Result class variables comprising: the starting station, terminating stations, distance (number of stations) through the middle of the site.
3, test at Demo package for understanding Dijstra idea of the algorithm
4, DistanceBuilder various reading method comprising
Storing information including variables subway, subway and reading information and writing information underground methods, and other auxiliary method of reading information (obtained through the subway line corresponding domain name, the corresponding site Station by subway line objects)
5 DijstraUtil
This class is an implementation class Dijstra algorithm (which may result Demo package under test class)
Fourth, operating instructions
Note: Before running cmd in the contents out / production / Dijkstra in station.txt and routine.txt emptied (emptying the reason is because it is written in the form of additional information, if not empty, the result will be run multiple times, to avoid confusion) (subway.txt content must not be empty, subway information)
Note: Run Subway (comprising main function class) in cmd, the command:
"Java subway" can be. Since the subway to identify different command parameters, you must follow a strict format.
(1) reads subway.txt file:
command:
“java subway -map subway.txt”
(2) read a route subway station information:
command:
“java subway -a 1号线 -map subway.txt -o station.txt”
Description:
The information read write station.txt file.
Station.txt content:
(3) to read the information between the two sites:
command:
java subway -b 洪湖里 复兴路 -map subway.txt -o routine.txt
说明:
两站点之间的信息写入routine.txt中,和station.txt同级。注意目录为out/production/Dijstra下。
说明routine.txt内容
五、GitHub:
https://github.com/liaoxuehua/Subway-Project