Skip to content

Commit

Permalink
Add another cluster nesting to increase margin
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook committed Jun 17, 2023
1 parent aa7d7ac commit 40c27da
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/graph/to_graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,20 @@ fn build_graph(nodes: Nodes, edges: Edges, sort_colors: &SortColors) -> Graph {
let color = sort_colors[&sort];
stmts.push(stmt!(attr!("fillcolor", color)));
for (subgraph_id, nodes) in subgraphs {
// Nest in empty sub-graph so that we can use rank=same
// https://stackoverflow.com/a/55562026/907060
let quoted_subgraph_id = quote(&subgraph_id);
let subgraph_stmts = nodes.into_iter().map(|s| stmt!(s)).collect();
let s = stmt!(subgraph!(quoted_subgraph_id;
let s = stmt!(subgraph!("";
// Disable label for now, to reduce size
// NodeAttributes::label(subgraph_html_label(&sort)),
subgraph!("", subgraph_stmts)

// Nest in empty sub-graph so that we can use rank=same
// https://stackoverflow.com/a/55562026/907060
subgraph!(quoted_subgraph_id; subgraph!("", subgraph_stmts)),

// Make outer subgraph a cluster but make it invisible, so just used for padding
// https://forum.graphviz.org/t/how-to-add-space-between-clusters/1209/3
SubgraphAttributes::style(quote("invis")),
attr!("cluster", "true")
));
stmts.push(s);
}
Expand Down

0 comments on commit 40c27da

Please sign in to comment.