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

  Winning number combinations from the missouri lottery

The file input.txt contains all of the winning number combinations from the Missouri Lottery since it took its current form on January 3, 1998.  The data is in a file called "input.txt"  All of the data in the file is integer.

  Write a program to determine how long (sec.)

Using the v 2  form of drag, write a program to determine how long (sec.) and how far (m) a 150 gram ball whose radius is 3.5cm would fall before it reached 75% of its terminal velocity. Assume ball falls in air whose density is 1.21 kg/m 3 , has a d..

  Amanda and tyler opened a business

Amanda and Tyler opened a business that specializes in shipping liquids, such as milk, juice, and water, in cylinderical containers. The shipping charges depend on the amount of liquid in the container. (For simplicity, you may assume that the con..

  Write a function named largest which will receive the array

Write a function named largest which will receive the array as input and return the variable LargestNumber.

  Use the top-down modular approach to design program

Use the top-down modular approach and pseudocode to design a suitable program to solve it. Where appropriate, use defensive programming techniques.

  Chess program, enable a monitoring component

Given a chess program, enable a monitoring component to switch planning algorithms at runtime, based on the opposing player's style and response time.

  Program to print out invalid number to character

The integer must contain 3 distinct non-zero number, or the program will print out invalid number.it should print out invalid query.

  Write a c++ program that prompts the user for a double

Write a C++ program that prompts the user for a double that is either positive or negative.

  The staffs need a program that can determine

The staffs need a program that can determine whether children have been naughty or nice. individual data files(can be any name) for each childred are available that consist of 368(365+3)integer number each.

  The program should support a ''new'' feature

Write a GUI program that represents a simple Notepad clone. The program should support a 'new' feature that clears the text buffer, a save feature that writes to a file using a PrintStream

  Contacts class that contains an array

Create a Friend class that contains a first name, last name, a birthday, and a telephone number. Create a Contacts class that contains an array of Friend as well as the owner's name and cell phone Number.

  Program to generate 100,000 prime numbers

Write a POSIX C/C++ program to generate 100,000 prime numbers. Assume that the program will be run on a computer with 5 CPUs and that your goal is to have this program finish as quickly as possible.

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