File tree 3 files changed +34
-35
lines changed
3 files changed +34
-35
lines changed Original file line number Diff line number Diff line change 220
220
221
221
;; Rules for the test_components test
222
222
223
- ;; (rule
224
- ;; (with-stdout-to
225
- ;; test_components.output
226
- ;; (run ./test_components.exe)))
227
-
228
- ;; (rule
229
- ;; (alias runtest)
230
- ;; (action
231
- ;; (progn
232
- ;; (diff test_components.expected test_components.output)
233
- ;; (echo "test_components: all tests succeeded.\n"))))
234
-
235
- ;; (executable
236
- ;; (name test_components)
237
- ;; (modules test_components)
238
- ;; (libraries graph))
223
+ (rule
224
+ (with-stdout-to
225
+ test_components.output
226
+ (run ./test_components.exe)))
227
+
228
+ (rule
229
+ (alias runtest)
230
+ (action
231
+ (progn
232
+ (diff test_components.expected test_components.output)
233
+ (echo "test_components: all tests succeeded.\n"))))
234
+
235
+ (executable
236
+ (name test_components)
237
+ (modules test_components)
238
+ (libraries graph))
239
239
240
240
;; rules for the dot test
241
241
Original file line number Diff line number Diff line change 1
- 7 components
1
+ 4 components
2
2
0 -> 0
3
3
1 -> 1
4
- 2 -> 2
5
- 3 -> 3
6
- 4 -> 1
7
- 5 -> 1
8
- 6 -> 4
9
- 7 -> 1
10
- 8 -> 5
11
- 9 -> 6
4
+ 2 -> 0
5
+ 3 -> 2
6
+ 4 -> 2
7
+ 5 -> 3
8
+ 6 -> 2
9
+ 7 -> 0
Original file line number Diff line number Diff line change @@ -22,19 +22,20 @@ module C = Components.Undirected(Pack.Graph)
22
22
23
23
open Pack.Graph
24
24
25
- (* FIXME: do not use Random here, as OCaml 5.0 seems to generate a
26
- different graph *)
25
+ (* 0 -- 2 -- 7 1 3 -- 4 5
26
+ \ /
27
+ 6
28
+
29
+ component: 0 1 2 3
30
+ *)
27
31
28
32
let () =
29
- Random. init 42 ;
30
- let g = Rand. graph ~v: 10 ~e: 3 () in
33
+ let g = create () in
34
+ let v = Array. init 8 V. create in
35
+ Array. iter (add_vertex g) v;
36
+ let add i j = add_edge g v.(i) v.(j) in
37
+ add 0 2 ; add 7 2 ; add 3 4 ; add 4 6 ; add 3 6 ;
31
38
let n, f = C. components g in
32
39
printf " %d components@." n;
33
40
iter_vertex (fun v -> printf " %d -> %d@." (V. label v) (f v)) g
34
41
35
-
36
- (*
37
- Local Variables:
38
- compile-command: "ocaml -I .. graph.cma test_components.ml"
39
- End:
40
- *)
You can’t perform that action at this time.
0 commit comments