Print the adjacency list for the full graph Print the edge list and adjacency list for the MST

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

The problem to solve is using a priority queue to compute a minimum spanning
tree.
Given a fully connected undirected graph where each edge has a weight, find the
set of edges with the least total sum of weights.
You are a civil engineer and you have been tasked with trying to find out the
lowest cost way to build internet access in CIS-Land. There are X (3 ≤ X ≤ 100,000)
towns in CIS-Land connected by Y (X ≤ Y ≤ 100,000) roads and you can travel
between any two towns in CIS-Land by travelling some sequence of roads. With a
limited budget you also know that the cheapest approach to obtain internet
access is to install fiber-optic cables along existing roadways. Fortunately, you
know the costs of laying fiber-optic cable down along all the roads, and you will
be able to cost out how much money CIS-Land will need to spend to successfully
complete the internet access project – that is, every town will be connected along
some sequence of fiber-optic cables. Good thing, you are also CIS-Land’s brightest
computer science professional, and you remember learning about an algorithm,
Prim’s specifically, in one of your UM-D programming classes. This algorithm
turns out to be exactly what you need to solve this problem, but to implement
the algorithm you will need to use a priority queue.You would ask, why would I use a priority queue in Prim’s algorithm? The reason
why people use it is because it significantly speeds up the runtime of the
algorithm. It turns from O(V2 + E) to O(E*log(V)).
Basically, at each step in Prim’s algorithm, you're looking for the minimum edge
with one vertex in the partial minimum spanning tree, and one vertex not in the
tree, and you're going to add that edge to the tree. How do you do that
efficiently? If you have a way to efficiently order all the edges connected to a vertex in your partial spanning tree, you can simply iterate through them until you
find an edge with an acceptable vertex.
Without such an ordered data structure, you'd have to iterate through all
candidate edges each time to find the minimum, rather than being able to
efficiently grab the minimum directly.
The input data describing the graph will be the nodes and associated list of edges
(roads and their fiber-optic cost). The program will need to covert that input into
to an adjacency list: for every node in the graph (town in CIS-Land), there will be
list of the nodes (towns) it’s connected to and the weight (cost of building fiber-
optic cable along).
adj[0] → (1, 1) (3, 3)
adj[1] → (0, 1) (2, 6) (3, 5) (4, 1)
. . .
First, the adjacency list could be represented as a list of vectors, one for each
node. For the priority queue, you may use any built-in library routines to implement the
Priority Queue or Adaptable Priority Queue.
Input Format
Input and output file names are to be entered by the user.
Line 1: Two space-separated integers: X , the number of nodes in the graph, and Y
, the number of edges.
Lines 2 . . . Y+1 :
Line i contains three space-separated numbers describing an edge:
si and ti , the IDs of the two nodes involved, and wi , the weight of the edge. Sample input (input file name format is CIS-Land#.dat where this is file CIS-Land1.dat)
6 9
0 1 1
1 3 5
3 0 3
3 4 1
1 4 1
1 2 6
5 2 2
2 4 4
5 4 4

Line 1: 6 nodes (0 – 5) and 9 edges to follow line 2 - 10
Line 2: 0 1 1 describes edge between 0 and 1 of weight 1
Line 3: 1 3 5 describes edge between 1 and 3 of weight 5
...
The MST sum is 1+1+1+4+2 = 9
Output to Screen and File (output file name format: MST#.out)
Echo print the input (format appropriately per display messages in program)
Print the adjacency list for the full graph
Print the edge list and adjacency list for the MST 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

The problem to solve is using a priority queue to compute a minimum spanning
tree.
Given a fully connected undirected graph where each edge has a weight, find the
set of edges with the least total sum of weights.
You are a civil engineer and you have been tasked with trying to find out the
lowest cost way to build internet access in CIS-Land. There are X (3 ≤ X ≤ 100,000)
towns in CIS-Land connected by Y (X ≤ Y ≤ 100,000) roads and you can travel
between any two towns in CIS-Land by travelling some sequence of roads. With a
limited budget you also know that the cheapest approach to obtain internet
access is to install fiber-optic cables along existing roadways. Fortunately, you
know the costs of laying fiber-optic cable down along all the roads, and you will
be able to cost out how much money CIS-Land will need to spend to successfully
complete the internet access project – that is, every town will be connected along
some sequence of fiber-optic cables. Good thing, you are also CIS-Land’s brightest
computer science professional, and you remember learning about an algorithm,
Prim’s specifically, in one of your UM-D programming classes. This algorithm
turns out to be exactly what you need to solve this problem, but to implement
the algorithm you will need to use a priority queue.You would ask, why would I use a priority queue in Prim’s algorithm? The reason
why people use it is because it significantly speeds up the runtime of the
algorithm. It turns from O(V2 + E) to O(E*log(V)).
Basically, at each step in Prim’s algorithm, you're looking for the minimum edge
with one vertex in the partial minimum spanning tree, and one vertex not in the
tree, and you're going to add that edge to the tree. How do you do that
efficiently? If you have a way to efficiently order all the edges connected to a vertex in your partial spanning tree, you can simply iterate through them until you
find an edge with an acceptable vertex.
Without such an ordered data structure, you'd have to iterate through all
candidate edges each time to find the minimum, rather than being able to
efficiently grab the minimum directly.
The input data describing the graph will be the nodes and associated list of edges
(roads and their fiber-optic cost). The program will need to covert that input into
to an adjacency list: for every node in the graph (town in CIS-Land), there will be
list of the nodes (towns) it’s connected to and the weight (cost of building fiber-
optic cable along).
adj[0] → (1, 1) (3, 3)
adj[1] → (0, 1) (2, 6) (3, 5) (4, 1)
. . .
First, the adjacency list could be represented as a list of vectors, one for each
node. For the priority queue, you may use any built-in library routines to implement the
Priority Queue or Adaptable Priority Queue.
Input Format
Input and output file names are to be entered by the user.
Line 1: Two space-separated integers: X , the number of nodes in the graph, and Y
, the number of edges.
Lines 2 . . . Y+1 :
Line i contains three space-separated numbers describing an edge:
si and ti , the IDs of the two nodes involved, and wi , the weight of the edge. Sample input (input file name format is CIS-Land#.dat where this is file CIS-Land1.dat)
6 9
0 1 1
1 3 5
3 0 3
3 4 1
1 4 1
1 2 6
5 2 2
2 4 4
5 4 4

Line 1: 6 nodes (0 – 5) and 9 edges to follow line 2 - 10
Line 2: 0 1 1 describes edge between 0 and 1 of weight 1
Line 3: 1 3 5 describes edge between 1 and 3 of weight 5
...
The MST sum is 1+1+1+4+2 = 9
Output to Screen and File (output file name format: MST#.out)
Echo print the input (format appropriately per display messages in program)
Print the adjacency list for the full graph
Print the edge list and adjacency list for the MST 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Single source shortest path
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY