Search code examples
graphnodesgraphvizedges

graphviz - reduce distance of node inside cluster (but keep them aligned)


I currently have this cluster:

imag1 .

describe as following:

    subgraph cluster_Step0 {
    compound=true;
    style=filled;
    color=blue;

    start_Step0[color=black, fontsize=8, width=0.3, style=filled, shape=point];
    ver_Step0[color=green, fontsize=10, width=4, height=1, style=filled, shape=rectangle];
    action_Step0[color=red, fontsize=10, width=4, height=1, style=filled, shape=rectangle];
    end_Step0[color=white, fontsize=8, width=0.3, style=filled, shape=point];

    // Align
    start_Step0, ver_Step0, action_Step0, end_Step0 [group = Step0]

    // Connection within the node

    start_Step0 -> ver_Step0;
    ver_Step0 -> action_Step0;
    action_Step0 -> end_Step0;

    // node label
    label = "Step0";

    // VERIFICATION in node
    ver_Step0[label="<>"]

    // ACTION in node
    action_Step0[label="PRECONDITION"]
    }

. I want to make the graph significantly more "dense". something like this:

Fig2

I've tried with ranksep but nothing moved. Any suggestions? thx


Solution

  • I added graph [ranksep=.1] and it produced this:
    enter image description here
    Did you add the ranksep attribute at a graph level?

    digraph {
      graph [ranksep=.1]
       subgraph cluster_Step0 {
        compound=true;
        style=filled;
        color=blue;
    
        start_Step0[color=black, fontsize=8, width=0.3, style=filled, shape=point];
        ver_Step0[color=green, fontsize=10, width=4, height=1, style=filled, shape=rectangle];
        action_Step0[color=red, fontsize=10, width=4, height=1, style=filled, shape=rectangle];
        end_Step0[color=white, fontsize=8, width=0.3, style=filled, shape=point];
    
        // Align
        start_Step0, ver_Step0, action_Step0, end_Step0 [group = Step0]
    
        // Connection within the node
    
        start_Step0 -> ver_Step0;
        ver_Step0 -> action_Step0 
        action_Step0 -> end_Step0;
    
        // node label
        label = "Step0";
    
        // VERIFICATION in node
        ver_Step0[label="<>"]
    
        // ACTION in node
        action_Step0[label="PRECONDITION"]
        }
    }