Commit 528298e3 authored by erwan's avatar erwan
Browse files

gg: add an option to compute the graph diameter

parent 917a7891
......@@ -83,8 +83,8 @@ let compute_attr : (Topology.t -> string list -> (string * string) list) =
)
*)
let all_attr : (Topology.t -> (string * string) list) =
fun g ->
let all_attr : bool -> (Topology.t -> (string * string) list) =
fun diameter g ->
[ "min_deg", string_of_int
(match !min_max with
| None -> (
......@@ -137,13 +137,12 @@ let all_attr : (Topology.t -> (string * string) list) =
Printf.eprintf "Computing the link_number...\n";
flush stderr;
Topology.get_nb_link g);
(*
"diameter", string_of_int (
] @ (if not diameter then [] else
["diameter", string_of_int (
Printf.eprintf "Computing the diameter...\n";
flush stderr;
Diameter.get g)
*)
]
Diameter.get g)
])
let to_dot_string : (Topology.t -> string -> (string * string) list -> string) =
......@@ -279,7 +278,7 @@ let () = (
exit 2
| Some g -> g
in
make_dot g t.outputFile (all_attr g);
make_dot g t.outputFile (all_attr t.diameter g);
if (t.outputFile <> "" && not t.silent)
then Printf.printf "Done.\nOutput file : '%s'\n" t.outputFile
)
......@@ -35,6 +35,7 @@ type t = {
mutable silent : bool;
mutable connected : bool;
mutable directed : bool;
mutable diameter : bool;
mutable _args : (string * Arg.spec * string) list;
mutable _man : (string * (string list * action) list) list;
......@@ -86,6 +87,7 @@ let (make_args : unit -> t) =
silent = false;
connected = false;
directed = false;
diameter = false;
_args = [];
_man = [];
......@@ -299,6 +301,10 @@ let (mkoptab : string array -> t -> unit) =
(Arg.Unit (fun () -> args.connected <- true))
[(["Try again until a connected graph is generated"],"void")];
mkopt args ["--diameter"]
(Arg.Unit (fun () -> args.diameter <- true))
[(["Compute the graph diameter and put it in the graph attributes"],"void")];
mkopt args ["--directed";"-dir"]
(Arg.Unit (fun () -> match args.action with
| "ring" -> args.directed <- true
......
......@@ -33,6 +33,7 @@ type t = {
mutable silent : bool;
mutable connected : bool;
mutable directed : bool;
mutable diameter : bool;
mutable _args : (string * Arg.spec * string) list;
mutable _man : (string * (string list * action) list) list;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment