Write a Program to generate a random connected undirected graph on a n vertices by generating random pairs of integers between 1 and n. Compute how many edges are needed to produce a connected graph(as a function of n).

Implement the union-find algorithm, with the Weighted Balancing and the splitting Rule, to keep track of the connectivity. For each n=5, 10, 15, 20…95, 100, do 1000 experiments to find the average number of edges needed to get a connected graph.

Can any one help me out with the code?