Filling between cluster boundaries and nodes using Graphviz and neato

I want to generate the following graph in Graphviz:

Desired layout

For the reasons explained here , this is:

digraph { layout=dot; rankdir="LR"; overlap = true; node[shape=record, height="0.4", width="0.4"]; edge[dir=none]; A; B; C; D; E; F; G; H; I; A -> B -> C; D -> E -> F; G -> H -> I; edge[constraint=false]; A -> D -> G; subgraph clusterX { label="Cluster 1"; A; B; } subgraph clusterY { label="Cluster 2"; E; F; H; I; } } 

produces the following:

Not desired layout

Following some careful tuning of the appearance order of the nodes :

  F; E; I; H; D; G; A; B; C; 

I get the correct result.

While this works, I would like to get more direct control over the placement of nodes, so I tried switching to neato so that I could force node locations to use pos:

 graph g { layout=neato; node[shape=record, height="0.4", width="0.4"]; edge[dir=none]; A [pos="1,3!"]; B [pos="2,3!"]; C [pos="3,3!"]; D [pos="1,2!"]; E [pos="2,2!"]; F [pos="3,2!"]; G [pos="1,1!"]; H [pos="2,1!"]; I [pos="3,1!"]; A -- B -- C; D -- E -- F; G -- H -- I; A -- D -- G; subgraph clusterX { label="Cluster 1"; A; B; } subgraph clusterY { label="Cluster 2"; E; F; H; I; } } 

This gives the following result:

enter image description here

How can I get neato to add padding between the borders of the cluster and the nodes in the cluster (just like the dot does)?

+4
source share
1 answer

I hate being a supporter of pooper, but I don't think the neato-with-fixed-position-and-clusters approach will succeed.

Cluster support depends on the layout mechanism - not all engines support it to the same extent :

Note that for good and bad, clustered subgraphs are not part of the DOT language, but only the syntactic convention that some of the linking mechanisms adhere to.

Neato does not seem to be part of the engines supporting clusters , and while fdp supports neato as a layout, it does not support fixed positions .

In the above related forum posts, ERG suggests using the gvpr script at some point to achieve this - perhaps not the solution you had in mind.

By the way, the graph should not be a directed graph, I get warnings and replace everything -> with -- .

+4
source

Source: https://habr.com/ru/post/1403442/


All Articles