Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
type graph = bool array array
let example () =
[| (* 0 1 2 3 4 *)
(*0*) [| true; true; false; true; false; |];
(*1*) [| false; true; true; false; false; |];
(*2*) [| false; false; true; false; false; |];
(*3*) [| false; false; false; true; true; |];
(*4*) [| true; false; false; false; true; |];
|]
let floyd_warshall (g : graph) : unit =
let n = Array.length g in
for k = 0 to n - 1 do
for i = 0 to n - 1 do
for j = 0 to n - 1 do
g.(i).(j) <- g.(i).(j) || g.(i).(k) && g.(k).(j)
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.