Question: 1 . Please write the c language code . Write a Program to compute the Minimum spanning tree of a connected undirected graph G using
Please write the c language code Write a Program to compute the Minimum spanning tree of a connected undirected graph G using
Prims algorithm Print the sequence with which edges are picked by algorithm and total edge
weight of spanning tree. The goal is to implement the following functions:
a Sequencex : Print sequence in which edges will be picked if x is starting node.
b Total weight : Print total cost of the minimum spanning tree.
Input format:
First line contains an integer n in that denotes the number of vertices in the graph.
The subsequent n lines contain an Adjacency matrix of size n n If two nodes are directly
connected by an edge, it is denoted by a positive integer in the matrix; else it is denoted by
The positive integer corresponds to the weight on the edge. Assume that all edge weights
will be distinct.
Each line of input is a character from the menu list stx
Input s calls the function Sequencex
Input t calls the function Total weight
Input x terminates the execution of the program.
All the inputs in a line are separated by space.
Output format:
Line contains an integer representation of the total edge weight of the spanning tree or Line
contains sequence of integer representing sequence of edges.
Sample Input :
t
s
x
Sample Output :
Sample Input :
t
s
x
Sample Output :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
