Class ShortestPathAlgorithm
- java.lang.Object
-
- org.insa.graphs.algorithm.AbstractAlgorithm<ShortestPathObserver>
-
- org.insa.graphs.algorithm.shortestpath.ShortestPathAlgorithm
-
- Direct Known Subclasses:
BellmanFordAlgorithm
,DijkstraAlgorithm
public abstract class ShortestPathAlgorithm extends AbstractAlgorithm<ShortestPathObserver>
-
-
Field Summary
-
Fields inherited from class org.insa.graphs.algorithm.AbstractAlgorithm
data, observers
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ShortestPathAlgorithm(ShortestPathData data)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ShortestPathSolution
doRun()
Abstract method that should be implemented by child class.ShortestPathData
getInputData()
void
notifyDestinationReached(Node node)
Notify all observers that the destination has been reached.void
notifyNodeMarked(Node node)
Notify all observers that a node has been marked, i.e.void
notifyNodeReached(Node node)
Notify all observers that a node has been reached for the first time.void
notifyOriginProcessed(Node node)
Notify all observers that the origin has been processed.ShortestPathSolution
run()
Run the algorithm and return the solution.-
Methods inherited from class org.insa.graphs.algorithm.AbstractAlgorithm
addObserver, getObservers
-
-
-
-
Constructor Detail
-
ShortestPathAlgorithm
protected ShortestPathAlgorithm(ShortestPathData data)
-
-
Method Detail
-
run
public ShortestPathSolution run()
Description copied from class:AbstractAlgorithm
Run the algorithm and return the solution. This methods internally time the call to doRun() and update the result of the call with the computed solving time.- Overrides:
run
in classAbstractAlgorithm<ShortestPathObserver>
- Returns:
- The solution found by the algorithm (may not be a feasible solution).
-
doRun
protected abstract ShortestPathSolution doRun()
Description copied from class:AbstractAlgorithm
Abstract method that should be implemented by child class.- Specified by:
doRun
in classAbstractAlgorithm<ShortestPathObserver>
- Returns:
- The solution found, must not be null (use an infeasible or unknown status if necessary).
-
getInputData
public ShortestPathData getInputData()
- Overrides:
getInputData
in classAbstractAlgorithm<ShortestPathObserver>
- Returns:
- Input for this algorithm.
-
notifyOriginProcessed
public void notifyOriginProcessed(Node node)
Notify all observers that the origin has been processed.- Parameters:
node
- Origin.
-
notifyNodeReached
public void notifyNodeReached(Node node)
Notify all observers that a node has been reached for the first time.- Parameters:
node
- Node that has been reached.
-
notifyNodeMarked
public void notifyNodeMarked(Node node)
Notify all observers that a node has been marked, i.e. its final value has been set.- Parameters:
node
- Node that has been marked.
-
notifyDestinationReached
public void notifyDestinationReached(Node node)
Notify all observers that the destination has been reached.- Parameters:
node
- Destination.
-
-