# How to align loose nodes beside the main graph?

**URL:** <https://forum.graphviz.org/t/how-to-align-loose-nodes-beside-the-main-graph/429>\
**Category:** Uncategorized\
**Created:** [November 10, 2020, 3:43pm UTC](https://forum.graphviz.org/t/how-to-align-loose-nodes-beside-the-main-graph/429 "2020-11-10T15:43:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hans](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@hans](https://forum.graphviz.org/u/hans)\
**Post date:** [November 10, 2020, 3:43pm UTC](https://forum.graphviz.org/t/how-to-align-loose-nodes-beside-the-main-graph/429/1 "2020-11-10T15:43:38Z")

</div>

My code creates following output:

 ![sample](https://global.discourse-cdn.com/graphviz/original/1X/37e3f533a6378ebf9dc25c072b26758555fae41e.png)

But I want the the rectangular boxes to be placed beside the graph one below the other

Does anyone have an idea how to achive that? Setting packmode to array\_2 brings me a little bit closer to my goal but it removes the edge labels. I tried a lot with rank and size/ratio but that didn’t work as well.

```
digraph config
{

#packmode="array_c2";

Init [style=filled,fillcolor="#80bfff"]
foo [shape=box, label="Line1_TextTextText\lLine2_TextTextText\lLine3_TextTextText\lLine4_TextTextText\l"]
bar [shape=box, label="Line1_TextTextText\llLine2_TextTextText\lLine3_TextTextText\lLine4_TextTextText\l"]
bar2 [shape=box, label="Line1_TextTextText\llLine2_TextTextText\lLine3_TextTextText\lLine4_TextTextText\l"]

Init -> 1

1 -> 2[label=<
	<I>Block 1 </I><BR/>
		<FONT COLOR="gray"> T2 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> T3 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A2 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A3 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A4 </FONT><BR ALIGN="LEFT"/>
>]
2 -> 3[label=<
	<I>Block 3 </I><BR/>

		<FONT COLOR="gray"> T2 </FONT><FONT COLOR="#ff4d4d">Else</FONT><BR ALIGN="LEFT"/>
>]
2 -> 3[label=<
	<I>Block 2 </I><BR/>
		<FONT COLOR="gray"> A2 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A3 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A4 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A5 </FONT><BR ALIGN="LEFT"/>
>]

3 -> 4[label=<
	<I>Block 4 </I><BR/>
		<FONT COLOR="gray"> A2 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A3 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A4 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A5 </FONT><BR ALIGN="LEFT"/>
>]

4 -> 1

}
```

---

<div class="post-metadata">

**Author:** ![hans](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@hans](https://forum.graphviz.org/u/hans)\
**Post date:** [November 10, 2020, 3:44pm UTC](https://forum.graphviz.org/t/how-to-align-loose-nodes-beside-the-main-graph/429/2 "2020-11-10T15:44:14Z")

</div>

So should it look like:

 ![sample2](https://global.discourse-cdn.com/graphviz/original/1X/e282f435d619c41a3b45dcc556e9812766749506.png)

---

<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 10, 2020, 7:17pm UTC](https://forum.graphviz.org/t/how-to-align-loose-nodes-beside-the-main-graph/429/3 "2020-11-10T19:17:36Z")

</div>

Add some invisible edges, like so:

```
digraph config
{
 Init [style=filled,fillcolor="#80bfff"]
foo [shape=box, label="Line1_TextTextText\lLine2_TextTextText\lLine3_TextTextText\lLine4_TextTextText\l"]
bar [shape=box, label="Line1_TextTextText\llLine2_TextTextText\lLine3_TextTextText\lLine4_TextTextText\l"]
bar2 [shape=box, label="Line1_TextTextText\llLine2_TextTextText\lLine3_TextTextText\lLine4_TextTextText\l"]

Init -> 1

1 -> 2[label=<
	<I>Block 1 </I><BR/>
		<FONT COLOR="gray"> T2 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> T3 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A2 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A3 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A4 </FONT><BR ALIGN="LEFT"/>
>]
2 -> 3[label=<
	<I>Block 3 </I><BR/>

		<FONT COLOR="gray"> T2 </FONT><FONT COLOR="#ff4d4d">Else</FONT><BR ALIGN="LEFT"/>
>]
2 -> 3[label=<
	<I>Block 2 </I><BR/>
		<FONT COLOR="gray"> A2 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A3 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A4 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A5 </FONT><BR ALIGN="LEFT"/>
>]

3 -> 4[label=<
	<I>Block 4 </I><BR/>
		<FONT COLOR="gray"> A2 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A3 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A4 </FONT><BR ALIGN="LEFT"/>
		<FONT COLOR="gray"> A5 </FONT><BR ALIGN="LEFT"/>
>]

4 -> 1
edge[style=invis]
foo -> bar -> bar2
}

```

Giving:

 ![vertNodes1](https://global.discourse-cdn.com/graphviz/original/1X/04034bcf1214f72d09aa1a16a9996f99fbaacc84.png)

---

<div class="post-metadata">

**Author:** ![hans](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@hans](https://forum.graphviz.org/u/hans)\
**Post date:** [November 11, 2020, 10:25am UTC](https://forum.graphviz.org/t/how-to-align-loose-nodes-beside-the-main-graph/429/4 "2020-11-11T10:25:46Z")

</div>

Thank you! Quite good idea I would never hit on 🙂  
In this case the nodes are placed line by line regardless of the lines of the edge-labels. Is there any way to break this behaviour?

---

<div class="post-metadata">

**Author:** ![hans](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@hans](https://forum.graphviz.org/u/hans)\
**Post date:** [November 11, 2020, 10:55am UTC](https://forum.graphviz.org/t/how-to-align-loose-nodes-beside-the-main-graph/429/5 "2020-11-11T10:55:16Z")

</div>

Unfortunately the result applied on my data still isn’t what I want:

 ![result_pixeled](https://global.discourse-cdn.com/graphviz/original/1X/b3c16cada99ae2d8794eba50cf984c4e87722a76.jpeg)  
The second column should not care about the edge lables in the first column…

Otherwise it is not mandatory that the loose nodes are placed in a second column.  
Also a nice placement independent of the connected nodes would also be a solution.

Edit: I think I found a solution I can live with.

Just place the table like node in

```
{
rank=sink
"TABLE"
}

```

changes everything from

 ![solution2](https://global.discourse-cdn.com/graphviz/original/1X/84eaa072cdb10b1e231da9b16e5cc3dcdb6ffbb1.png)  
to  
 ![solution1](https://global.discourse-cdn.com/graphviz/original/1X/701bab757175d05a73029cb49c6841713d1161f9.png)

I just wonder why the rank of the table affects the look of the main graph.  
In bigger graphs it looks quite awful: 😭

 ![sol3](https://global.discourse-cdn.com/graphviz/original/1X/de9fc512d919d0fadfa0a3aa70c8c892f676aba6.png)
