Package graphs.shortestpaths
Class BellmanFordSolver<V>
- java.lang.Object
-
- graphs.shortestpaths.BellmanFordSolver<V>
-
- Type Parameters:
V
- the type of vertices.
- All Implemented Interfaces:
ShortestPathSolver<V>
public class BellmanFordSolver<V> extends Object implements ShortestPathSolver<V>
Bellman-Ford algorithm implementation of theShortestPathSolver
interface.- See Also:
ShortestPathSolver
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface graphs.shortestpaths.ShortestPathSolver
ShortestPathSolver.Constructor<V>
-
-
Constructor Summary
Constructors Constructor Description BellmanFordSolver(Graph<V> graph, V start)
Constructs a new instance by executing Bellman-Ford algorithm on the graph from the start.
-
-
-
Method Detail
-
solution
public List<V> solution(V goal)
Description copied from interface:ShortestPathSolver
Returns the single-pair shortest path from a start vertex to the goal.- Specified by:
solution
in interfaceShortestPathSolver<V>
- Parameters:
goal
- the goal vertex.- Returns:
- a list of vertices representing the shortest path.
-
-