let inf_int = 1000000

let floyd n graph =
  let d = Array.init n (fun i ->
    Array.init n (fun j -> graph.(i).(j))) in
  for k = 0 to n - 1 do
    for i = 0 to n - 1 do
      for j = 0 to n - 1 do
        if d.(i).(k) + d.(k).(j) < d.(i).(j) then
          d.(i).(j) <- d.(i).(k) + d.(k).(j)
      done
    done
  done;
  d

;;

let n = 4 in
let g = Array.init n (fun _ -> Array.make n inf_int) in
for i = 0 to n - 1 do g.(i).(i) <- 0 done;
g.(0).(1) <- 5;
g.(0).(3) <- 10;
g.(1).(2) <- 3;
g.(2).(3) <- 1;
let d = floyd n g in
d.(0).(3)
