All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class rpi.goldsd.graph.Graph

java.lang.Object
   |
   +----rpi.goldsd.graph.GraphBase
           |
           +----rpi.goldsd.graph.Graph

public class Graph
extends GraphBase
The Graph class is used to represent a single directed or undirected graph consisting of zero or more vertices and edges.

Version:
2.1, 5/12/98
Author:
David Goldschmidt
See Also:
Vertex, Edge, GraphBase

Constructor Index

 o Graph()
Constructs an unnamed empty graph.
 o Graph(GraphBase)
Constructs a graph by copying another graph.
 o Graph(int, double)
Constructs a random unnamed graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices.
 o Graph(int, double, double, double)
Constructs a random unnamed graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices.
 o Graph(int, double, Sequence, Sequence)
Constructs a random unnamed graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices.
 o Graph(int, int)
Constructs an empty graph with the specified initial vertex hashtable size and initial edge hashtable size.
 o Graph(String)
Constructs an empty graph with the specified name.
 o Graph(String, int, double)
Constructs a random graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices.
 o Graph(String, int, double, boolean, double, double, Sequence, Sequence)
Constructs a random graph with the specified name, the number of vertices to create, and the probability of an undirected edge existing between each distinct pair of vertices.
 o Graph(String, int, double, double, double)
Constructs a random graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices.
 o Graph(String, int, double, Sequence, Sequence)
Constructs a random graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices.
 o Graph(String, int, int)
Constructs an empty graph with the specified name, initial vertex hashtable size, and initial edge hashtable size.

Method Index

 o add(Edge)
Adds the given edge to this graph if it is not already in this graph.
 o add(Vertex)
Adds the given vertex to this graph if it is not already in this graph.
 o clone()
Clones this graph.
 o isClique()
Tests if this graph is a clique (a complete graph).
 o isComplete()
Tests if this graph is a complete graph.
 o isConnected()
Tests if this graph is a connected graph.
 o remove(Edge)
Removes the given edge from this graph.
 o remove(Vertex)
Removes the given vertex from this graph.
 o removeAllEdges()
Removes all edges from this graph.

Constructors

 o Graph
 public Graph(String name,
              int vertexTableSize,
              int edgeTableSize)
Constructs an empty graph with the specified name, initial vertex hashtable size, and initial edge hashtable size.

Parameters:
name - the user-defined name of this graph.
vertexTableSize - the initial hashtable size for the hashtable used to contain the set of vertices.
edgeTableSize - the initial hashtable size for the hashtable used to contain the set of edges.
 o Graph
 public Graph(int vertexTableSize,
              int edgeTableSize)
Constructs an empty graph with the specified initial vertex hashtable size and initial edge hashtable size.

Parameters:
vertexTableSize - the initial hashtable size for the hashtable used to contain the set of vertices.
edgeTableSize - the initial hashtable size for the hashtable used to contain the set of edges.
 o Graph
 public Graph(String name)
Constructs an empty graph with the specified name.

Parameters:
name - the user-defined name of this graph.
 o Graph
 public Graph(GraphBase G)
Constructs a graph by copying another graph.

Parameters:
G - the graph to copy.
 o Graph
 public Graph()
Constructs an unnamed empty graph.

 o Graph
 public Graph(String name,
              int numVertices,
              double probabilityOfEdge,
              boolean weighted,
              double minWeight,
              double maxWeight,
              Sequence vertexSequence,
              Sequence edgeSequence)
Constructs a random graph with the specified name, the number of vertices to create, and the probability of an undirected edge existing between each distinct pair of vertices. When the weighted flag is true, each edge is assigned a random weight in the range specified by the minWeight and maxWeight arguments. Two Sequence arguments provide an enumeration of unique key values for both the vertices and the edges of this graph.

Note that all other random-graph constructor methods call this method.

Parameters:
name - the name of the constructed graph.
numVertices - the number of vertices to add to this graph.
probabilityOfEdge - the probability of an edge existing between a given pair of distinct vertices.
weighted - a boolean flag specifying whether the edges of the generated graph are to be weighted.
minWeight - the minimum weight assigned to an edge.
maxWeight - the maximum weight assigned to an edge.
vertexSequence - used to generate unique Hashable objects to be associated with each generated vertex.
edgeSequence - used to generate unique Hashable objects to be associated with each generated edge.
 o Graph
 public Graph(String name,
              int numVertices,
              double probabilityOfEdge,
              Sequence vertexSequence,
              Sequence edgeSequence)
Constructs a random graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices. Two Sequence arguments provide an enumeration of unique key values for both the vertices and the edges of this graph.

