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
-
associatedGraph
- A reference to the graph that this vertex is associated with;
or null if this vertex is not associated with a graph.
-
data
- The Hashable object associated with this vertex.
-
distance
- Used by the static Algorithms class.
-
incidentEdges
- A reference to the Vector used to contain the set of edges
incident with this vertex.
-
incomingEdges
- A reference to the Vector used to contain the set of incoming
directed edges incident to this vertex.
-
min
- Used by the static Algorithms class.
-
parent
- Used by the static Algorithms class.
-
rank
- Rank field used internally by the static Algorithms class.
-
status
- Status field used internally by the static Algorithms class.
-
Vertex()
- Constructs a vertex with default attributes.
-
Vertex(Hashable)
- Constructs a vertex with the initial user-defined object to be
associated with this vertex.
-
Vertex(int)
- Constructs a vertex with the initial integer value to be
associated with this vertex.
-
Vertex(String)
- Constructs a vertex with the initial String object to be
associated with this vertex.
-
Vertex(Vertex)
- Constructs a vertex by copying the attributes of another vertex.
-
addIncidentEdge(Edge)
- Adds an incident edge to this vertex.
-
addIncomingEdge(DirectedEdge)
- Adds an incoming directed edge to this vertex.
-
clone()
- Clones this vertex.
-
data()
- Returns a reference to the Hashable object that is
associated with this vertex.
-
degree()
- Returns the degree of this vertex.
-
graph()
- Returns a reference to the graph that contains this vertex, if any.
-
hash()
- Returns the hash value of the Hashable data associated with
this vertex.
-
hash(int)
- Returns the hash value of the Hashable data associated with
this vertex.
-
incidentEdges()
- Returns an enumeration of the edges incident with this vertex.
-
incomingEdges()
- Returns an enumeration of the incoming directed edges that
are incident with this vertex.
-
inDegree()
- Returns the in-degree of this vertex.
-
isEqualTo(Comparable)
- Tests if two vertices are "equal" based on their Hashable data
objects.
-
isIncident(Edge)
- Tests if the given edge is incident with this vertex.
-
isInGraph()
- Tests if this vertex is associated with a graph.
-
isInGraph(GraphBase)
- Tests if this vertex is associated with the given graph.
-
isLessThan(Comparable)
- Tests if one vertex is "less than" another based on the Hashable
data objects.
-
numIncidentEdges()
- Returns the number of edges incident with this vertex.
-
outDegree()
- Returns the out-degree of this vertex.
-
printSummary()
- Displays information about this vertex.
-
removeAllIncidentEdges()
- Removes all incident edges from this vertex.
-
removeAllIncomingEdges()
- Removes all incoming edges from this vertex.
-
removeIncidentEdge(Edge)
- Finds and removes an incident edge from this vertex.
-
removeIncomingEdge(DirectedEdge)
- Finds and removes an incoming directed edge from this vertex.
-
setData(Hashable)
- Sets the Hashable object that is associated with this vertex.
-
setInGraph(GraphBase)
- Sets the associatedGraph reference to the graph G.
-
toString()
- Returns a String representation of this vertex.
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.
data
protected Hashable data
- The Hashable object associated with this vertex.
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.
incomingEdges
protected Vector incomingEdges
- A reference to the Vector used to contain the set of incoming
directed edges incident to this vertex.
status
protected int status
- Status field used internally by the static Algorithms class.
rank
protected int rank
- Rank field used internally by the static Algorithms class.
distance
protected double distance
- Used by the static Algorithms class.
parent
protected Vertex parent
- Used by the static Algorithms class.
min
protected Vertex min
- Used by the static Algorithms class.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
incidentEdges
public Enumeration incidentEdges()
- Returns an enumeration of the edges incident with this vertex.
- Returns:
- an enumeration of the edges incident with this vertex.
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.
inDegree
public int inDegree()
- Returns the in-degree of this vertex.
- Returns:
- the in-degree of this vertex.
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.
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.
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.
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.
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.
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.
outDegree
public int outDegree()
- Returns the out-degree of this vertex.
- Returns:
- the out-degree of this vertex.
printSummary
public void printSummary()
- Displays information about this vertex.
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
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.
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.
removeAllIncidentEdges
protected void removeAllIncidentEdges()
- Removes all incident edges from this vertex.
removeAllIncomingEdges
protected void removeAllIncomingEdges()
- Removes all incoming edges from this vertex.
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.
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.
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.
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