Project 6: network broadcasting

Due Friday, 2019/05/03, 11:59:59PM.

You may work with one partner for this project. If you choose to work in a pair, you must tell me before you begin work on the project by sending me an email. Once you have chosen partners you may not change partners. Partners must be finalized by the first class meeting after the day this project is assigned.

Project description

You are in the planning stages of setting up the distribution network for a internet-based television system. There is an existing network of computers which are at different cities, which are the endpoints for your network. These computers have connections to each other with varying delay times.

For a network configuration, you need to also designate one computer as the primary source for the television content. This computer sends the content over the network to all other computers. This source computer must be chosen in such a way that it minimizes the total transmission time to all the other computers in the network.

We represent the network as a set of computers connected by network links. Each computer is named after the city it is in.

Each network link connects two computers, in a particular direction, and has an associated delay time. Note that just because there is a network link from computer A to computer B doesn't mean that there is one from B to A. Even if there is, they may have different delays.


The input is a description of the existing network. The first line contains an integer N, where 1 ≤ N ≤ 1,000 is the number of network connections. The following N lines each describe one directed connection. Each line contains the names of two different connected computers and a connection delay, separated by single spaces. Each name is between 1 and 40 lowercase English letters or underscores, and each delay is an integer in the range 0 to 10,000, representing milliseconds. No direct link from one computer to another computer appears more than once.

Not all computers may be the server. Only a computer that ends with the string "_server" could serve as a server. (Be careful how you check for this suffix; it can be a source of difficulty.)


If there is no server that can serve the entire network, print no server can serve the whole network. Otherwise, print out total delay: x, where x is the shortest total delay time possible. On the following lines, print all the servers that can serve the entire network with this delay time, sorted in alphabetic order.

Sample input and output

Provided code

You must use the .h files provided here.

You will use the ArrayHeap code you wrote for project 5, with a modification that allows you to change the value on the heap. This is necessary to implement Dijkstra's algorithm.

Remember that when using templates, all of the code you write goes in the (student's) .h file. You will submit these files: arrayheap-student-proj6.h, graph-proj6.cpp, and driver-proj6.cpp.

In your driver, you may find the STL map useful for converting the strings given on the input to integers which are used in the Graph class as vertex indexes. We will talk about this in class.

Please feel free to use the following STL cheatsheets to learn more about some of the STL types used in this project: cheatsheet 1, cheatsheet 2. Here is a good reference for the STL.

Structuring the project

Since this is a large project, it helps to have a plan of attack. The following milestones should be turned in via the upload site by noon on the due date.

Step Finish by Milestone
1. Thursday, April 25 by noon WRITE and TEST the required changes to the ArrayHeap class. Do not underestimate the difficulty of these modifications!
2. Tuesday, April 30 by noon WRITE and TEST the dijkstra method in the Graph class.
3. Thursday, May 2 by noon WRITE and TEST the driver and finish the project.

Writing a test driver for a data structure means writing a small, self-contained program that tests the different methods of the data structure and verifies that they are correct. For each milestone you should develop and turn in a driver that illustrates testing your code.

Sample executables

Here are sample executables for you. When you design test cases, you can judge your output against the output from my correct solution. Here are my compiled solutions:

As in previous projects, if you give a command-line argument to these executables, they will print extra information about how they are running.

Final notes

Remember when writing this program to adhere to the coding style guidelines. For this project you must work only by yourself or with your approved partner. No credit will be given for a solution which does not pass all the hidden tests I create, or does not pass in the allowed time. For more detailed instructions, read the project submission guidelines.

Copyright © Greg Hamerly.
Computer Science Department
Baylor University

valid html and css