# How to specify ordering of vertically stacked nodes

**URL:** <https://forum.graphviz.org/t/how-to-specify-ordering-of-vertically-stacked-nodes/997>\
**Category:** Help\
**Created:** [January 16, 2022, 7:04pm UTC](https://forum.graphviz.org/t/how-to-specify-ordering-of-vertically-stacked-nodes/997 "2022-01-16T19:04:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MangoMan](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@MangoMan](https://forum.graphviz.org/u/MangoMan)\
**Post date:** [January 16, 2022, 7:04pm UTC](https://forum.graphviz.org/t/how-to-specify-ordering-of-vertically-stacked-nodes/997/1 "2022-01-16T19:04:57Z")

</div>

As a sort of exersize for myself to learn how to make graphs with graphiz, I decided to try to create [this graph](https://git-scm.com/book/en/v2/images/basic-branching-2.png) myself (it’s from the git manual). So far I have managed to get this, but I find myself stuck on trying to properly order the `master`, `c2` and `iss53` nodes. I want them to be vertically stacked in that order, however for whatever reason I can’t seem to do it. This current code gives [this output](https://i.imgur.com/zfDNZJL.png) where both `master` and `iss53` are stacked _above_ `c2` when I want `c2` to be in between them.

Any help would be appreciated.

```auto
digraph {
	rankdir = "RL"
	splines=line

	c2 -> c1 -> c0

	{
		rank=same
		node [style=filled color=red fillcolor=red shape=rectangle fontname=monospace
		      fontcolor=white]
		iss53 -> c2
		master -> c2
	}
}

```

**EDIT:** I have also tried appending the following to the end of my graph:

```auto
edge [style=invis]
c2 -> {master iss53}

```

this _almost_ works except for the fact that the arrows are now curved as [can be seen here](https://i.imgur.com/gcT7pXB.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:** [January 16, 2022, 9:46pm UTC](https://forum.graphviz.org/t/how-to-specify-ordering-of-vertically-stacked-nodes/997/2 "2022-01-16T21:46:25Z")

</div>

Close, just needed tweak to _iss53-\>c2_. Reversed head/tail and used **dir=back** ([dir | Graphviz](https://graphviz.org/docs/attrs/dir/))

```auto
digraph {
	rankdir = "RL"
	splines=line
	node[shape=rect style=rounded] // added
	c2 -> c1 -> c0

	{
		rank=same
		node [style=filled color=red fillcolor=red shape=rectangle
		  fontname=monospace fontcolor=white]
		c2 -> iss53 [dir=back] // dir=back, reverse arrowhead position
		master -> c2
	}
}

```

Giving:  
 ![verticalStack1](https://global.discourse-cdn.com/graphviz/original/1X/9012f4c741bc4fa7890b800d2a7916f645d84b54.png)

---

<div class="post-metadata">

**Author:** ![MangoMan](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@MangoMan](https://forum.graphviz.org/u/MangoMan)\
**Post date:** [January 16, 2022, 9:54pm UTC](https://forum.graphviz.org/t/how-to-specify-ordering-of-vertically-stacked-nodes/997/3 "2022-01-16T21:54:18Z")

</div>

That makes a lot of sense, thanks!
