Same node in two subgraphs

Viewed 467

I want to draw a border around two subgraphs but I have one node that belongs to both.

digraph {
    subgraph cluster_0 {
            color = red

            A -> D
            A -> C
            C -> D
    }

    subgraph cluster_1 {
            color = blue

            B -> C
            B -> E
            C -> E
    }
}

Now C should be part of both Clusters - instead I get this:

C should be part of both subgraphs

1 Answers

There s a difference between tha name / label of a node and its identification. When a node has no name / label ithe identification is taken as name / label.

Not sure if the following is what uou intended (otherwise clarify you question).

digraph {
    subgraph cluster_0 {
            color = red

            A -> D
            A -> C
            C -> D
    }

    subgraph cluster_1 {
            color = blue
            node C2 [label="C"]
            B -> C2
            B -> E
            C2 -> E
    }
}

From the comment of OP (image should be in original question) looks like OP wants something more like:

digraph {
    subgraph cluster_2 {
    color = none;
    node C
    }
    subgraph cluster_0 {
            color = red

            A -> D
            A -> C
            C -> D
    }

    subgraph cluster_1 {
            color = blue

            B -> C
            B -> E
            C -> E
    }
}

this image does not provide the exact picture OP wants but I think a direction and with some ran setting together with some hidden nodes and edges it should give the right picture.

Related