let alias_node (graph : graph)
(curid : nodeid)
(newid : nodeid) : unit =
let move_edge orig dest edge =
remove_inb graph orig edge;
match edge with
| InConcat(lhs,rhs) -> add_concat graph lhs rhs dest
| InIsect(source) -> add_isect graph source dest
in
let at_most_one_concat edge acc = match edge with
| InConcat(_,_) when acc = 1 -> raise Rename
| InConcat(_,_) -> acc + 1
| _ -> acc
in
if Hashtbl.mem graph newid then
let curid_node = find_node graph curid in
let newid_node = find_node graph newid in
iter (move_edge curid newid) curid_node.inb;
ignore (fold at_most_one_concat newid_node.inb 0);
Hashtbl.remove graph curid
else
let curid_node = find_node graph curid in
curid_node.id <- newid;
Hashtbl.remove graph curid;
Hashtbl.replace graph newid curid_node