···119119 H.remove degree x;
120120 Q.push x todo
121121 in
122122+ let add_vertex acc v =
123123+ G.iter_succ
124124+ (fun x->
125125+ try
126126+ let d = H.find degree x in
127127+ if d = 1 then push x else H.replace degree x (d-1)
128128+ with Not_found ->
129129+ (* [x] already visited *)
130130+ ())
131131+ g v;
132132+ f v acc in
122133 let rec walk acc =
123134 if Q.is_empty todo then
124135 (* let's find any node of minimal degree *)
···129140 | [] -> acc
130141 | _ ->
131142 let vl = find_top_cycle checker min in
132132- List.iter push vl;
143143+ List.iter (H.remove degree) vl;
144144+ let acc = List.fold_left add_vertex acc vl in
133145 (* let v = choose_independent_vertex checker min in push v; *)
134146 walk acc
135147 else
136148 let v = Q.pop todo in
137137- let acc = f v acc in
138138- G.iter_succ
139139- (fun x->
140140- try
141141- let d = H.find degree x in
142142- if d = 1 then push x else H.replace degree x (d-1)
143143- with Not_found ->
144144- (* [x] already visited *)
145145- ())
146146- g v;
149149+ let acc = add_vertex acc v in
147150 walk acc
148151 in
149152 G.iter_vertex