# Edge drawing order

**URL:** <https://forum.graphviz.org/t/edge-drawing-order/86>\
**Category:** Help\
**Created:** [May 4, 2020, 4:43pm UTC](https://forum.graphviz.org/t/edge-drawing-order/86 "2020-05-04T16:43:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.valaki](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@peter.valaki](https://forum.graphviz.org/u/peter.valaki)\
**Post date:** [May 4, 2020, 4:43pm UTC](https://forum.graphviz.org/t/edge-drawing-order/86/1 "2020-05-04T16:43:37Z")

</div>

I’m trying to create a graph with certain edges on top of others based on a given value.

 ![image](https://global.discourse-cdn.com/graphviz/original/1X/d1d0970fc70008e0151ec060652fa223442ce1c5.png)  
I want the yellow edges to be on top, but it seems like the drawing order is determined by the order of the nodes.  
I’ve already tried ordering the edge definition based on the drawing order, but that did not affect anything. Is it possible to somehow influence the order in which edges are drawn so that certain edges are always on top?  
(Basically what I’m trying to do, is create a graph with several coloured “layers”, with certain colours always being above others. For instance, all yellows are at the top, oranges below that, and so on.)

---

<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:** [May 4, 2020, 6:25pm UTC](https://forum.graphviz.org/t/edge-drawing-order/86/2 "2020-05-04T18:25:30Z")

</div>

I haven’t tried this yet, but the **outputorder** graph attribute set to **nodesfirst** should help. That and ordering the nodes by color.

---

<div class="post-metadata">

**Author:** ![Ellson](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/ellson/32/19_2.png) [@Ellson](https://forum.graphviz.org/u/Ellson)\
**Post date:** [May 5, 2020, 5:34pm UTC](https://forum.graphviz.org/t/edge-drawing-order/86/3 "2020-05-05T17:34:28Z")

</div>

Neato has an option of leaving node position info untouched and just laying out edges. So you could try:

- use dot to provide an initial complete layout, as you have now, but output in DOT format.
- use gvpr to split the layout into 3 graphs: nodes with position, black edges, yellow edges.
- use neato to relayout the black edges and the pre-positioned nodes.
- finally use neato to layout the yellow edges and generate desired output format.

Detailed procedure is left to the reader … 😉

---

<div class="post-metadata">

**Author:** ![peter.valaki](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@peter.valaki](https://forum.graphviz.org/u/peter.valaki)\
**Post date:** [May 5, 2020, 7:40pm UTC](https://forum.graphviz.org/t/edge-drawing-order/86/4 "2020-05-05T19:40:21Z")

</div>

Thank you, I’ll try that.
