Data Structures Project 4
Due: Wednesday, May 3, 2000.
In this project, you will construct your own reusable
implementation of the UndirectedGraph
ADT.
You are to also create a class, GraphAlgorithm, that performs the
following (static) actions:
-
isConnected(G): return true if and only if the UndirectedGraph G is connected.
-
printAdjacencies(G): prints the adjacencies for each vertex of
the UndirectedGraph G, with all the adjacencies for each vertex
printed on a single line.
(Note that this requires that each vertex has a way of printing itself
or its element.)
So, for example, the adjacencies for a triangle of three vertices
could be printed as follows:
0: 1, 2
1: 2, 0
2: 1, 0
You will test your GraphAlgorithm class with a main() method that
performs the following actions:
-
Create the UndirectedGraph G illustrated below (can be hard-coded into the
main() method):
-
Call GraphAlgorithm.printAdjacencies(G) on this graph.
-
Perform the following action five (5) different times in a loop:
-
Create an UndirectedGraph, G,
with 300 vertices and randomly add 500 edges to this
graph (where each possible edge is equally likely).
-
Print the value of GraphAlgorithm.isConnected(G) called on this graph
(i.e., print "true" or "false").
-
Perform the following action five (5) different times in a loop:
-
Create an UndirectedGraph, G,
with 300 vertices and randomly add 1800 edges to this
graph (where each possible edge is equally likely).
-
Print the value of GraphAlgorithm.isConnected(G) called on this graph.