Skip to content

Latest commit

 

History

History
27 lines (27 loc) · 902 Bytes

README.md

File metadata and controls

27 lines (27 loc) · 902 Bytes

Cycles Detection in an Undirected Graph (Cyclic Undirected Graph Conversion to Acyclic Graph)

In this code, you can create an undirected graph and add its edges; then, the code finds all cycles also cycles of the cycle in the graph and print its members. The main idea is finding one cycle at the time and destroy it, then repeat this process until no cycle will be found in the graph. in the final, your graph will not have any cycle in it. For example, consider the following undirected graph:

When run the code, you see this out put

cycle 1: [2, 3, 4, 1, 0]
cycle 2: [9, 8, 7]
cycle 3: [5, 10, 9, 8, 7, 2, 3]
cycle 4: [6, 5, 10, 9, 8, 7, 2, 3, 4]