Question
Modified graph You are given an array A of size N. Imagine a complete undirected graph of N vertices, where the value of each vertex
Modified graph
You are given an array A of size N. Imagine a complete undirected graph of N vertices, where the value of each vertex is A/. The weight of each edge (0) in this graph is the product of the values of its vertices, that is AAL. Now, you are given a list of Medges that are removed from this graph.
Task
Determine the sum of weights of the minimum spanning tree of the graph or report if no such tree exists.
Notes
A complete undirected graph is an undirected graph where every pair of vertices is connected via an edge.
A minimal spanning tree of a graph is a subset of edges that connects all the vertices of the graph and has a minimal total sum of edge weights.
No edge is removed twice.
The resulting graph formed can be disconnected.
Function description
Complete the function solve provided in the editor. This function takes the following 4 parameters and returns a long integer as the required answer.
N. Represents the value of N
M. Represents the value of M
A: Represents the 1-D array A
E Represents the 2-D array E
Input format
Note: This is the input format you must use to provide custom input (available above the Compile and Test buttons).
The first line contains a single integer T, which denotes the number of test cases. Talso specifies the number of times you have to run the solve function on a different set of inputs.
. For each test case:
The first line contains an integer N denoting the digits in the number of
vertices in the graph.
The second line contains an integer M denoting the number of edges o be removed.
to be removed.
The next line contains N-spaced Integers: A[I] denoting the value of the ith vertex.
The next M lines: Each line contains two spaced Integers E[i][1], E[i][2]). denoting that the edges connecting vertices E[i][1] and E[I][2] is removed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started