How to print all simple negative weight cycles in a directed graph for a given vertex

Viewed 107

It seems I've read through all of the questions about finding cycles in graphs on stackoverflow and more, so I'll try to be as clear as possible:

  1. I am new to all these algorithms, so please try to be as specific as possible in your answers. Thanks!
  2. Complexity and performance does not matter to me
  3. I have a directed graph and a starting vertex
  4. I need only negative-weight cycles starting and ending in that vertex (e.g. A-B-C-A, A-G-M-A etc.)
  5. I need only simple cycles (i.e. A-B-A-B-A will not work for me).
  6. Elementary cycles (i.e. A-B-A) also need to be included
  7. I need to print all of these cycles (not count or just tell if they exist)
  8. I tried Bellman-Ford algorithm, but it seems to find only the most negative cycle. Even changing the starting vertex does not guarantee all cycles.

The only solution I found to that problem is finding all cycles and choosing negative-weight cycles from them. The thing is the solution COUNTS (not prints) ALL (not the ones that start and end in a given vertex). I'm stuck here. Any help would be greatly appreciated. Thanks in advance!

0 Answers
Related