com.mhhe.clrs2e
Class Vertex

java.lang.Object
  |
  +--com.mhhe.clrs2e.Vertex

public class Vertex
extends java.lang.Object

A class for vertices in graphs. Every vertex has a name and an index in its graph.

See Also:
Graph, AdjacencyListGraph, AdjacencyMatrixGraph, WeightedAdjacencyListGraph, WeightedAdjacencyMatrixGraph, FlowNetwork

Field Summary
private  int index
          Index of this vertex in its graph, 0 to cardV-1.
private  java.lang.String name
          This vertex's name.
static int UNKNOWN_INDEX
          Value that indicates that this vertex does not yet have an index, i.e., the index is unknown.
 
Constructor Summary
Vertex(int index, java.lang.String name)
          Creates a vertex with a given index and name.
Vertex(java.lang.String name)
          Creates a vertex whose index is unknown.
 
Method Summary
 int getIndex()
          Returns this vertex's index.
 java.lang.String getName()
          Returns this vertex's name.
 void setIndex(int index)
          Sets this vertex's index.
 void setName(java.lang.String name)
          Sets this vertex's name.
 java.lang.String toString()
          Returns the String representation of this vertex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN_INDEX

public static final int UNKNOWN_INDEX
Value that indicates that this vertex does not yet have an index, i.e., the index is unknown.

See Also:
Constant Field Values

index

private int index
Index of this vertex in its graph, 0 to cardV-1.


name

private java.lang.String name
This vertex's name.

Constructor Detail

Vertex

public Vertex(java.lang.String name)
Creates a vertex whose index is unknown.

Parameters:
name - This vertex's name.

Vertex

public Vertex(int index,
              java.lang.String name)
Creates a vertex with a given index and name.

Parameters:
index - This vertex's index.
name - This vertex's name.
Method Detail

setIndex

public void setIndex(int index)
Sets this vertex's index.

Parameters:
index - New value for this vertex's index.

getIndex

public int getIndex()
Returns this vertex's index.


setName

public void setName(java.lang.String name)
Sets this vertex's name.

Parameters:
name - New value for this vertex's name.

getName

public java.lang.String getName()
Returns this vertex's name.


toString

public java.lang.String toString()
Returns the String representation of this vertex.

Overrides:
toString in class java.lang.Object