let overAnd (connection,and_node,port) graph =
let rec add_and or_inputs target and_node and_in_edges graph =
match or_inputs with
(c,t,p)::tail ->let new_id = NewName.get ()
in let new_node = {and_node with id=new_id; inputs = PortMap.from_list (List.map (fun x -> let (c,_,_)=x in (PortStrictB,{c with nameforudg = NewName.get ()})) and_in_edges)}
in let and_added = DG.addnode new_node graph
in let edge_to_or_added = DG.addedge ({sourceid=new_id; nameforudg=NewName.get (); lblmap = mkcnstlblmap and_node.inside},target,PortUnstrB) and_added
in let edge_added = DG.addedge ({c with nameforudg=NewName.get (); lblmap = rlmmcompose c.lblmap connection.lblmap}, new_id, PortStrictB) edge_to_or_added
in
add_and tail target and_node and_in_edges edge_added
| _ -> graph
in let or_node = DG.findnode connection.sourceid graph
in let and_out_edges = DG.nodefoldoutedges graph (fun y a -> y::a) and_node []
and and_in_edges = List.filter (fun x -> let (c,_,_ )= x in c.nameforudg!=connection.nameforudg) (DG.nodefoldedges (fun y a -> y::a) and_node [])
and or_in_edges = DG.nodefoldedges (fun y a -> y::a) or_node []
and graph_ref = ref graph
and new_or_id = NewName.get ()
in graph_ref := DG.remedge connection.nameforudg !graph_ref;
graph_ref := DG.remnode connection.sourceid !graph_ref;
graph_ref := DG.remnode (and_node).id !graph_ref;
graph_ref := DG.addnode or_node !graph_ref;
graph_ref := DG.addnode {or_node with inputs = PortMap.empty; inside = and_node.inside; id=new_or_id} !graph_ref;
graph_ref := new_source_edge and_out_edges new_or_id !graph_ref;
graph_ref := add_and or_in_edges new_or_id and_node and_in_edges !graph_ref;
Left !graph_ref