Parameters:
name - the name of the constructed graph.
numVertices - the number of vertices to add to this graph.
probabilityOfEdge - the probability of an edge existing between a given pair of distinct vertices.
vertexSequence - used to generate unique Hashable objects to be associated with each generated vertex.
edgeSequence - used to generate unique Hashable objects to be associated with each generated edge.
 o Graph
 public Graph(int numVertices,
              double probabilityOfEdge,
              Sequence vertexSequence,
              Sequence edgeSequence)
Constructs a random unnamed graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices. Two Sequence arguments provide an enumeration of unique key values for both the vertices and the edges of this graph.

Parameters:
numVertices - the number of vertices to add to this graph.
probabilityOfEdge - the probability of an edge existing between a given pair of distinct vertices.
vertexSequence - used to generate unique Hashable objects to be associated with each generated vertex.
edgeSequence - used to generate unique Hashable objects to be associated with each generated edge.
 o Graph
 public Graph(String name,
              int numVertices,
              double probabilityOfEdge,
              double minWeight,
              double maxWeight)
Constructs a random graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices. Each edge is assigned a random weight in the range specified by the minWeight and maxWeight arguments.

Parameters:
name - the name of the constructed graph.
numVertices - the number of vertices to add to this graph.
probabilityOfEdge - the probability of an edge existing between a given pair of distinct vertices.
minWeight - the minimum weight assigned to an edge.
maxWeight - the maximum weight assigned to an edge.
 o Graph
 public Graph(int numVertices,
              double probabilityOfEdge,
              double minWeight,
              double maxWeight)
Constructs a random unnamed graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices. Each edge is assigned a random weight in the range specified by the minWeight and maxWeight arguments.

Parameters:
numVertices - the number of vertices to add to this graph.
probabilityOfEdge - the probability of an edge existing between a given pair of distinct vertices.
minWeight - the minimum weight assigned to an edge.
maxWeight - the maximum weight assigned to an edge.
 o Graph
 public Graph(String name,
              int numVertices,
              double probabilityOfEdge)
Constructs a random graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices.

Parameters:
name - the name of the constructed graph.
numVertices - the number of vertices to add to this graph.
probabilityOfEdge - the probability of an edge existing between a given pair of distinct vertices.
 o Graph
 public Graph(int numVertices,
              double probabilityOfEdge)
Constructs a random unnamed graph with the specified number of vertices and the probability of an edge existing between each distinct pair of vertices.

Parameters:
numVertices - the number of vertices to add to this graph.
probabilityOfEdge - the probability of an edge existing between a given pair of distinct vertices.

Methods

 o clone
 public Object clone()
Clones this graph.

Returns:
a new graph that is a clone of this graph.
Overrides:
clone in class GraphBase
 o isClique
 public boolean isClique()
Tests if this graph is a clique (a complete graph).

Returns:
true if this graph is a clique; false otherwise.
 o isComplete
 public boolean isComplete()
Tests if this graph is a complete graph.

Returns:
true if this graph is complete; false otherwise.
 o isConnected
 public boolean isConnected()
Tests if this graph is a connected graph.

Returns:
true if this graph is connected; false otherwise.
 o add
 public synchronized void add(Edge E) throws DuplicateElementException, InAnotherGraphException, VertexNotFoundException
Adds the given edge to this graph if it is not already in this graph. The two endpoint vertices associated with the given edge must already be in this graph.

Parameters:
E - the edge to be added to this graph.
Throws: DuplicateElementException
if the key is already present in the set of vertices.
Throws: InAnotherGraphException
if the edge is already in a different graph.
Throws: VertexNotFoundException
if either of the endpoint vertices of the edge are not in this graph.
 o add
 public synchronized void add(Vertex V) throws DuplicateElementException, InAnotherGraphException
Adds the given vertex to this graph if it is not already in this graph.

Parameters:
V - the vertex to be added to this graph.
Throws: DuplicateElementException
if the key is already present in the set of vertices.
Throws: InAnotherGraphException
if the vertex is already in a different graph.
 o remove
 public synchronized void remove(Edge E) throws EdgeNotFoundException, VertexNotFoundException
Removes the given edge from this graph.

Parameters:
E - the edge to remove.
Throws: EdgeNotFoundException
if the edge is not in this graph.
Throws: VertexNotFoundException
if either of the endpoint vertices of the edge are not in this graph.
 o remove
 public synchronized void remove(Vertex V) throws VertexNotFoundException
Removes the given vertex from this graph.

NOT YET IMPLEMENTED.

Parameters:
V - the vertex to remove.
 o removeAllEdges
 public synchronized void removeAllEdges()
Removes all edges from this graph.


All Packages  Class Hierarchy  This Package  Previous  Next  Index