CSCI 280 - Algorithms and Problem Solving Paradigms
Spring 2010
Project 2: Random Graphs
Overview
Many computer scientists and mathematicians study random graphs.
The most commonly studied type of random graph is the following:
Given an integer n and a probability p, we generate
a graph by creating n vertices and connecting each pair of vertices
(u, v) with probability p. For example, given
three vertices a, b, and c, and = 0.5,
we'd flip a coin to decide whether to connect a and b,
a second flip to decide whether to connect b and c, and
a third flip to decide whether to connect a and c.
One of eight possible graphs would result, each with equal probability.
A component of a graph is a subset of the vertices that are all
connected to one another. The diameter of a graph is the maximum
distance between two vertices in any of the graph's components.
For a given graph size n, we can calculate the average number
of components and the average diameter by generating every possible graph,
determining the values for each graph, and averaging. For large values of
n, this is unrealistic; hence, we can generate a number of random
graphs as a means of approximating these averages.
Assignment
Write a program to create random undirected graphs. The program should take
as arguments values for n and p, as well as the number of
random graphs to generate. The program will report the average number of
components and the average diameter.
Run the program for n = 9, n = 36, and n = 144.
For each value of n, run the program to generate 100
random graphs. For each of these combinations, run the program with
p = 0.1, p = 0.2, p = 0.3, and so forth up to
p = 0.9.
From this data, you will produce two Cartesian graphs, using spreadsheet
software or something similar. Each graph will have the value for p
as the x-axis. The first graph will have the average number of
components as the y-axis; the other graph will have the average
diameter as the y-axis. Each graph should contain one curve for each value of
n.
Make two more runs of the above configurations, one with 50 random graphs, the
other with 500 random graphs. Create two Cartesian graphs for each of these
configurations as well.
Text Document
Write a brief report discussing your results.