let neighbours_dist2 topo =
Array.mapi
(fun i neighbours ->
let forbiden = i :: Array.to_list neighbours in
let result = ref [] in
Array.iter
(fun neighbour ->
Array.iter
(fun non -> (* neighbour of neighbour *)
if not (List.mem non !result) && not (List.mem non forbiden) then result := non :: !result)
topo.(neighbour))
neighbours;
Array.of_list (List.rev !result))
topo