(* Clôture transitive d'un graphe représenté par une matrice d'adjacence

   Algorithme de Warshall *)

let warshall g =
  let n = Array.length g in
  let t = Array.map Array.copy g in
  for k = 0 to n - 1 do
    for i = 0 to n - 1 do
      for j = 0 to n - 1 do
        t.(i).(j) <- t.(i).(j) || t.(i).(k) && t.(k).(j)
      done
    done
  done;
  t

This document was generated using caml2html