-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
262 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
digraph D { | ||
label="diagram_label"; | ||
|
||
// should be override | ||
bgcolor=red; | ||
|
||
node [color=green]; | ||
before_subgraph -> green | ||
|
||
subgraph cluster_1 { | ||
bgcolor=lightgrey; | ||
label="cluster_1"; | ||
|
||
in_subgraph1 -> green | ||
|
||
node [color=blue]; | ||
in_subgraph1 -> blue | ||
} | ||
|
||
after_subgraph -> green | ||
|
||
// should override bgcolor | ||
bgcolor=pink; | ||
|
||
// subgraph without ID | ||
subgraph cluster_2 { | ||
// will be ignored | ||
bgcolor=blue; | ||
label="noname_1"; | ||
|
||
// will affect nodes | ||
node [color=white]; | ||
|
||
in_subgraph2 -> white; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
========= BEGIN output graph ========= | ||
digraph G { | ||
"before_subgraph"; | ||
"green"; | ||
"in_subgraph1"; | ||
"blue"; | ||
"after_subgraph"; | ||
"in_subgraph2"; | ||
"white"; | ||
|
||
subgraph cluster_1 { "blue";"in_subgraph1";"green"; | ||
}; | ||
subgraph cluster_2 { "white";"in_subgraph2"; | ||
}; | ||
|
||
"before_subgraph" -> "green" [label=<f$oo>, ]; | ||
"in_subgraph1" -> "green" [label=<f$oo>, ]; | ||
"in_subgraph1" -> "blue" [label=<f$oo>, ]; | ||
"after_subgraph" -> "green" [label=<f$oo>, ]; | ||
"in_subgraph2" -> "white" [label=<f$oo>, ]; | ||
|
||
} | ||
========= END output graph ========= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
(**************************************************************************) | ||
(* *) | ||
(* Ocamlgraph: a generic graph library for OCaml *) | ||
(* Copyright (C) 2004-2007 *) | ||
(* Sylvain Conchon, Jean-Christophe Filliatre and Julien Signoles *) | ||
(* *) | ||
(* This software is free software; you can redistribute it and/or *) | ||
(* modify it under the terms of the GNU Library General Public *) | ||
(* License version 2, with the special exception on linking *) | ||
(* described in file LICENSE. *) | ||
(* *) | ||
(* This software is distributed in the hope that it will be useful, *) | ||
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *) | ||
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *) | ||
(* *) | ||
(**************************************************************************) | ||
|
||
(* $Id:$ *) | ||
|
||
open Graph | ||
module G = Imperative.Digraph.Abstract(String) | ||
module B = Builder.I(G) | ||
module DotInput = | ||
Dot.Parse | ||
(B) | ||
(struct | ||
let node (id,_) _ = match id with | ||
| Dot_ast.Ident s | ||
| Dot_ast.Number s | ||
| Dot_ast.String s | ||
| Dot_ast.Html s -> s | ||
let edge _ = () | ||
end) | ||
|
||
let g, _, gh = DotInput.parse_all Sys.argv.(1) | ||
|
||
module Display = struct | ||
include G | ||
let vertex_name v = "\"" ^ String.escaped (V.label v) ^ "\"" | ||
let graph_attributes _ = [] | ||
let default_vertex_attributes _ = [] | ||
let vertex_attributes _ = [] | ||
let default_edge_attributes _ = [] | ||
let edge_attributes _ = [ `HtmlLabel "f$oo" ] | ||
let get_subgraph v = | ||
let graphviz_graph_of_dot_graph graph_id (dg : Dot.graph) : Graphviz.DotAttributes.subgraph = | ||
{ sg_name = graph_id; | ||
sg_attributes = []; | ||
sg_parent = dg.sg_parent; | ||
} in | ||
gh | ||
|> Hashtbl.to_seq | ||
|> Seq.find_map (fun (graph_id_opt, (graph : Dot.graph)) -> | ||
match graph_id_opt with | ||
| Some graph_id -> begin | ||
match List.find_opt (fun n -> n = (V.label v)) graph.sg_nodes with | ||
| Some _ -> Some (graphviz_graph_of_dot_graph graph_id graph) | ||
| None -> None | ||
end | ||
| None -> None | ||
) | ||
|
||
end | ||
module DotOutput = Graphviz.Dot(Display) | ||
|
||
let () = | ||
Printf.printf "========= BEGIN output graph =========\n"; | ||
DotOutput.output_graph stdout g; | ||
Printf.printf "========= END output graph =========" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters