# Adding node between two clusters

**URL:** <https://forum.graphviz.org/t/adding-node-between-two-clusters/1876>\
**Category:** Help\
**Created:** [November 14, 2023, 1:55pm UTC](https://forum.graphviz.org/t/adding-node-between-two-clusters/1876 "2023-11-14T13:55:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sreejith.u](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sreejith.u](https://forum.graphviz.org/u/Sreejith.u)\
**Post date:** [November 14, 2023, 1:55pm UTC](https://forum.graphviz.org/t/adding-node-between-two-clusters/1876/1 "2023-11-14T13:55:58Z")

</div>

![Screenshot 2023-11-14 at 7.25.13 PM](https://global.discourse-cdn.com/graphviz/original/2X/3/31914727ff18e100a7bcce7c98625fb38fcc803f.png)

Is there a way to add node as common between two clusters ? Sample is given in the attached diagram.

If blue is one cluster and brown is another one. I am looking to have node C and D common to both clusters.

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [November 15, 2023, 12:33am UTC](https://forum.graphviz.org/t/adding-node-between-two-clusters/1876/2 "2023-11-15T00:33:58Z")

</div>

_Short_ answer: No, sorry. None of the engines supports overlapping clusters.

_More info_ answer: see this chain of related questions and answers [Subset Diagrams](https://forum.graphviz.org/t/subset-diagrams/1118)

_With a bit of work_ answer (if you want some more challenge in your life):

1. Can you create a resulting graph with the nodes and edges placed where you want them? (Using any layout engine, any number of clusters, any fiddling). (Don’t worry about cluster surround/peripheries yet)
2. If you can get the nodes and edges where you want them, then maybe you can modify the graph to build what you want.

The result of roughly an hour of fiddling:

![oo](https://global.discourse-cdn.com/graphviz/original/2X/c/c0f83bb6de804ec6dcc42846364f88ac720b3346.png)

First, the starting place - using 3 clusters:

```auto
graph V{
  rankdir=LR
  subgraph cluster1{
    graph [style=filled fillcolor="#a0ffff90"]
    a
    b
  }
  subgraph cluster2{
  c d
  }
  subgraph cluster3{
    graph [style=filled fillcolor="#ffbbff60"];
    e f g
  }
  b -- c -- e
  d -- f
  d --g
}

```

Giving:  
 ![vennNew0](https://global.discourse-cdn.com/graphviz/original/2X/e/ebfd739e40947787e9d7b32d818d18a3dd537c92.png)

Then `dot myfile.gv > myfile.dot` - produces input plus positioning of all nodes, edges & clusters.

Finally, I hand-edited the file (fifteen time or so) to remove the 2nd cluster, move those nodes into the 1st cluster, and resized the **bb** (bounding boxes) of the two remaining clusters, producing this:

```auto
graph V {
	graph [bb="0,0,266,230",
		rankdir=LR
	];
	node [label="\N"];
	subgraph cluster1 {
		graph [OLDbb="8,116,78,222"
		      bb="8,60,172,222" style=filled fillcolor="#a0ffff90"];
		a	[height=0.5,
			pos="43,196",
			width=0.75];
		b	[height=0.5,
			pos="43,142",
			width=0.75];

		c	[height=0.5,
			pos="133,142",
			width=0.75];
		d	[height=0.5,
			pos="133,88",
			width=0.75];
	}
	subgraph cluster3 {
		graph [OLDbb="188,8,258,168"
			bb="100,8,258,168" style=filled fillcolor="#ffbbff60"];
		e	[height=0.5,
			pos="223,142",
			width=0.75];
		f	[height=0.5,
			pos="223,88",
			width=0.75];
		g	[height=0.5,
			pos="223,34",
			width=0.75];
	}
	b -- c	[pos="70.403,142 81.541,142 94.48,142 105.62,142"];
	c -- e	[pos="160.4,142 171.54,142 184.48,142 195.62,142"];
	d -- f	[pos="160.4,88 171.54,88 184.48,88 195.62,88"];
	d -- g	[pos="153.53,76.016 168.11,67.067 187.95,54.892 202.52,45.951"];
}

```

Finally to produce a finished graph `neato -n2 myfile.dot -Tpng >myfile.png` (see [FAQ | Graphviz](https://graphviz.org/faq/#FaqDotWithCoords))
