net.aronnax.CountPaths
Class Path

java.lang.Object
  extended by net.aronnax.CountPaths.Path

public class Path
extends java.lang.Object

Class Path represents a trip through several vertices in some order. This version of Path supposes that you already know the maximum number of vertices that will be travelled through. If this isn't true, the class will need modified to dynamically grow the internal array.

Version:
$Id: Path.java 32 2010-12-26 07:33:10Z rassilon $
See Also:
Vertex

Constructor Summary
Path(int maxPathLength, Vertex V)
          This constructor creates a bare minimum Path: it has a maximum length and a starting Vertex.
Path(int maxPathLength, Vertex[] vertexPathIn)
          This constructor initializes a Path with the vertices passed in the vertexPathIn array and has a size bigger than or equal to the passed array specified by maxPathLength.
Path(Vertex[] vertexPathIn)
          This constructor initializes a Path with the vertices passed in the vertexPathIn array and the same array size.
 
Method Summary
 void add(Vertex V)
          The add method allows one to append a new Vertex to the Path.
 Path copyAndAdd(Vertex V)
          The copyAndAdd method provides a way to create a copy of the current Path with the addition of a new Vertex at the end.
 Path copyPath()
          The copyPath method permits one to create an identical Path to the current one.
 boolean hasDuplicates()
          The hasDuplicates method checks to see if the last Vertex added has created a duplicate Vertex in the Path.
 Vertex lastVertex()
          The lastVertex method returns the current end of the Path (aka the last Vertex added to the Path).
 int length()
          The length method returns the number of steps in the current Path.
 java.lang.String toString()
          The toString method returns a String object that describes the way the Path traverses the various Vertex points.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Path

public Path(int maxPathLength,
            Vertex V)
This constructor creates a bare minimum Path: it has a maximum length and a starting Vertex.

Parameters:
maxPathLength - The maximum number of steps in this Path.
V - The starting Vertex of this Path.

Path

public Path(Vertex[] vertexPathIn)
This constructor initializes a Path with the vertices passed in the vertexPathIn array and the same array size. This is useful for creating copies of the current path before added a new Vertex.

Parameters:
vertexPathIn - An array of vertices describing a Path. (Need not be completely filled.)

Path

public Path(int maxPathLength,
            Vertex[] vertexPathIn)
This constructor initializes a Path with the vertices passed in the vertexPathIn array and has a size bigger than or equal to the passed array specified by maxPathLength. This can be used to dynamically grow Path lengths if desired.

Parameters:
maxPathLength - The maximum number of steps in this Path. (Should be bigger or equal to the passed array length.)
vertexPathIn - An array of vertices describing a Path. (Need not be completely filled.)
Method Detail

add

public void add(Vertex V)
The add method allows one to append a new Vertex to the Path.

Parameters:
V - The next Vertex in this Path.

copyPath

public Path copyPath()
The copyPath method permits one to create an identical Path to the current one. This can be used to split off Paths that differ only by the last Vertex.

Returns:
A new Path object that has all the same vertices.

copyAndAdd

public Path copyAndAdd(Vertex V)
The copyAndAdd method provides a way to create a copy of the current Path with the addition of a new Vertex at the end.

Parameters:
V - A new Vertex to be added to a copy of the current Path.
Returns:
A copy of the current Path with a new Vertex V appended at the end.

lastVertex

public Vertex lastVertex()
The lastVertex method returns the current end of the Path (aka the last Vertex added to the Path).

Returns:
The last Vertex added to this Path (ie, the current end of the Path).

hasDuplicates

public boolean hasDuplicates()
The hasDuplicates method checks to see if the last Vertex added has created a duplicate Vertex in the Path.

Returns:
True if the current Path has developed duplicates do to the last Vertex addition.

length

public int length()
The length method returns the number of steps in the current Path.

Returns:
The current number of edges (steps) in the Path.

toString

public java.lang.String toString()
The toString method returns a String object that describes the way the Path traverses the various Vertex points. It is written in a way that should be easy for a human to understand and a computer to parse.

Overrides:
toString in class java.lang.Object
Returns:
A String describing the Path through the Vertex points.