16
16
17
17
open ! Stdlib
18
18
19
- module IntSet = Set. Make (struct
20
- type t = int
21
-
22
- let compare = compare
23
- end )
24
-
25
19
module Kosaraju : sig
26
20
type component_graph =
27
21
{ sorted_connected_components : int list array
@@ -147,12 +141,6 @@ struct
147
141
| Has_loop of Id .t list
148
142
| No_loop of Id .t
149
143
150
- type numbering =
151
- { back : int Id.Map .t
152
- ; forth : Id .t array
153
- }
154
- [@@ ocaml.warning "-unused-field" ]
155
-
156
144
let number graph =
157
145
let size = Id.Map. cardinal graph in
158
146
let bindings = Id.Map. bindings graph in
@@ -175,10 +163,10 @@ struct
175
163
dests
176
164
[] )
177
165
in
178
- { back; forth } , integer_graph
166
+ forth, integer_graph
179
167
180
168
let component_graph graph =
181
- let numbering , integer_graph = number graph in
169
+ let forth , integer_graph = number graph in
182
170
let { Kosaraju. sorted_connected_components; component_edges } =
183
171
Kosaraju. component_graph integer_graph
184
172
in
@@ -188,11 +176,11 @@ struct
188
176
| [] -> assert false
189
177
| [ node ] ->
190
178
( (if List. mem ~eq: Int. equal node integer_graph.(node)
191
- then Has_loop [ numbering. forth.(node) ]
192
- else No_loop numbering. forth.(node))
179
+ then Has_loop [ forth.(node) ]
180
+ else No_loop forth.(node))
193
181
, component_edges.(component) )
194
182
| _ :: _ ->
195
- ( Has_loop (List. map ~f: (fun node -> numbering. forth.(node)) nodes)
183
+ ( Has_loop (List. map ~f: (fun node -> forth.(node)) nodes)
196
184
, component_edges.(component) ))
197
185
sorted_connected_components
198
186
0 commit comments