V
- the graph vertex typeE
- the graph edge typepublic class ListSingleSourcePathsImpl<V,E> extends Object implements ShortestPathAlgorithm.SingleSourcePaths<V,E>, Serializable
ShortestPathAlgorithm.SingleSourcePaths
which stores one path per vertex.
This is an explicit representation which stores all paths. For a more compact representation see
TreeSingleSourcePathsImpl
.
Modifier and Type | Field and Description |
---|---|
protected Graph<V,E> |
graph
The graph
|
protected Map<V,GraphPath<V,E>> |
paths
One path per vertex
|
protected V |
source
The source vertex of all paths
|
Constructor and Description |
---|
ListSingleSourcePathsImpl(Graph<V,E> graph,
V source,
Map<V,GraphPath<V,E>> paths)
Construct a new instance.
|
Modifier and Type | Method and 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.
|
protected V source
public Graph<V,E> getGraph()
getGraph
in interface ShortestPathAlgorithm.SingleSourcePaths<V,E>
public V getSourceVertex()
getSourceVertex
in interface ShortestPathAlgorithm.SingleSourcePaths<V,E>
public double getWeight(V targetVertex)
Double.POSITIVE_INFINITY
is returned. The weight of the path between a
vertex and itself is always zero.getWeight
in interface ShortestPathAlgorithm.SingleSourcePaths<V,E>
targetVertex
- the sink vertexDouble.POSITIVE_INFINITY
in case no such path existspublic GraphPath<V,E> getPath(V targetVertex)
getPath
in interface ShortestPathAlgorithm.SingleSourcePaths<V,E>
targetVertex
- the sink vertexCopyright © 2019. All rights reserved.