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.ObjectA 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
GraphPathinterface instead.- Since:
- July 5, 2007
-
-
Field Summary
Fields Modifier and Type Field Description protected intnHopsNumber of hops of the path.protected EprevEdgeEdge reaching the target vertex of the path.protected AbstractPathElement<V,E>prevPathElementPrevious path element.private VvertexTarget vertex.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPathElement(AbstractPathElement<V,E> original)Copy constructor.protectedAbstractPathElement(Graph<V,E> graph, AbstractPathElement<V,E> pathElement, E edge)Creates a path element by concatenation of an edge to a path element.protectedAbstractPathElement(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.intgetHopCount()Returns the number of hops (or number of edges) of the path.EgetPrevEdge()Returns the edge reaching the target vertex of the path.AbstractPathElement<V,E>getPrevPathElement()Returns the previous path element.VgetVertex()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:
nullif the path is empty.
-
getPrevPathElement
public AbstractPathElement<V,E> getPrevPathElement()
Returns the previous path element.- Returns:
nullis the path is empty.
-
getVertex
public V getVertex()
Returns the target vertex of the path.- Returns:
- .
-
-