Package org.jgrapht.alg.shortestpath
Class AbstractPathElement<V,E>
- java.lang.Object
-
- org.jgrapht.alg.shortestpath.AbstractPathElement<V,E>
-
- Direct Known Subclasses:
BellmanFordPathElement
,RankingPathElement
abstract class AbstractPathElement<V,E> extends java.lang.Object
A new path is created from a path concatenated to an edge. It's like a linked list.
The empty path is composed only of one vertex.
In this case the path has no previous path element.
.NOTE jvs 1-Jan-2008: This is an internal data structure for use in algorithms. For returning paths to callers, use the public
GraphPath
interface instead.- Since:
- July 5, 2007
-
-
Field Summary
Fields Modifier and Type Field Description protected int
nHops
Number of hops of the path.protected E
prevEdge
Edge reaching the target vertex of the path.protected AbstractPathElement<V,E>
prevPathElement
Previous path element.private V
vertex
Target vertex.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPathElement(AbstractPathElement<V,E> original)
Copy constructor.protected
AbstractPathElement(Graph<V,E> graph, AbstractPathElement<V,E> pathElement, E edge)
Creates a path element by concatenation of an edge to a path element.protected
AbstractPathElement(V vertex)
Creates an empty path element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<E>
createEdgeListPath()
Returns the path as a list of edges.int
getHopCount()
Returns the number of hops (or number of edges) of the path.E
getPrevEdge()
Returns the edge reaching the target vertex of the path.AbstractPathElement<V,E>
getPrevPathElement()
Returns the previous path element.V
getVertex()
Returns the target vertex of the path.
-
-
-
Field Detail
-
nHops
protected int nHops
Number of hops of the path.
-
prevEdge
protected E prevEdge
Edge reaching the target vertex of the path.
-
prevPathElement
protected AbstractPathElement<V,E> prevPathElement
Previous path element.
-
vertex
private V vertex
Target vertex.
-
-
Constructor Detail
-
AbstractPathElement
protected AbstractPathElement(Graph<V,E> graph, AbstractPathElement<V,E> pathElement, E edge)
Creates a path element by concatenation of an edge to a path element.- Parameters:
pathElement
-edge
- edge reaching the end vertex of the path element created.
-
AbstractPathElement
protected AbstractPathElement(AbstractPathElement<V,E> original)
Copy constructor.- Parameters:
original
- source to copy from
-
AbstractPathElement
protected AbstractPathElement(V vertex)
Creates an empty path element.- Parameters:
vertex
- end vertex of the path element.
-
-
Method Detail
-
createEdgeListPath
public java.util.List<E> createEdgeListPath()
Returns the path as a list of edges.- Returns:
- list of
Edge
.
-
getHopCount
public int getHopCount()
Returns the number of hops (or number of edges) of the path.- Returns:
- .
-
getPrevEdge
public E getPrevEdge()
Returns the edge reaching the target vertex of the path.- Returns:
null
if the path is empty.
-
getPrevPathElement
public AbstractPathElement<V,E> getPrevPathElement()
Returns the previous path element.- Returns:
null
is the path is empty.
-
getVertex
public V getVertex()
Returns the target vertex of the path.- Returns:
- .
-
-