Design and Analysis of Algorithms
CSE 5311 Section 087/088/098 Fall 2002
Due: November 26, 2002 (midnight)
For this assignment you will write a program that determines the
shortest routes for messages between two nodes in a dynamic network of
nodes and connections. Your program will also support pruning the
network to a minimum spanning tree to help minimize connections. The
specifics of the program follow. All code must be written by you
individually and may not be copied in whole or in part from other
- Your program will implement a graph data structure to represent
the dynamic network, where vertices are nodes, and edges are
connections between nodes. The data structure should support the
addition and deletion of nodes and connections. Connections are
bidirectional. Each connection (u,v) has a weight
w(u,v) representing the delay in milliseconds of the
connection. There is at most one connection between two nodes.
- Your program will implement an algorithm to compute the shortest
path and distance between two nodes. Be sure to describe in the
comment to this algorithm what technique you are using for the
- Your program will implement an algorithm for finding the minimum
spanning tree of the network, identifying connections to delete to
result in a minimum spanning tree.
- The main part of your program will read in and process commands
from a file whose name is given as a command-line argument. Each line
of the input file contains one of the following commands. All command
arguments are positive integers.
||Add node numbered n to network. Output whether node added
or already existed in the network.
||Delete node n from the network along with all its
connections. Output whether node does not exist in network or the
node and connections deleted.
|connect n1 n2 w
||Add a connection between nodes n1 and n2 with weight
w. Output whether new connection added, weight changed, or
|disconnect n1 n2
||Delete connection between nodes n1 and n2. Output
whether connection deleted or does not exist in network.
|message n1 n2
||Find the shortest route from node n1 to node n2.
Output whether the route exists and, if so, the sequence of nodes and
total delay of the route.
||Print all the connections in the network in the form n1 --w--
n2, one per line, where n1 < n2. If a node has
no connections, then output just the node n1. The output
should be in increasing order by first node number, and then by second
||Find and delete the connections necessary to yield a minimum
spanning tree. If the network is not a connected graph, then just
output "Network not connected." Otherwise, either output that it is
already a minimum spanning tree or output the connections deleted.
- See pgm3.in and pgm3.out for sample input and output.
Your output should follow the sample as closely as possible.
- After ensuring that your program compiles and runs correctly on
the omega.uta.edu system, submit your source code to me (firstname.lastname@example.org) by the above
deadline. Please only send one email message; use attachments if
sending multiple files. In addition to correct functionality and
satisfaction of the above constraints, your submission will be graded
based on good programming style and documentation.