rustworkx icon indicating copy to clipboard operation
rustworkx copied to clipboard

Implement simple_cycles() Johnson Algorithm

Open chikko80 opened this issue 3 years ago • 5 comments

What is the expected enhancement?

Networkx has an algorithm for finding all cycles in a directed graph:

simple_cycles

it's based on the Research of D. B. Johnson in 1975

Would love to see a rust implementation of that!

chikko80 avatar Jun 05 '22 09:06 chikko80

@mtreinish I appreciate the fast implementation! I tested your code on my current graph in comparison to networkx. Just want to let you know that there is probably a little bug in the code. On my current graph, networkx returns about 7000 cycle. The retworkx implementation returns only 1.

Maybe just a wrong condition

chikko80 avatar Jun 07 '22 05:06 chikko80

It's still a work in progress (hence the WIP prefix), it's still failing one of the tests I wrote too. I pushed up the commit to my fork mostly for saving so I had the work backed up. But, yeah the implementation isn't working fully yet, when I finish it then I'll open a pull request.

mtreinish avatar Jun 07 '22 10:06 mtreinish

Hi @mtreinish, I just wanna kindly ask how your current workload is and when we could expect the algorithm to be finished. I know, you are doing that in your free time so absolutely no pressure. I am just curious and looking forward to the implementation because it would fit into my current university project perfectly.

chikko80 avatar Jun 19 '22 06:06 chikko80

I think I've got it working now, see https://github.com/Qiskit/retworkx/pull/633, let me know if you still have issues with it. I still need to do more testing and add more tests to the PR

mtreinish avatar Jun 26 '22 16:06 mtreinish

Working as expected!

chikko80 avatar Jun 27 '22 01:06 chikko80