tags:

views:

81

answers:

1

A similar question is posted here.

I have an undirected graph with Vertex V and Edge E. I am looking for an algorithm to identify all the cycle bases in that graph. An example of such a graph is shown below:

alt text

Now, all the vertex coordinates are known ( unlike previous question, and contrary to the explanation in the above diagram), therefore it is possible to find the smallest cycles that encompass the whole graph.

In this graph, it is possible that there are edges that don't form any cycles.

What is the best algorithm to do this?

A: 

I haven't tried this and it is rather greedy but should work:

  1. Pick one node
  2. Go to one it's neighbors's
  3. Keep on going until you get back to your starting node, but you're not allowed to visit an old node.
  4. If you get a cycle save it if it doesn't already exist or a subset of those node make up a cycle. If the node in the cycle is a subset of the nodes in another cycle remove the larger cycle (or maybe split it in two?)
  5. Start over at 2 with a new neighbor.
  6. Start over at 1 with a new node.

Comments: At 3 you should of course do the same thing as for step 2, so take all possible paths.

Maybe that's a start? As I said, I haven't tried it so it is not optimized.

mastoj