UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.graphs
Class Path

java.lang.Object
  |
  +--edu.berkeley.guir.lib.graphs.Path
All Implemented Interfaces:
Cloneable, GraphConst, Serializable

public class Path
extends Object
implements GraphConst, Serializable, Cloneable

An object representing a Path in a Graph.

This software is distributed under the Berkeley Software License.

 Revisions:  - GUIRLib-v1.0-1.0.0, Nov 04 1997, JH
               Created class
             - GUIRLib-v1.0-1.1.0, Feb 24 2000, JH
               Updated for JDK1.3RC1 to use the Collections
             - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH
               Touched for GUIRLib release
 

Since:
1.3RC1
Version:
GUIRLib-v1.4-1.0.0, Aug 31 2000
Author:
Jason Hong ( jasonh@cs.berkeley.edu)
See Also:
Serialized Form

Fields inherited from interface edu.berkeley.guir.lib.graphs.GraphConst
DEFAULT_NUMBER_EDGES, DEFAULT_NUMBER_NODES, DEFAULT_PATH_SIZE, DEFAULT_WEIGHT, ERROR, TRUE
 
Constructor Summary
Path()
          Create a new empty Path.
 
Method Summary
 void addNode(Node node)
          Add a Node to the end of the Path.
 void addNode(Node node, float weight)
          Add a Node to the end of the Path.
 void addNode(Node node, Float weight)
          Add a Node to the end of the Path.
 Object clone()
          Shallowly clones this Path.
 boolean contains(Node node)
          See if the specified Node is contained in this Adjacency List.
 boolean contains(String strNodeName)
          See if the specified Node is contained in this Adjacency List.
 boolean equals(Object obj)
           
 Node getLastNode()
          Get the last Node added to this Path.
 Iterator getNodes()
          Return the list of Nodes.
 Iterator getNodesReversed()
          Return the list of Nodes in reverse order.
 Iterator getWeights()
          Return the list of weights.
 Iterator getWeightsReversed()
          Return the list of weights.
 boolean isCycle()
          See if there is a cycle in the Path.
 int length()
          Get the length of the path.
 void removeLastNode()
          Remove the last Node added from the Path.
 String toString()
           
 float totalWeight()
          Sum the weight in the Path.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Path

public Path()
Create a new empty Path.
Method Detail

getNodes

public Iterator getNodes()
Return the list of Nodes.
Returns:
an Iterator that contains the Nodes in this Path (Node).

getNodesReversed

public Iterator getNodesReversed()
Return the list of Nodes in reverse order.
Returns:
an Iterator that contains the Nodes in this Path (Node) in reverse order.

getWeights

public Iterator getWeights()
Return the list of weights.
Returns:
an Iterator that contains Floats, which represent the weights.

getWeightsReversed

public Iterator getWeightsReversed()
Return the list of weights.
Returns:
an Iterator that contains Floats, which represent the weights.

totalWeight

public float totalWeight()
Sum the weight in the Path.
Returns:
the weight of the Path.

isCycle

public boolean isCycle()
See if there is a cycle in the Path.
Returns:
true if there is a cycle, false otherwise.

contains

public boolean contains(Node node)
See if the specified Node is contained in this Adjacency List.
Parameters:
node - is the Node to check if for in this Adjacency List.

contains

public boolean contains(String strNodeName)
See if the specified Node is contained in this Adjacency List.
Parameters:
node - is the Node to check if for in this Adjacency List.

getLastNode

public Node getLastNode()
Get the last Node added to this Path.
Returns:
the name of the last Node, or null if there are no Nodes.

length

public int length()
Get the length of the path.
Returns:
the length of the path, nonnegative.

addNode

public void addNode(Node node)
Add a Node to the end of the Path. The weight is defaulted to GraphConst.DEFAULT_WEIGHT.

Currently no runtime checks are done to ensure that this edge is valid or even connects correctly in the Path.

Parameters:
node - is the Node to add to the end of the Path.
See Also:
GraphConst

addNode

public void addNode(Node node,
                    float weight)
Add a Node to the end of the Path.

Currently no runtime checks are done to ensure that this edge is valid or even connects correctly in the Path.

Parameters:
node - is the Node to add to the end of the Path.
weight - is the weight of the edge taken. Note that the weight is meaningless if it is the first node in a Path, and will thus be ignored.

removeLastNode

public void removeLastNode()
Remove the last Node added from the Path.

addNode

public void addNode(Node node,
                    Float weight)
Add a Node to the end of the Path.
Parameters:
strNodeName - is the name of the Node to add to the end of the Path.
See Also:
GraphConst

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
Shallowly clones this Path.
Overrides:
clone in class Object
Returns:
a Path object that has the same values as this Path object.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

Copyright Information