AlgoMaster Logo

Detect Cycle in Undirected Graph (Union-Find)

n=5,edges=[[0,1],[1,2],[2,3],[3,4],[4,1]]
0 / 21
Input Graph01234Union-Find StructureLegend:StandardProcessingActiveConnectedCycle
algomaster.io
Step:Given an undirected graph with 5 vertices and 5 edges. Detect if the graph contains a cycle using Union-Find.