All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class rpi.goldsd.graph.Vertex

java.lang.Object
   |
   +----rpi.goldsd.graph.Vertex

public class Vertex
extends Object
implements Cloneable, Hashable
The Vertex class is used to represent a single vertex, and is associated with zero or one GraphBase objects.

Version:
2.2, 5/11/98
Author:
David Goldschmidt
See Also:
GraphBase

Variable Index

 o associatedGraph
A reference to the graph that this vertex is associated with; or null if this vertex is not associated with a graph.
 o data
The Hashable object associated with this vertex.
 o distance
Used by the static Algorithms class.
 o incidentEdges
A reference to the Vector used to contain the set of edges incident with this vertex.
 o incomingEdges
A reference to the Vector used to contain the set of incoming directed edges incident to this vertex.
 o min
Used by the static Algorithms class.
 o parent
Used by the static Algorithms class.
 o rank
Rank field used internally by the static Algorithms class.
 o status
Status field used internally by the static Algorithms class.

Constructor Index

 o Vertex()
Constructs a vertex with default attributes.
 o Vertex(Hashable)
Constructs a vertex with the initial user-defined object to be associated with this vertex.
 o Vertex(int)
Constructs a vertex with the initial integer value to be associated with this vertex.
 o Vertex(String)
Constructs a vertex with the initial String object to be associated with this vertex.
 o Vertex(Vertex)
Constructs a vertex by copying the attributes of another vertex.

Method Index

 o addIncidentEdge(Edge)
Adds an incident edge to this vertex.
 o addIncomingEdge(DirectedEdge)
Adds an incoming directed edge to this vertex.
 o clone()
Clones this vertex.
 o data()
Returns a reference to the Hashable object that is associated with this vertex.
 o degree()
Returns the degree of this vertex.
 o graph()
Returns a reference to the graph that contains this vertex, if any.
 o hash()
Returns the hash value of the Hashable data associated with this vertex.
 o hash(int)
Returns the hash value of the Hashable data associated with this vertex.
 o incidentEdges()
Returns an enumeration of the edges incident with this vertex.
 o incomingEdges()
Returns an enumeration of the incoming directed edges that are incident with this vertex.
 o inDegree()
Returns the in-degree of this vertex.
 o isEqualTo(Comparable)
Tests if two vertices are "equal" based on their Hashable data objects.
 o isIncident(Edge)
Tests if the given edge is incident with this vertex.
 o isInGraph()
Tests if this vertex is associated with a graph.
 o isInGraph(GraphBase)
Tests if this vertex is associated with the given graph.
 o isLessThan(Comparable)
Tests if one vertex is "less than" another based on the Hashable data objects.
 o numIncidentEdges()
Returns the number of edges incident with this vertex.
 o outDegree()
Returns the out-degree of this vertex.
 o printSummary()
Displays information about this vertex.
 o removeAllIncidentEdges()
Removes all incident edges from this vertex.
 o removeAllIncomingEdges()
Removes all incoming edges from this vertex.
 o removeIncidentEdge(Edge)
Finds and removes an incident edge from this vertex.
 o removeIncomingEdge(DirectedEdge)
Finds and removes an incoming directed edge from this vertex.
 o setData(Hashable)
Sets the Hashable object that is associated with this vertex.
 o setInGraph(GraphBase)
Sets the associatedGraph reference to the graph G.
 o toString()
Returns a String representation of this vertex.

Variables

 o associatedGraph
 protected GraphBase associatedGraph
A reference to the graph that this vertex is associated with; or null if this vertex is not associated with a graph.

 o data
 protected Hashable data
The Hashable object associated with this vertex.

 o incidentEdges
 protected Vector incidentEdges
A reference to the Vector used to contain the set of edges incident with this vertex. For directed edges, only outgoing edges are stored in this Vector.

 o incomingEdges
 protected Vector incomingEdges
A reference to the Vector used to contain the set of incoming directed edges incident to this vertex.

 o status
 protected int status
Status field used internally by the static Algorithms class.

 o rank
 protected int rank
Rank field used internally by the static Algorithms class.

 o distance
 protected double distance
Used by the static Algorithms class.

 o parent
 protected Vertex parent
Used by the static Algorithms class.

 o min
 protected Vertex min
Used by the static Algorithms class.

Constructors

 o Vertex
 public Vertex(Hashable data)
Constructs a vertex with the initial user-defined object to be associated with this vertex.

Parameters:
data - the user-defined object to be associated with this vertex.
 o Vertex
 public Vertex(String s)
Constructs a vertex with the initial String object to be associated with this vertex. The String object is converted to a Str object since the Str class implements the Hashable interface.

Parameters:
s - the String object to be associated with this vertex.
 o Vertex
 public Vertex(int i)
Constructs a vertex with the initial integer value to be associated with this vertex. The integer value is converted to a Int object since the Int class implements the Hashable interface.

Parameters:
i - the integer value to be associated with this vertex.
 o Vertex
 public Vertex(Vertex V)
Constructs a vertex by copying the attributes of another vertex. Note that the new vertex does not contain any incident or incoming edges and is not associated with a graph.

Parameters:
V - the vertex to be copied.
 o Vertex
 public Vertex()
