# C Language Graphs and Graph Algorithm Programming Project Paper I attached an instruction and starter codes. Please read it carefully! All requirements mus

C Language Graphs and Graph Algorithm Programming Project Paper I attached an instruction and starter codes. Please read it carefully! All requirements must be met. Thanks. Assignment 12
The purpose of this assignment is to give you practice with graphs and graph algorithms.
Consider a problem that online game designers and Internet radio providers face: How can you
efficiently transfer a piece of information to everyone who may be listening. This is important in realtime gaming so that all the players know the very latest position of every other player; this is important
for Internet radio so that all the listeners that are tuned in are getting all the data they need to
reconstruct the song they are listening to.
Figure 1 illustrates a network with a broadcast host, routers
(represented by nodes A-G), and listeners that are connected to some
routers. The weight of each connection represents the cost of sending
One approach is a brute force approach called uncontrolled
flooding. For the broadcast host to send a single copy of the
broadcast message and let the routers relay the message, the
flooding strategy works as follows: each message starts with a
time to live (ttl) value set to some number
greater than or equal to the number of edges
between the broadcast host and its most
distant listener. Each router gets a copy of the
1
message and passes the message on to all of
its neighboring routers. When the message is
2
passed on the ttl is decreased. Each router
continues to send copies of the message to all its
Figure 1. A weighted connected graph.
neighbors until the ttl value reaches 0. It is
obvious that the uncontrolled flooding approach generates many unnecessary messages.
3
Another approach is for the broadcasting host to keep a list of all of the listeners and send individual
messages to each. Using this approach on the graph shown in Figure 1, four copies of every message
would be sent using the least cost path (shortest path) to the four listeners. All messages from the
broadcaster will go through router A, so A sees all four copies of every message. Similarly, routers B
and D would see three copies of every message since routers B and D are on the shortest paths from the
broadcasting host to listeners 1, 2 and 3. This approach still generates lots of traffic in the network.
A better solution to this problem is to construct a minimal
spanning tree (MST). Figure 2 shows a simplified version of the
The highlighted edges form a minimal spanning tree for the graph.
sends a single copy of the broadcast message into the network. Each
router forwards the message to any neighbor that is part of the
spanning tree, excluding the neighbor that just sent it the message.
Figure 2. A minimal spanning tree.
In this example, A forwards the message to B. B forwards the
message to D and C. D forwards the message to E, which forwards it
to F, which forwards it to G. No router sees more than one copy of
any message, and all the listeners that are interested see a copy of
the message.
1
In this assignment, you are asked to implement a program to simulate a network. The program first
constructs a graph from an input file. The file name will be the one and only command-line argument
passed to the program. The input file stores a weighted, undirected, connected graph. The file contains
entries formatted as follows:
Each 3-tuple denotes a link between the nodes and that has a weight of .
The name of the node is an ASCII string (the label may be longer than one character) and the weight is a
non-negative integer value.
The starter code contains an executable that can be run as
%mynetwork data0
to demonstrate a sample run with the sample graph in Figures 1 and 2.
The program will read from the file whose name is passed as a command line
argument, and then construct the graph and its minimal spanning tree. Next, the
user is presented a prompt to query the graph from a starting node (which is the
first node of the first tuple of the input file). The starting node is displayed at the
prompt as:
# ping B
From: A
To: B
# ping F
From: A
To: B
To: D
To: E
To: F
# ping E
From: A
To: B
To: D
To: E
#
The user can then work with simulated network commands ping, ssh, and exit
interactively from the keyboard. When the user issues the ping command to
communicate to a target node, the program uses the MST to generate a stack of
nodes that construct the path from the start node to the target node (shown?).
The ssh command allows the user to change the current node. For example, by
calling ssh to B at current node A, the current node is changed to B. Then the ping
commands that follow will print out paths using B as the new starting node.
# ssh B
# ping E
From: B
To: D
To: E
The user may continue to move to other nodes using ssh, and they are also allowed
to ssh to the same node. The program must keep track of the users ssh
# ssh E
history, so they are able to exit from the previous ssh using the exit
# ping A
From: E
command. For example, suppose they have moved from A to B and then
To: D
from B to E. The first exit disconnects from E and returns to B. The second
To: B
To: A
exit disconnects from B and returns to A (the current runs starting node),
# exit
and the last exit terminates the program.
# exit
The program displays an error message if ping or ssh commands are
issued to a non-existing node in the graph (as illustrated below)
# ping Z
Cannot find node.
A
B
C
D
E
F
G
Available nodes are:
# ssh Z
Cannot find node.
A
B
C
D
E
F
G
# exit
%
(program ends)
Available nodes are:
You may assume that the input file and commands issued at the program prompt are all in proper valid
formats.
Requirements:


The MST must be built using Kruskals minimal spanning tree algorithm.
You need to implement your own disjoint set data structure (See Lab 10) that will be used in
Kruskals algorithm.
2
Submission:

You need to submit all the files (header and source) required to compile your program. You
must submit a makefile that will make an executable target named mynetwork. A sample
makefile is provided in the starter code.
CC = g++
DEBUG = -g
EXECUTABLE = mynetwork
SOURCES = mynetwork.cpp
all: \$(EXECUTABLE)
\$(EXECUTABLE): \$(SOURCES)

Don't use plagiarized sources. Get Your Custom Essay on
C Language Graphs and Graph Algorithm Programming Project Paper I attached an instruction and starter codes. Please read it carefully! All requirements mus
Just from \$13/Page
Calculate the Price of your PAPER Now
Pages (550 words)
Approximate price: -

Why Choose Us

Top quality papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

We have hired a team of professional writers experienced in academic and business writing. Most of them are native speakers and PhD holders able to take care of any assignment you need help with.

Free revisions

If you feel that we missed something, send the order for a free revision. You will have 10 days to send the order for revision after you receive the final paper. You can either do it on your own after signing in to your personal account or by contacting our support.

On-time delivery

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & confidential

We use several checkers to make sure that all papers you receive are plagiarism-free. Our editors carefully go through all in-text citations. We also promise full confidentiality in all our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.