class Graphlb::Algorithms::Dijkstras
- Graphlb::Algorithms::Dijkstras
- Reference
- Object
Overview
Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a graph,
Given a graph and source vertex dijkstra function finds the shortest distance from the source vertex to all other vertices in the graph
Defined in:
graphlb/algorithms/dijkstras.crConstructors
-
.new(graph, source)
Runs the Dijkstras Algorithm on the given graph and the source node
Instance Method Summary
-
#shortest_path(source, target)
constructs a path from source vertex to target vertex
-
#shortest_paths(source)
constructs a path from source vertex to all other vertices in the graph
Constructor Detail
Runs the Dijkstras Algorithm on the given graph and the source node
@param : graph, A directed graph,
@param : Source, Source vertex form which the algorithm starts running,
@raise : it raises an exception when there is a negative edge in the graph
Instance Method Detail
constructs a path from source vertex to target vertex
@param : prev , prev hash contains the previous node of all the vertices
@param : Source, the source vertex for the path
@param : target, The vertex till which the path should be constructed
@return : An array which contains all the vertices(path) to be travelled to reach from source to target vertex
constructs a path from source vertex to all other vertices in the graph
@param : Source, the source vertex for the path
@return : An array which contains all the vertices(path) to be travelled to reach from source vertex to all other vertices in the graph