let find_two_mux_edge cycle tree =
let rec find_two cyc =
match cyc with
x::t::tail -> if is_MUXor x tree && is_MUXor t tree
then (List.hd (List.map (fun nx -> let (cx,_,_) = nx.edge in cx.nameforudg) (edgefilter tree (fun _ mx -> let (cx,tx,_)=mx.edge in tx ==x && cx.sourceid == t && mx.edgeway == Normal))))
else find_two (t::tail)
| t::tail -> if is_MUXor t tree && is_MUXor (List.hd cycle) tree
then (List.hd (List.map (fun nx -> let (cx,_,_) = nx.edge in cx.nameforudg) (edgefilter tree (fun _ mx -> let (cx,tx,_)=mx.edge in tx ==t && cx.sourceid == (List.hd cycle) && mx.edgeway == Backward))))
else find_two tail
| _ -> NewName.invalid_id
in find_two cycle