# Forcefully draw edges on top of each other

**URL:** <https://forum.graphviz.org/t/forcefully-draw-edges-on-top-of-each-other/266>\
**Category:** Uncategorized\
**Created:** [July 20, 2020, 1:21pm UTC](https://forum.graphviz.org/t/forcefully-draw-edges-on-top-of-each-other/266 "2020-07-20T13:21:46Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [July 23, 2020, 1:29am UTC](https://forum.graphviz.org/t/forcefully-draw-edges-on-top-of-each-other/266/4 "2020-07-23T01:29:05Z")

</div>

[NOTE: I am not a Graphviz developer, just a “friend of the family”. I don’t speak for the developers]  
Cool, I think you found a fascinating “accidental” result of a complex set of algorithms. Not documented that I know of, but not necessarily a bug. A gray area.  
But can you depend on it, probably, but let me suggest a “more” legal alternative.  
The basic idea is :

1. you define the complete graph _excluding_ all the “on-top” edges
2. run it through dot with this command: **dot -Tdot myfile.gv \>myfile.dot**
3. you modify (edit) **myfile.dot** duplicating the “bottom” edges to create the “top” edges

- change attribute values ( **color, penwidth, style, …** ) as needed
- this process can be done manually (see below), with any programming language, or with the Graphviz **GVPR** language  
Then run the edited myfile.dot through this command: **neato -n2 -Tpng myfie.dot \>myfile.png** (note the **-n2** option)  
The FAQ has a section that helps explain, as does the documentation on **dot** as an output file format  
Here is an example of the result of step 3:  
graph {  
graph [bb=“0,0,252,108”];  
node [label="\N"];  
A [height=0.5,  
pos=“27,90”,  
width=0.75];  
X [height=0.5,  
pos=“81,18”,  
width=0.75];  
A:e – X:w [color="#000000",  
penwidth=9.0,  
pos=“55,90 71.006,90 36.994,18 53,18”];  
// duplicated by hand  
A:e – X:w [color="#ff00ff",  
penwidth=3.0,  
pos=“55,90 71.006,90 36.994,18 53,18”];  
B [height=0.5,  
pos=“99,90”,  
width=0.75];  
Y [height=0.5,  
pos=“153,18”,  
width=0.75];  
B:e – Y:w [color="#000000",  
penwidth=9.0,  
pos=“127,90 143.01,90 108.99,18 125,18”];  
// again  
B:e – Y:w [color="#ffff00",  
penwidth=3.0,  
pos=“127,90 143.01,90 108.99,18 125,18”];  
C [height=0.5,  
pos=“171,90”,  
width=0.75];  
Z [height=0.5,  
pos=“225,18”,  
width=0.75];  
C:e – Z:w [color="#000000",  
penwidth=9.0,  
pos=“199,90 215.01,90 180.99,18 197,18”];  
// number 3  
C:e – Z:w [color="#00ffff",  
penwidth=3.0,  
pos=“199,90 215.01,90 180.99,18 197,18”];  
}

Convoluted, yes. But definitely within the bounds of legal.  
If you decide to try this, you could add “extra” attributes to the edges you wanted to duplicate like dup\_pen=3 and dupcolor=blue (documented as legal). to give instructions to your script.

---

_[View the full topic](https://forum.graphviz.org/t/forcefully-draw-edges-on-top-of-each-other/266)._