Constructs a vertex with default attributes. Since each Vertex object must be associated with a Hashable object, the default constructor generates a unique Hashable key of type Int.

Methods

 o clone
 public Object clone()
Clones this vertex. Note that the new vertex does not contain any incident or incoming edges and is not associated with a graph.

Returns:
a new vertex that is a clone of this vertex.
Overrides:
clone in class Object
 o data
 public Hashable data()
Returns a reference to the Hashable object that is associated with this vertex.

Returns:
a reference to the Hashable object that is associated with this vertex.
 o degree
 public int degree()
Returns the degree of this vertex. For directed edges that are incident with this vertex, the degree is the sum of the in-degree and the out-degree.

Returns:
the degree of this vertex.
 o graph
 public GraphBase graph()
Returns a reference to the graph that contains this vertex, if any.

Returns:
a reference to the graph that contains this vertex; or null if this vertex is not associated with a graph.
 o hash
 public int hash()
Returns the hash value of the Hashable data associated with this vertex.

Returns:
the hash value of the Hashable data associated with this vertex.
 o hash
 public int hash(int tableSize)
Returns the hash value of the Hashable data associated with this vertex.

Parameters:
tableSize - the size of the table that will potentially hold this Vertex object and others.
Returns:
the hash value of the Hashable data associated with this vertex.
 o incidentEdges
 public Enumeration incidentEdges()
Returns an enumeration of the edges incident with this vertex.

Returns:
an enumeration of the edges incident with this vertex.
 o incomingEdges
 public Enumeration incomingEdges()
Returns an enumeration of the incoming directed edges that are incident with this vertex.

Returns:
an enumeration of the incoming directed edges incident with this vertex.
 o inDegree
 public int inDegree()
Returns the in-degree of this vertex.

Returns:
the in-degree of this vertex.
 o isEqualTo
 public boolean isEqualTo(Comparable C)
Tests if two vertices are "equal" based on their Hashable data objects.

Parameters:
C - the right-hand side of the comparison.
Returns:
true if this vertex is "equal" to the given vertex C based on the Hashable data objects; false otherwise.
 o isIncident
 public boolean isIncident(Edge E)
Tests if the given edge is incident with this vertex. For directed edges, only outgoing edges are considered to be incident with this vertex.

Parameters:
E - the edge to test.
Returns:
true if the given edge E is incident with this vertex; false otherwise.
 o isInGraph
 public boolean isInGraph()
Tests if this vertex is associated with a graph.

Returns:
true if this vertex is associated with a graph; false otherwise.
 o isInGraph
 public boolean isInGraph(GraphBase G)
Tests if this vertex is associated with the given graph.

Parameters:
G - the graph to test.
Returns:
true if this vertex is associated with the given graph G; false otherwise.
 o isLessThan
 public boolean isLessThan(Comparable C)
Tests if one vertex is "less than" another based on the Hashable data objects.

Parameters:
C - the right-hand side of the comparison.
Returns:
true if this vertex is "less than" the given vertex C based on the Hashable data objects; false otherwise.
 o numIncidentEdges
 public int numIncidentEdges()
Returns the number of edges incident with this vertex. For directed edges, only outgoing edges are considered incident with this vertex.

Returns:
the number of edges incident with this vertex.
 o outDegree
 public int outDegree()
Returns the out-degree of this vertex.

Returns:
the out-degree of this vertex.
 o printSummary
 public void printSummary()
Displays information about this vertex.

 o toString
 public String toString()
Returns a String representation of this vertex. The toString() method is applied to the Hashable object associated with this vertex.

Returns:
a String representation of this vertex.
Overrides:
toString in class Object
 o addIncidentEdge
 protected void addIncidentEdge(Edge E)
Adds an incident edge to this vertex.

Parameters:
E - the edge to be added to the list of incident edges for this vertex.
 o addIncomingEdge
 protected void addIncomingEdge(DirectedEdge E)
Adds an incoming directed edge to this vertex.

Parameters:
E - the directed edge to be added to the list of incoming edges for this vertex.
 o removeAllIncidentEdges
 protected void removeAllIncidentEdges()
Removes all incident edges from this vertex.

 o removeAllIncomingEdges
 protected void removeAllIncomingEdges()
Removes all incoming edges from this vertex.

 o removeIncidentEdge
 protected void removeIncidentEdge(Edge E)
Finds and removes an incident edge from this vertex.

Parameters:
E - the edge to be removed from the list of incident edges for this vertex.
 o removeIncomingEdge
 protected void removeIncomingEdge(DirectedEdge E)
Finds and removes an incoming directed edge from this vertex.

Parameters:
E - the directed edge to be removed from the list of incoming edges for this vertex.
 o setData
 public Hashable setData(Hashable data)
Sets the Hashable object that is associated with this vertex.

Parameters:
data - the new Hashable object.
Returns:
the old Hashable object associated with this vertex.
 o setInGraph
 protected void setInGraph(GraphBase G)
Sets the associatedGraph reference to the graph G.

Parameters:
G - the graph that this vertex is to be associated with.

All Packages  Class Hierarchy  This Package  Previous  Next  Index