A program to write the graph information to the screen

Assignment Help Computer Engineering
Reference no: EM132107387

Your program should take one of the following four commands from the standard input, and execute corresponding functions.

•S

•R

•W

•Pst

On reading S, the program stops.

On reading R, the program reads in an edge weighted directed graph from file GRAPHinput.txt to build the adjacency lists, and waits for the next command.

The file GRAPHinput.txt is a text file. The first line of the file contains two integers n and m, which indicates the number of vertices and the number of edges on the graph, respectively.

It is followed by m lines, where each line contains three integers: u,v, and w. These three integers indicate the information of an edge: there is an edge pointing from u to v, with weight w. Please note that the vertices of the graph are indexed from 1 to n (not from 0 to n - 1).

On reading W, the program writes the graph information to the screen, and waits for the next command.

The screen output format of W is as follows: The first line should contain two integers, n and m, where n is the number of vertices and m is the number of edges. It should be followed by n lines, where each of these n lines has the following format:

u : (v1 w1) (v2 w2) ... (vx, wx) 1

On reading P s t, the program runs Dijkstra's shortest path algorithm to compute a shortest s-t path, and prints out the shortest path information from s to t to the screen, and waits for the next command.

The screen output format of P s t is as follows: There are two lines. The first line contains an integer dist, which is the length of the shortest path computed. The next line contains the indexes of all vertices along the path direction, starting from src and ending with dest, in format of:

sv1 v2 ...t

Please note that your program should read in only one graph, but may be asked to compute s-t shortest paths for different pairs of s and t. Therefore, during the computation of the s-t shortest path, your program should not modify the given graph.

You should use modular design. At the minimum, you should have

• the main program as main.cpp and the corresponding main.h;
• the heap functions heap.cpp and the corresponding heap.h;
• the graph functions graph.cpp and the corresponding graph.h;
• various utility functions util.cpp and the corresponding util.h.

You should also provide a Makefile which compile the files into an executable file named run. Grading policies: (Sample test cases will be posted soon.)

Reference no: EM132107387

Questions Cloud

Normal probability distribution : Fill in the blanks: The number of hours it takes for a certain metal part to wear out is assumed to be from a population with a normal probability distribution
Create a java program that manipulates an array : In the main method, have the user input the size of an array. Create an integer array of that size. Then call the methods outlined in the following steps.
Number of dots on the uppermost faces : A pair of dice is tossed and the number of dots on the uppermost faces are observed. Let X denote the random variable defined as the larger of the two numbers.
Create a person gui where the application read person file : Create a Person GUI where the application read your Person file when launching the interface.
A program to write the graph information to the screen : The first line of the file contains two integers n and m, which indicates the number of vertices and the number of edges on the graph, respectively.
What does this tell you about the shape of this distribution : The mean of this data was found to be 42, while the median was 37. What does this tell you about the shape of this distribution
Develop and implement an interactive two-player yahtzee game : Develop and implement an interactive two-player Yahtzee game. Yahtzee is a dice game that was invented by Milton Bradley and Edwin S. Lowe in 1956.
What is the monthly reach of people 13 of facebook : The U.S. population of people 13 + is 252,904,000. Expressed as a percentage, what is the monthly reach of people 13 + of Facebook?
What is combined reach : You are advertising on two television programs that achieve the reach percentages listed. What is their combined reach?

Reviews

Write a Review

Computer Engineering Questions & Answers

  What types of relationships that exist between tables

What are the differences between relational database models and object-oriented database models? express at least 2 differences at length.

  Design the logic for a program that merges the files

Design the logic for a program that merges the files for summer and winter programs to create a list of the first and last names of all participants.

  How many such strings have exactly five as

How many such strings have exactly five a's? How many such strings have three of each letter?

  Sections of currency conversion development documentation

The Currency Conversion application is a menu-driven program that allows users to select one of five international currency types, input the amount of a foreign currency, and then convert the foreign currency to dollars. The program displays the e..

  How can you generate a list of such files

The tar command on one system can't accept absolute pathnames longer than 100 characters. How can you generate a list of such files?

  Which features of the system are likely to change

Which features of the system are likely to change in different contexts? State clearly and precisely the requirements that should be satisfied by the system.

  Write down a c++ program for little man''s computer

A text file containing machine code (not assembly code) for little man's computer following instruction set . Instructions are in different lines (no need for semicolon at the end of each instruction)

  Design an fir filter

An alternative method for designing an FIR filter that approximates the desired channel characteristics is based on the window method.

  Write a help module for an inventory control system

In this assignment, you will develop appropriate messages to the user and write a Help module for an Inventory Control system.

  How that could actually detract from your presentation

PowerPoint is a relatively easy application to use, yet it carries the highest visual impact in the MS Office suit.

  What criteria should consider in making appropriate choice

What criteria should you consider in making the appropriate choice? Design three alternative E-R diagrams to represent the university registrar's office.

  Transfering the power over ethernet

A recent article in an industry magazine discussed the ability to transfer the Power over Ethernet (PoE) and an emerging technology which is able to transfer the Power over Fiber (PoF).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd