SP17705 SPCE - Gopu and Combinatorics on Graphs
Description
Little Gopu was playing with graphs. He encoutered following problem while playing.
Given a graph G with n vertices and m edges. Let us say it has k connected components. Find out how many numbers of ways you can add k - 1 edges to make the graph connected. Note that the new edge you are going to add should not be a repeated edge ie. if you are going to connect u, v then there should not be an edge between u, v already in the graph. Output the answer modulo 10^9 + 7.
If the graph is already connected, Output -1
Help Gopu with this task.
Input Format
First line contains T : number of test cases. (1
Output Format
For each test case, output the answer as required.