type t = Pa1.t ref let create n = ref (Pa1.init n (fun i -> i)) let rec find_aux t i = let fi = Pa1.get t i in if fi == i then t, i else let t,r = find_aux t fi in let t = Pa1.set t i r in t, r let find h x = let t,rx = find_aux !h x in h := t; rx let union h x y = let rx = find h x in let ry = find h y in if rx != ry then ref (Pa1.set !h rx ry) else h