The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

contraction: test case with multiple edges

+50 -39
+24 -22
vendor/opam/ocamlgraph/tests/test_contraction.expected
··· 15 15 13; 16 16 17 17 18 - 0 -> 1; 19 - 0 -> 2; 20 - 1 -> 6; 21 - 2 -> 3; 22 - 2 -> 4; 23 - 3 -> 7; 24 - 4 -> 5; 25 - 5 -> 9; 26 - 6 -> 8; 27 - 7 -> 8; 28 - 9 -> 10; 29 - 10 -> 12; 30 - 12 -> 11; 18 + 0 -> 1 [taillabel="0-1", ]; 19 + 0 -> 2 [taillabel="0-2", ]; 20 + 1 -> 6 [taillabel="1-6", ]; 21 + 2 -> 3 [taillabel="2-3", ]; 22 + 2 -> 4 [taillabel="2-4", ]; 23 + 2 -> 5 [taillabel="2-5", ]; 24 + 3 -> 7 [taillabel="3-7", ]; 25 + 4 -> 5 [taillabel="4-5", ]; 26 + 5 -> 9 [taillabel="5-9", ]; 27 + 6 -> 8 [taillabel="6-8", ]; 28 + 7 -> 8 [taillabel="7-8", ]; 29 + 9 -> 10 [taillabel="9-10", ]; 30 + 10 -> 12 [taillabel="10-12", ]; 31 + 12 -> 11 [taillabel="12-11", ]; 31 32 32 33 } 33 34 digraph G { ··· 42 43 11; 43 44 44 45 45 - 0 -> 1; 46 - 0 -> 3; 47 - 0 -> 5; 48 - 1 -> 6; 49 - 3 -> 7; 50 - 5 -> 9; 51 - 7 -> 6; 52 - 9 -> 10; 53 - 10 -> 11; 46 + 0 -> 1 [taillabel="0-1", ]; 47 + 0 -> 3 [taillabel="2-3", ]; 48 + 0 -> 5 [taillabel="2-5", ]; 49 + 0 -> 5 [taillabel="4-5", ]; 50 + 1 -> 6 [taillabel="1-6", ]; 51 + 3 -> 7 [taillabel="3-7", ]; 52 + 5 -> 9 [taillabel="5-9", ]; 53 + 7 -> 6 [taillabel="7-8", ]; 54 + 9 -> 10 [taillabel="9-10", ]; 55 + 10 -> 11 [taillabel="12-11", ]; 54 56 55 57 } 56 58
+26 -17
vendor/opam/ocamlgraph/tests/test_contraction.ml
··· 1 1 (* Test file for Contraction *) 2 2 3 + #use "topfind";; 4 + #require "ocamlgraph";; 5 + 3 6 open Graph 4 7 5 8 module Int = struct 6 - type t = int 7 - let compare = compare 8 - let hash = Hashtbl.hash 9 - let equal = (=) 10 - let default = 0 9 + type t = int 10 + let compare = compare 11 + let hash = Hashtbl.hash 12 + let equal = (=) 13 + let default = 0 11 14 end 12 15 13 - module G = Persistent.Digraph.ConcreteBidirectional(Int) 16 + module String = struct 17 + type t = string 18 + let compare = compare 19 + let default = "" 20 + end 21 + 22 + module G = Persistent.Digraph.ConcreteLabeled(Int)(String) 14 23 15 24 (* Make a persistent graph where: 16 25 17 26 0---1---6 18 27 / \ 19 28 2---3---7---8 20 - / 29 + / \ 21 30 4---5---9---10---12---11 13 22 31 23 32 and contract edges linking even numbers. ··· 25 34 1---6,8 26 35 / / 27 36 4,2,0---3---7 28 - \ 37 + \\ 29 38 5---9---10,12---11 30 39 31 40 *) 32 - let g = List.fold_left (fun g (x, y) -> 33 - G.add_edge g x y) (G.add_vertex G.empty 13) [ 34 - (0, 1); (1, 6); 35 - (0, 2); (6, 8); 36 - (2, 3); (3, 7); (7, 8); 37 - (2, 4); 38 - (4, 5); (5, 9); (9, 10); (10, 12); (12, 11) 41 + let g = List.fold_left (fun g -> G.add_edge_e g) (G.add_vertex G.empty 13) [ 42 + (0, "0-1", 1); (1, "1-6", 6); 43 + (0, "0-2", 2); (6, "6-8", 8); 44 + (2, "2-3", 3); (3, "3-7", 7); (7, "7-8", 8); 45 + (2, "2-4", 4); (2, "2-5", 5); 46 + (4, "4-5", 5); (5, "5-9", 9); (9, "9-10", 10); 47 + (10, "10-12", 12); (12, "12-11", 11) 39 48 ] 40 49 41 50 module C = Contraction.Make(G) 42 51 43 - let connects_even (src, dst) = (src mod 2 = 0) && (dst mod 2 = 0) 52 + let connects_even (src, _, dst) = (src mod 2 = 0) && (dst mod 2 = 0) 44 53 let g', m = C.contract' connects_even g 45 54 46 55 module Dot = Graphviz.Dot ( ··· 51 60 let default_vertex_attributes _ = [] 52 61 let vertex_attributes _ = [] 53 62 let default_edge_attributes _ = [] 54 - let edge_attributes _ = [] 63 + let edge_attributes (_, l, _) = [`Taillabel l] 55 64 let get_subgraph _ = None 56 65 end) 57 66