org.apache.commons.graph.model
Class InMemoryPath<V extends Vertex,WE extends WeightedEdge<V>>

java.lang.Object
  extended by org.apache.commons.graph.model.InMemoryPath<V,WE>
Type Parameters:
V - the Graph vertices type
WE - the Graph weighted edges type
All Implemented Interfaces:
Path<V,WE>, WeightedPath<V,WE>

public final class InMemoryPath<V extends Vertex,WE extends WeightedEdge<V>>
extends Object
implements WeightedPath<V,WE>

Support WeightedPath implementation, optimized for algorithms (such Dijkstra's) that need to rebuild the path traversing the predecessor list bottom-up.


Constructor Summary
InMemoryPath(V start, V end, Double weigth)
           
 
Method Summary
 void addEdgeInHead(WE edge)
           
 void addEdgeInTail(WE edge)
           
 void addVertexInHead(V vertex)
           
 void addVertexInTail(V vertex)
           
 boolean equals(Object obj)
          
 List<WE> getEdges()
          getEdges() - This returns a list of Edges which comprise the path.
 V getSource()
          Returns the source of the path.
 V getTarget()
          Returns the target of the path.
 List<V> getVertices()
          getVertices() - This returns a list of Vertices, in order as they go from Start to End.
 Double getWeight()
          Gets the weight attribute of the WeightedPath object.
 int hashCode()
          
 int size()
          size() - This returns the size of the path in terms of number of verticies it visits.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InMemoryPath

public InMemoryPath(V start,
                    V end,
                    Double weigth)
Method Detail

getSource

public V getSource()
Returns the source of the path.

Specified by:
getSource in interface Path<V extends Vertex,WE extends WeightedEdge<V>>

getTarget

public V getTarget()
Returns the target of the path.

Specified by:
getTarget in interface Path<V extends Vertex,WE extends WeightedEdge<V>>

addVertexInHead

public void addVertexInHead(V vertex)

addVertexInTail

public void addVertexInTail(V vertex)

getVertices

public List<V> getVertices()
getVertices() - This returns a list of Vertices, in order as they go from Start to End. This includes the Start and End vertex, and will have one more entry than the Edges list.

Specified by:
getVertices in interface Path<V extends Vertex,WE extends WeightedEdge<V>>

addEdgeInHead

public void addEdgeInHead(WE edge)

addEdgeInTail

public void addEdgeInTail(WE edge)

getEdges

public List<WE> getEdges()
getEdges() - This returns a list of Edges which comprise the path. It will have one less than the list of Vertices.

Specified by:
getEdges in interface Path<V extends Vertex,WE extends WeightedEdge<V>>

size

public int size()
size() - This returns the size of the path in terms of number of verticies it visits.

Specified by:
size in interface Path<V extends Vertex,WE extends WeightedEdge<V>>

getWeight

public Double getWeight()
Gets the weight attribute of the WeightedPath object.

Specified by:
getWeight in interface WeightedPath<V extends Vertex,WE extends WeightedEdge<V>>
Returns:
the weight attribute of the WeightedPath object.

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2001-2011 The Apache Software Foundation. All Rights Reserved.