phylonet.graph.model
Class PathImpl

java.lang.Object
  extended by phylonet.graph.model.PathImpl
All Implemented Interfaces:
Path
Direct Known Subclasses:
HershbergerMaxelSuriKSSP.HMSPath

public class PathImpl
extends java.lang.Object
implements Path

This class provides a basic implementation of the Path interface. It is designed to be easily used and to be easily extended for more specific path implementations.

Author:
Derek Ruths

Constructor Summary
PathImpl(Edge[] edges)
          Build the path from an array of edges.
 
Method Summary
 boolean contains(Node n)
           
 java.lang.Iterable<Edge> getEdgePath()
           
 void getEdges(Edge[] edge_array)
          Retrieve the actual edges in the path, in order from source to end.
 Node getEnd()
           
 int getLength()
           
 java.lang.Iterable<Node> getNodePath()
           
 void getNodes(Node[] node_array)
          Retrieve the actual nodes in the path, in order from source to end.
 Node getSource()
           
 double getWeight()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathImpl

public PathImpl(Edge[] edges)
Build the path from an array of edges. Adjacent edges must share a vertex with their neighbors (enforcing the standard definition of a path).

Method Detail

getSource

public Node getSource()
Specified by:
getSource in interface Path
Returns:
the starting node of the path.

getEnd

public Node getEnd()
Specified by:
getEnd in interface Path
Returns:
the ending node in the path.

getLength

public int getLength()
Specified by:
getLength in interface Path
Returns:
the number of nodes in this path, including the source and end. If the path length is n, then the number of edges is n-1.

getWeight

public double getWeight()
Specified by:
getWeight in interface Path
Returns:
the weight of this path - the sum of the weights of the edges comprising it. If any of the edges are unweighted, then the return value is Edge.NO_WEIGHT.

getNodes

public void getNodes(Node[] node_array)
Retrieve the actual nodes in the path, in order from source to end.

Specified by:
getNodes in interface Path
Parameters:
node_array - must be an array with length greater than or equal to the length of this path.

getEdges

public void getEdges(Edge[] edge_array)
Retrieve the actual edges in the path, in order from source to end.

Specified by:
getEdges in interface Path
Parameters:
edge_array - must be an array with length greater than or equal to the this path's length - 1.

getEdgePath

public java.lang.Iterable<Edge> getEdgePath()
Specified by:
getEdgePath in interface Path
Returns:
an object which can be iterated over to give the edges. The edges will be supplied in order from source to end

getNodePath

public java.lang.Iterable<Node> getNodePath()
Specified by:
getNodePath in interface Path
Returns:
an object which can be iterated over to give the nodes. The nodes will be supplied in order from source to end

contains

public boolean contains(Node n)
Specified by:
contains in interface Path
Returns:
true only if this path contains the node n.