Method: RGL::Graph#dijkstra_shortest_path
- Defined in:
- lib/rgl/dijkstra.rb
#dijkstra_shortest_path(edge_weights_map, source, target, visitor = DijkstraVisitor.new(self)) ⇒ Object
Finds the shortest path from the source to the target in the graph.
If the path exists, returns it as an Array of vertices. Otherwise, returns nil.
Raises ArgumentError if edge weight is negative or undefined.
116 117 118 |
# File 'lib/rgl/dijkstra.rb', line 116 def dijkstra_shortest_path(edge_weights_map, source, target, visitor = DijkstraVisitor.new(self)) DijkstraAlgorithm.new(self, edge_weights_map, visitor).shortest_path(source, target) end |