diff --git a/test/coloring/config.ml b/test/coloring/config.ml index 3bcc6b7d812097ee0ee5ba1286784619efd11697..11a5d8140d2d42bce4815b672c8aa74f441686b6 100644 --- a/test/coloring/config.ml +++ b/test/coloring/config.ml @@ -12,5 +12,14 @@ let clash_number pidl get = let potential = Some clash_number (* let potential = None *) let legitimate = None -let fault = None -let init_search_utils = None +let fault = None + + +let md = max_degree () +let s2n s = [I (0, s, md)] +let n2s nl s = + match nl with + | [I(_, i, _)] -> i + | _ -> assert false + +let init_search_utils = Some (s2n, n2s) diff --git a/test/coloring/p.ml b/test/coloring/p.ml index 9be6c6f1f9f6b0444922e6d62d9a24273ccf3d97..2178a1396d6dfd06352bcf65fda01f404a59f432 100644 --- a/test/coloring/p.ml +++ b/test/coloring/p.ml @@ -1,9 +1,9 @@ -(* Time-stamp: <modified the 28/07/2021 (at 09:01) by Erwan Jahier> *) +(* Time-stamp: <modified the 12/10/2021 (at 15:42) by Erwan Jahier> *) (* This is algo 3.1 in the book *) open Algo let k = if is_directed () then - failwith "this algo is for non-directed graphs!" card()+1 + failwith "this algo is for non-directed graphs!" else max_degree () + 1 @@ -12,7 +12,9 @@ let (init_state: int -> string -> 'v) = fun i _ -> Random.int i let (colors : 'v neighbor list -> 'v list) = fun nl -> List.map (fun n -> state n) nl -(* Returns the free colors is ascending order (n.log(n)) *) +(* Returns the free colors is ascending order (n.log(n)) +nb: suppose that all states are in [0;k-1] +*) let (free : 'v neighbor list -> 'v list) = fun nl -> let comp_neg x y = - (compare x y) in let n_colors = List.map (fun n -> state n) nl in (* neighbor colors *) diff --git a/test/coloring/state.ml b/test/coloring/state.ml index 3a603c02fcdac6a078c1c8dc14764550c2b4f6e9..25ccb6f320c1cf3ee34494b1dbdf732e3fe6258f 100644 --- a/test/coloring/state.ml +++ b/test/coloring/state.ml @@ -4,7 +4,7 @@ type t = int let to_string = Printf.sprintf "c=%i" -let of_string = Some int_of_string +let of_string = Some (fun s -> Scanf.sscanf s "c=%i" (fun s -> s)) let copy = fun x -> x let actions = ["conflict"]