Finding all cycles in an undirected graph
Asked Answered
M

2

10

If I have an undirected graph, how can I get a list of all cycles?

For example, from the following graph, I would want the cycles:

(a,b,d,e,c)
(a,b,c)
(b,d,e)

enter image description here

Manifold answered 21/2, 2011 at 15:54 Comment(4)
(a,b,d,c)? Are you sure?Caswell
Homework? Also possible duplicate: https://mcmap.net/q/36817/-finding-all-cycles-in-a-directed-graphPe
me.utexas.edu/~bard/IP/Handouts/cycles.pdfToenail
Googling your question, the very first search result has a nice explanation about how to do itCrin
S
2

You presumably want only simple cycles (those that don't repeat a vertex), or there's an infinite number of them. Even then, there can be an exponential number of cycles. Perhaps this isn't the problem you really want to solve?

Splenetic answered 22/2, 2011 at 2:31 Comment(0)
O
8

this is not possible in polynomial time as if possible then we could use this to find all cycles and hence cycle of largest length which implies we can solve hamiltonian cycle problem completely in polynomial time.

Obed answered 22/4, 2013 at 9:27 Comment(0)
S
2

You presumably want only simple cycles (those that don't repeat a vertex), or there's an infinite number of them. Even then, there can be an exponential number of cycles. Perhaps this isn't the problem you really want to solve?

Splenetic answered 22/2, 2011 at 2:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.