Sir doubt in this disjoint DS

sir this will work only for undirected graph for directed graph this wont detect rightly cycle right??

@tejasddongare
Yes problems will be encountered in case of a directed graph because dsu does not hold information regarding the orientation of edges.

If my explanation was able to resolve your query, please mark the doubt as resolved.