Project Lab 2
Assignment : C by example: Modify a code.
- Make a directory for the project. Example
mkdir NetworkProject
- Download these 3 files randomGraph.c
, Makefile , ran34.c
- randomGraph.c generates random graphs from the model G(n,m)
and outputs a file with the adjacency list .
- Compile the file using the Makefile. Do
make randomGraph
-
./randomGraph -h will give you the codes
options/parameters.
- Example
./randomGraph -n 10 -m 20 -s 1
gives a random graph from G(n,m). That is 10 nodes 20
edges, s is the "seed".
- Do
ls to see the new file. Do
less ErdosRenyi10-20-1.gr to see the ouput of
the program.
- Write a function that outputs the adjacency matrix
instead of the adjacency list.
- Write a function that generates the G(n,p) model (both
adjacency list and adjacency matrix).
- To print a "randomGraph.c" file do
a2ps -R --column 1 randomGraph.c
Yannet Interian
Networks and Algorithms