Skip to content

step17/hw6-sol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HW6 example solution

This is an example solution for STEP HW6, implemented in Go.

Part 1:

Part 2:

Ther's two choices for priorities in routing: least transfers, or least stations in the path.

To compute the "least stations" path, it's simply computed via BFS over the train station network.

To compute the "least transfers" path, the train station network graph is transformed into an atlernate graph where all of the stations on the same line share an edge. On this graph, a shortest BFS path finds the stations where transfers should happen. Then between each of these "landmark stations", BFS is used again over the single line used between those "landmark stations" to enumerate a stations between them.

For example this adjacency graph for Tokyo:

Tokyo adjacency

And the corresponding line adjacency graph where stations on the same line are connected:

Tokyo adjacency

About

Example solution for HW6

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published