Module: Doodl::SingleSourceShortestPath
- Included in:
- BellmanFord, DijkstraShortestPath
- Defined in:
- lib/shortest_path/single_source.rb
Instance Method Summary collapse
Instance Method Details
#edge_path_to(node) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/shortest_path/single_source.rb', line 19 def edge_path_to(node) path = [] if @dist[node] != INFINITY while node != @source path.unshift @graph.get_edge(@prev[node], node) node = @prev[node] end end return path end |
#node_path_to(node) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/shortest_path/single_source.rb', line 7 def node_path_to(node) path = [] if @dist[node] != INFINITY while node != @source path.unshift node node = @prev[node] end path.unshift @source end return path end |