Skip to content

Instantly share code, notes, and snippets.

@lascar-pacagi
Created January 16, 2020 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lascar-pacagi/593a5d40ccda8e908628ada1013c8d13 to your computer and use it in GitHub Desktop.
Save lascar-pacagi/593a5d40ccda8e908628ada1013c8d13 to your computer and use it in GitHub Desktop.
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