Metro Line

demand analysis

1. The information needs to be stored underground

2. Design read command line subway information

3. The need to be able to query output destination of all passing subway station

4 can calculate the shortest route between two locations

The performance test can be performed

6. completion unit tests

Realization of ideas

To complete the job, in fact, to do file storage, query subway lines and the shortest path problem

1. xml files are stored subway line

2. Path algorithm stored in a txt document, wherein the path length to include, lines and subway stations.

3. traverse the list to find the lines and output lines of inquiry

4. Use the java programming language to accomplish this job

algorithm design

1. subway line is converted into an undirected graph, shortest line is actually the shortest path problem, the site is a node, is the edge line between two adjacent sites.

2. You can use Dijstra algorithms to solve shortest path problems, his time complexity is O (VlogV)

3. If the user enters the site does not exist, or no line between the two sites, or input error, you need to throw an error

Guess you like

Origin www.cnblogs.com/zucc31701081/p/11549888.html