I am trying to write a subgraph in graphviz, but while I'd like the main graph to preserve the ranking of its own nodes, I'd want the subgraph one to get a compressed form, ie to have its layout constrained into a square.
This is the actual graph that I obtain:
and this is the code that generated it (I am actually using a python lib to produce the output image):
subgraph cluster_15_ {
graph [aspect=1 concentrate=true ordering=out ratio=compress size="1.0,1.0!"]
node [fixedsize=true shape=circle width=0.4]
edge [dirType=forward len=0.5]
cluster_15_0 [label=0]
cluster_15_2 [label=2]
cluster_15_3 [label=3]
cluster_15_4 [label=4]
cluster_15_5 [label=5]
cluster_15_7 [label=7]
cluster_15_8 [label=8]
cluster_15_11 [label=11]
cluster_15_12 [label=12]
cluster_15_13 [label=13]
cluster_15_15 [label=15]
cluster_15_0 -> cluster_15_2
cluster_15_5 -> cluster_15_3
cluster_15_3 -> cluster_15_4
cluster_15_2 -> cluster_15_5
cluster_15_5 -> cluster_15_7
cluster_15_7 -> cluster_15_8
cluster_15_12 -> cluster_15_11
cluster_15_15 -> cluster_15_12
cluster_15_15 -> cluster_15_13
cluster_15_4 -> cluster_15_15
}
I'd like to have the nodes into a 4x4 box for instance (the arcs can go upside, down, it is not a problem).
This creates 4 ranks, each containing 4 nodes
digraph four{
subgraph cluster4{
edge [ style=invis]
// set up canks (rows)
{rank=same 0-> 1-> 2-> 3}
{rank=same 4-> 5-> 6-> 7}
{rank=same 8-> 9-> 10-> 11}
{rank=same 12-> 13-> 14-> 15}
// set up files (columns)
{ 0-> 4-> 8-> 12}
{ 1-> 5-> 9-> 13}
{ 2-> 6-> 10-> 14}
{ 3-> 7-> 11-> 15}
edge [constraint=false style=solid]
0->2
2->5
5->3
5->7
3->4
7->8
4->15
15->12
15->13
12->11
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.