class Graphlb::Algorithms::BellmanFord
- Graphlb::Algorithms::BellmanFord
- Reference
- Object
Overview
Bellman Ford's algorithm is an algorithm for finding the shortest paths between nodes in a graph,
Given a graph and source vertex Bellman Fords algorithm finds the shortest distance from the source vertex to all other vertices in the graph. It also finds wheather a negative cycle is prsent in a graph or not
Defined in:
graphlb/algorithms/bellman_ford.crInstance Method Summary
-
#path_constructor(prev, source, target)
constructs a path from source vertex to target vertex Returns the shortest path, if it exists, as an Array of vertices.
-
#run(graph, source)
returns two hashes, one contains the distance is vetex from the source node whereas, other hash conntains the information about the previous nodes for vertices in the graph
Instance Method Detail
constructs a path from source vertex to target vertex Returns the shortest path, if it exists, as an Array of vertices.
returns two hashes, one contains the distance is vetex from the source node whereas, other hash conntains the information about the previous nodes for vertices in the graph