File tree Expand file tree Collapse file tree 3 files changed +34
-35
lines changed Expand file tree Collapse file tree 3 files changed +34
-35
lines changed Original file line number Diff line number Diff line change 220220
221221;; Rules for the test_components test
222222
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))
239239
240240;; rules for the dot test
241241
Original file line number Diff line number Diff line change 1- 7 components
1+ 4 components
220 -> 0
331 -> 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)
2222
2323open Pack.Graph
2424
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+ *)
2731
2832let () =
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 ;
3138 let n, f = C. components g in
3239 printf " %d components@." n;
3340 iter_vertex (fun v -> printf " %d -> %d@." (V. label v) (f v)) g
3441
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