from union_find import UnionFind def redundant_connection(edges): print("\tDeclaring the parent and rank lists") #declares the parent and rank list with lengths based on the edges list graph = UnionFind(len(edges)) print("\t\tParent: ", graph.parent, sep = "") print("\t\tRank: ", graph.rank, sep = "") # Traverse the edges of the graph to check for the redundant edge for v1, v2 in edges: graph.union(v1, v2) # Driver code def main(): edges = [ [[1, 2], [1, 3], [2, 3]] ] for i in range(len(edges)): print(i+1, ".\tEdges: ", edges[i], "\n") redundant_connection(edges[i]) print("-" * 100) if __name__ == '__main__': main()