GraphViz: How to connect a node within in a subgraph to the sibling node of the subgraph?

StackOverflow https://stackoverflow.com/questions/22602608

  •  19-06-2023
  •  | 
  •  

Question

I am using subgraphs (clusters) in Graphviz. Taking help from this link (GraphViz - How to connect subgraphs?), I am able to connect the subgraphs and nodes with each other. However, there is one issue:

Suppose we have a digraph G, which contains a subgraph "cluster1" and a node "node1". Assume "cluster1" contains a single node "node10". Now, I want to connect "node10" with "node1". I am trying the following code:

digraph G {
    compound=true;
    node1;
    subgraph cluster1 {
        node10->node1;    
    }
}

This is giving the output where "node1" is present inside "cluster1". What I want is to have the "node1" outside the "cluster1" and within digraph G.

Kindly help.

Was it helpful?

Solution

Seems that link creation takes ownership of both ends. Then declaring nodes and link separately will work:

digraph G {
    compound=true;
    node1;
    subgraph cluster1 {
        node10
    }
    node10->node1
}

yields

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top