Package org.jgrapht.alg.shortestpath
Class ListSingleSourcePathsImpl<V,E>
- java.lang.Object
-
- org.jgrapht.alg.shortestpath.ListSingleSourcePathsImpl<V,E>
-
- Type Parameters:
V
- the graph vertex typeE
- the graph edge type
- All Implemented Interfaces:
Serializable
,ShortestPathAlgorithm.SingleSourcePaths<V,E>
public class ListSingleSourcePathsImpl<V,E> extends Object implements ShortestPathAlgorithm.SingleSourcePaths<V,E>, Serializable
An implementation ofShortestPathAlgorithm.SingleSourcePaths
which stores one path per vertex.This is an explicit representation which stores all paths. For a more compact representation see
TreeSingleSourcePathsImpl
.- Author:
- Dimitrios Michail
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Graph<V,E>
getGraph()
Returns the graph over which this set of paths is defined.GraphPath<V,E>
getPath(V targetVertex)
Return the path from the source vertex to the sink vertex.V
getSourceVertex()
Returns the single source vertex.double
getWeight(V targetVertex)
Return the weight of the path from the source vertex to the sink vertex.
-
-
-
Method Detail
-
getGraph
public Graph<V,E> getGraph()
Returns the graph over which this set of paths is defined.- Specified by:
getGraph
in interfaceShortestPathAlgorithm.SingleSourcePaths<V,E>
- Returns:
- the graph
-
getSourceVertex
public V getSourceVertex()
Returns the single source vertex.- Specified by:
getSourceVertex
in interfaceShortestPathAlgorithm.SingleSourcePaths<V,E>
- Returns:
- the single source vertex
-
getWeight
public double getWeight(V targetVertex)
Return the weight of the path from the source vertex to the sink vertex. If no such path exists,Double.POSITIVE_INFINITY
is returned. The weight of the path between a vertex and itself is always zero.- Specified by:
getWeight
in interfaceShortestPathAlgorithm.SingleSourcePaths<V,E>
- Parameters:
targetVertex
- the sink vertex- Returns:
- the weight of the path between source and sink vertices or
Double.POSITIVE_INFINITY
in case no such path exists
-
getPath
public GraphPath<V,E> getPath(V targetVertex)
Return the path from the source vertex to the sink vertex.- Specified by:
getPath
in interfaceShortestPathAlgorithm.SingleSourcePaths<V,E>
- Parameters:
targetVertex
- the sink vertex- Returns:
- the path from the source vertex to the sink vertex or null if no such path exists
-
-