Undirected graph has scanning tree

Assignment Help C/C++ Programming
Reference no: EM13168313

undirected graph has scanning trees. The minimal scanning tree is the scanning tree with the minimal sum of weights on edges. The minimal scanning tree can be found by using Prim's algorithm .

Write a program using C++ to find the minimal scanning tree of a graph. The graph is represented by an adjacency matrix. The adjacency matrix of a graph G = <V, E>

For example, the adjacency matrix of the following graph is on its right side:

The following is Prim's algorithm:

The input of your program should be in the following format:

<the number of vertices of the graph> <the index of the starting vertex>

<the adjacency matrix, arranged line by line>

For example, the input corresponding to the above graph is:

5 1

0 1 3 -1 -1

1 0 3 6 -1

3 3 0 4 2

-1 6 4 0 5

-1 -1 2 5 0

Note that infinity is represented by -1.

The output of your program should be the adjacency matrix of the minimal spanning tree.

For example, the output for the above input is:

0 1 3 -1 -1

1 0 -1 -1 -1

3 -1 0 4 2

-1 -1 4 0 -1

-1 -1 2 -1 0

 

 

Reference no: EM13168313

Questions Cloud

Calculate the mass of lead nitrate that had to be added : Sodium nitrate was added to 2.0 L of water at 25 °C to produce a saturated solution. The solution was then heated to 80 °C. Calculate the mass of lead nitrate that had to be added to produce a saturated solution at that higher temperature.
Pragmatically savvy : Below are descriptions of four university professors. Hopefully you will never have an instructor like  any of them because they are not very pragmatically savvy.
Draw the logic diagram for a circuit that resolves priority : Q:  "Draw the Logic diagram for a circuit that resolves priority among eight active-low inputs, 10_L-17_L, where 10_L has the highest priority.
Describe the australian qualifications framework : Describe the Australian Qualifications Framework. Include a table showing the characteristics of AQF levels and explain the process of developing a training package. List key stakeholders and outline their roles in the process
Undirected graph has scanning tree : undirected graph has scanning trees. The minimal scanning tree is the scanning tree with the minimal sum of weights on edges. The minimal scanning tree can be found by using Prim's algorithm
Sexual response cycle : During the excitement Phase of the sexual response cycle:
Give the contents of eax : in each additional instruction in this problem, assume that EAX contains a given contents before the instruction is executed, and give the contents of EAX as well as the values of the CF, OF, SF, and ZF flags after the instruction is executed:
Construct a 3-bit counter using three d flip-flop : Construct a 3-bit counter using three D flip-flops and a selection of logic gates. The inputs should consist of a signal that resets the counter to 0, called reset
Threatened or actively turned towards communism : Why do you think so many nations chose to pick this time end of warld war II as their own "spring" into greater independence? What were the major grievances they held? And, if they did so, why do you think that so many threatened or actively turned t..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Need a prg that lets user enter total rainfal

Need a prg that lets user enter total rainfall for each of 12 months into an array of doubles,prg should then calculate and display total rainfall for year,the average monthly rainfall, and the months with highest and lowest amounts

  Write a program that finds the equivalent series

Write a program that finds the equivalent series and parallel resistance for a collection of resistor values. Your program should scan first the number of resistors and then the resistor values. Then compute the equivalent series resistance for all r..

  Find the sixth maclaurin polynomial for sin x

Find the sixth Maclaurin polynomial for sin x and use Chebyshev economization to obtain a lesser-degree polynomial approximation.

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  A parking garage charges a $2.00 minimum

A parking garage charges a $2.00 minimum fee to park for up to three hours and an additional $0.50 per hour for each hour or part thereof over three hours.

  Program that takes a number between

Write a program that takes a number between -121 and 121 and output that number in the format of power of 3 (1,3,9,27)example:13 = 9+3+1

  The rpn calculator program

The RPN calculator program should read the RPN expression as an entire line from stdin.Input will consist of a single line. After completing the evaluation of the expression, the program should print the contents of the entire stack, starting with th..

  Native method with deadlock detection and recovery

The naïve method with deadlock avoidance and the naïve method with deadlock detection and recovery - what will you measure and compare in order to determine the winner or which is better

  Write a program to analyze students course marks

Write a program to analyze students course marks. The program should read in students course marks from "m2-grading.txt". The data file has a headline including students ID#, course-1marks, course-2 marks and course-3 markes.

  Describe the probability of the moves

Write a program in C++ to describe the Probability of the moves

  Execute tests and repetitions

Read data from standard input and store them in an array, Execute tests and repetitions

  Write a program that takes a positive integer

Write a program that takes a positive integer from the user and prints the rightmost digit of that integer. This is a sample output: Enter an integer: 1247

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