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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!