Skip to content
Snippets Groups Projects
Commit 73f42287 authored by erwan's avatar erwan
Browse files

Fix: a bug in gg. The ER graph generation was wrong (missing parenthesis in if/then).

Moreover, it was not taking into account whether the graph was directed or not.
parent 43b43e5b
No related branches found
No related tags found
No related merge requests found
...@@ -8,23 +8,34 @@ type probability = float (*between 0 and 1*) ...@@ -8,23 +8,34 @@ type probability = float (*between 0 and 1*)
let gen_ER : (bool -> int -> probability -> Topology.t) = let gen_ER : (bool -> int -> probability -> Topology.t) =
fun directed nb p -> fun directed nb p ->
let (node_succ:node_succ_t) = Hashtbl.create nb and nodes = create_nodes "p" (0,nb) in let (node_succ:node_succ_t) = Hashtbl.create nb
iteri (fun i n -> and nodes = create_nodes "p" (0,nb)
in
iteri (fun i n ->
iteri (fun j m -> iteri (fun j m ->
if (i < j) && (Random.float 1.) < p then if not directed then (
(Hashtbl.replace node_succ n if i < j && (Random.float 1.) < p then (
((1,m)::(try Hashtbl.find node_succ n with Not_found -> [])); (Hashtbl.replace node_succ n
Hashtbl.replace node_succ m ((1,m)::(try Hashtbl.find node_succ n with Not_found -> [])));
((1,n)::(try Hashtbl.find node_succ m with Not_found -> []))) (Hashtbl.replace node_succ m
) nodes ((1,n)::(try Hashtbl.find node_succ m with Not_found -> [])));
) nodes; ) else (
let nl = id_to_empty_nodes nodes in if i <> j && (Random.float 1.) < p then
{ (Hashtbl.replace node_succ n
nodes = nl; ((1,m)::(try Hashtbl.find node_succ n with Not_found -> [])));
succ = (fun n -> try Hashtbl.find node_succ n with Not_found -> []); )
of_id = get_of_id nl; )
directed = directed )
} nodes
)
nodes;
let nl = id_to_empty_nodes nodes in
{
nodes = nl;
succ = (fun n -> try Hashtbl.find node_succ n with Not_found -> []);
of_id = get_of_id nl;
directed = directed
}
let rec init_m_nodes : (int -> node_succ_t -> node_id list -> node_id list) = let rec init_m_nodes : (int -> node_succ_t -> node_id list -> node_id list) =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment