Class BellmanFordShortestPath<V,W>
java.lang.Object
org.episteme.core.mathematics.discrete.BellmanFordShortestPath<V,W>
Bellman-Ford algorithm for single-source shortest paths.
Unlike Dijkstra's algorithm, Bellman-Ford can handle negative edge weights and detects negative cycles. Time complexity is O(VE).
*
Reference:
Bellman, R. (1958). On a routing problem. Quarterly of Applied Mathematics, 16, 87-90.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindAllPaths(WeightedGraph<V, W> graph, V source) Computes shortest paths from source to all vertices.Computes shortest path from source to target.static <V> BellmanFordShortestPath<V, Double> ofDouble()Creates an instance for Double weights.static <V> BellmanFordShortestPath<V, Real> ofReal()Creates an instance for Real weights.
-
Constructor Details
-
BellmanFordShortestPath
-
-
Method Details
-
ofDouble
Creates an instance for Double weights. -
ofReal
Creates an instance for Real weights. -
findPath
Computes shortest path from source to target.- Parameters:
graph- the graphsource- source vertextarget- target vertex- Returns:
- result containing distance and path, or negative cycle detection
-
findAllPaths
-