Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network

  Advanced Search  

Program 7 20 points CS 2420 Fall 2010 Graph algorithms

Summary: Program 7 20 points CS 2420 Fall 2010
Graph algorithms
Given the graph shown below, write a C++ program that inputs the graph, stores it as an adjacency list, and
produces the desired output. Use the file prog7.txt as input. The format of the file is as follows:
The first line contains the number of nodes and the number of edges. The names of the nodes are A to N
There are edge description lines that follow ( one for each edge: "number of edges" lines):
o Each line lists the head node followed by the tail node
prog7.txt contains the input to store a representation of this graph:
(a) Topological order: The output will consist of the node names followed by their topological order number.
Note, there are multiple correct orderings.
(b) Length of the longest path (in terms of number of edges) anywhere in the graph.
(c) Print the nodes in order of a depth first traversal of the graph. You will have to begin the depth first
traversal multiple times (at nodes without predecessors) to get all nodes (as there is not one unique starting
point). Use a visited flag at each node so you don't list a node more than once.
When you have completed the assignment, zip your entire project and submit the zip file to Eagle.
You will use an adjacency list to store the graph. You will want to be able to convert between a nodeID (A-N)
and a subscript (0-13). An easy way of doing this is to compute nodeId-'A'. By subtracting the letter 'A' from
the character representation, you get the corresponding integer.


Source: Allan, Vicki H. - Department of Computer Science, Utah State University


Collections: Computer Technologies and Information Sciences