Skip to content

In this python script, you can create an undirected graph then convert it to a acyclic graph

Notifications You must be signed in to change notification settings

amoazeni75/cyclic-graph-to-spanning-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

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]

About

In this python script, you can create an undirected graph then convert it to a acyclic graph

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages