Does anyone have source code implementing this algorithm for finding cycles, preferably in a modern statically-typed language like SML, OCaml, Haskell, F#, Scala?
Asked
Active
Viewed 5,954 times
4
-
Did you ever find a public implementation. In f# out ocaml? Or even in c#? – Arturo Hernandez May 19 '16 at 00:42
-
@ArturoHernandez: No. – J D Mar 01 '17 at 18:08
-
let me github that for you: [Haskell](https://github.com/search?l=Haskell&q=Johnson+cycles&type=Code) or [OCaml](https://github.com/search?l=OCaml&q=Johnson+cycles&type=Code) or [F#](https://github.com/search?l=F%23&q=Johnson+cycles&type=Code) or [Scala](https://github.com/search?l=Scala&q=Johnson+cycles&type=Code). found nothing for [SML](https://github.com/search?l=SML&q=Johnson+cycles&type=Code) – milahu May 27 '22 at 21:34
4 Answers
2
The following is a Java implementation of the algorithm you need: https://github.com/1123/johnson. Java running on the JVM, you can also use it from Scala.

user152468
- 3,202
- 6
- 27
- 57
1
I struggled on this too, I came up with this page that lists some implementations for Johnson algorithm (the one looking for elementary circuits) in Java and OCaml. The author of the blog post fixed some issues in the original implementations, on the same page I linked before there are also the fixed versions of both implementations.

Alessandro S.
- 875
- 12
- 24
0
Will C++ and Boost Graph Library work for you?

mlt
- 1,595
- 2
- 21
- 52
-
2I already checked Boost Graph Library and it doesn't implement this algorithm (the Johnson's algorithm I cited finds all cycles but the Johnson's algorithm you've referenced finds all-pairs shortest paths for sparse graphs, i.e. different thing). In fact, I was surprised at how little BGL does implement. I also checked OCaml's ocamlgraph, Haskell's graph libraries and some others with no success. – J D Mar 24 '11 at 09:19