Write a C program to Find disjoint sets in a graph using disjoint set ADT operations FIND, UNION
Write a C program to Find disjoint sets in a graph using disjoint set ADT operations FIND, UNION
Let us first discuss what disjoint sets in a graph is? Disjoint sets in a graph mean components of a graph. Each connected component is treated as a disjoint set since it has no relation with the other components. Each connection (edge) is said to be the relation between two nodes. Two nodes having a relation falls in the same set.
The
For each edge in the edge list:
If the nodes on the edge are in same set, do nothing, otherwise, we will UNION them as they have relations between them and should come under same set.
To check whether the two nodes are in same set we use FIND
NOTE: IN C PROGRAM ONLY PLEASE
Output: (attached picture)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps