How to find all simple cycles in an undirected graph efficiently?

Given a graph, what are some of the best algorithms (what is the best algorithm) to find all the simple paths (i.e. no cycles) between any two nodes?

  • Some of the edges are undirected, some of them are directed.. That being the case, what is the best algorithm to find all the simple paths in a graph?

  • Answer:

    Breadth First Search should work(Make the BFS tree and you will get all simple paths).Regarding the huge number of paths, there can be O(2^|V|) paths and you need to know all those paths, so any algorithm will go for a toss.

Ambar Pal at Quora Visit the source

Was this solution helpful to you?

Other answers

The National Institute of Standards and Technology (NIST) online Dictionary of Algorithms and Data Structures describes this particular problem as http://xlinux.nist.gov/dads//HTML/allSimplePaths.html and recommends a http://xlinux.nist.gov/dads//HTML/depthfirst.html to find all non-cyclical paths between arbitrary pairs of nodes.

Andrew Webb

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.