GraphViz graph in the presence of clusters

Well, I know that the question of arranging nodes in GraphViz was almost ready for death, but I did not see anyone addressing the issue of arranging clusters. I tried all the tricks in the book:

  • The order of the nodes in the file is from left to right. If I do not add clusters, the dot just does the right thing and shows them in the correct order without any hints. However, when adding clusters, the point shuffles (randomizes?) The Order.

  • I added invisible edges to try to clean up the subgroups; but it seems that as soon as the clusters are located inside the cluster, the point selects a specific order and will not be shy that the edges go around the entire map in order to save it.

  • Since the order of the nodes and invisible edges did not suit me, I turned to an attempt to force the position of the nodes. This fails again, because only the dot makes clusters, and it ignores the entry positions. Starting even unchanged point output via fdp (with generated positions) caused a failure, so I also refused this direction.

Here is an example of a dots file that creates the image below. The green lines are the โ€œinvisibleโ€ edges that I unsuccessfully added, trying to get the dot to put everything in order from left to right. If this were successful, the green lines would pass from the anchor to the left through the nodes, to the right, without crossing itself. For example, each be.0 will be to the left of its native element be.1, and similarly for tg-s). As you can see, the point shuffled the order of the subclusters (by placing the sibling .1 to the left of one .0). It is as if he did it on purpose, due to some restrictions, regardless of any edges. I cannot find any way to convince him to do otherwise. This is very frustrating because the generated charts are perfect for my needs.

Badly ordered dot clusters
(source: ben-kiki.org )

So. Is there any way to get a point to observe some order of clusters within a cluster?

Change: If you look further, it seems that the order of the clusters is by default inverse to the order of the nodes. Thus, usually (in the TB column) the node that appears first in the text will tend to appear to the left of the node that appears later in the text; but it seems that the subcluster that appears first in the text will tend to appear to the right of the subcluster that appears later in the text. Now, if this were a strict rule, life would be magnificent; however, the dot still sometimes (but less frequently) insists on regrouping the subgroups, regardless of any resulting crossed edges, apparently "just because." So the question remains.

+5
source share
1 answer

A bit late, but here are some ideas for others that come here: (the sample data is too large to play with it)

anyway you tried:

  • edge [restriction = false] on some black / red lines (restriction = false may lead to some strange routing along the long edge)
  • and / or edge [weight = 1000] on the green lines (more difficult to understand correctly),
  • You can also add a bit more scaffolding.
  • You cannot rank = the same thing in clusters, so if necessary it should be on the nodes of the forests

Here is an easy example that successfully rotates the order of half the nodes, including clusters

digraph G { subgraph cluster_sa{ edge[weight=1000] subgraph cluster_s1a{ s1a1->s1a2 } subgraph cluster_s2a{ s2a1->s2a2 } subgraph cluster_s1a_{ s1a1_->s1a2_ } subgraph cluster_s2a_{ s2a1_->s2a2_ } s1a2->s1a1_ s2a2->s2a1_ } { edge[constraint=false] subgraph cluster_ta{ subgraph cluster_t1a{ t1a1->t1a2 } subgraph cluster_t2a{ t2a1->t2a2 } subgraph cluster_t1a_{ t1a1_->t1a2_ } subgraph cluster_t2a_{ t2a1_->t2a2_ } t1a2->t1a1_ t2a2->t2a1_ } edge[tailport=s headport=s] s1a2_->t1a1 s2a2_->t2a1 } edge[color=green] node[color=green] {rank=same s1a0->s2a0->t2a0->t1a0} s1a0->s1a1 s2a0->s2a1 t1a0->t1a2_ t2a0->t2a2_ t1a2_->t1a1_->t1a2->t1a1 t2a2_->t2a1_->t2a2->t2a1 } 

displayed on viz-js.com

bending

in some cases, it can also be useful for connecting the node in a strict order (for example, t2a2 _-> t2a1_ [dir = back] instead of the above, it would actually be better, since then the green arrow could be removed, giving a straight black arrow) but I donโ€™t think this will help in your case

0
source

All Articles