# Force straight edges above/through a node

**URL:** <https://forum.graphviz.org/t/force-straight-edges-above-through-a-node/741>\
**Category:** Help\
**Created:** [July 9, 2021, 10:03am UTC](https://forum.graphviz.org/t/force-straight-edges-above-through-a-node/741 "2021-07-09T10:03:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![moviuro](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@moviuro](https://forum.graphviz.org/u/moviuro)\
**Post date:** [July 9, 2021, 10:03am UTC](https://forum.graphviz.org/t/force-straight-edges-above-through-a-node/741/1 "2021-07-09T10:03:27Z")

</div>

Hi all,

I’m trying to write a digraph that would end up generating a graph similar to this SVG: [https://try.popho.be/images/haproxy-tls.svg](https://try.popho.be/images/haproxy-tls.svg) (this was inspired from haproxy’s documentation). At the time, I modified (by hand) the SVG to put straight edges and replace the splines that graphviz put there.

I have tried many things so far: using (at random) other generators instead of `dot`, `splines=line` (which is not actually a straight line, but a succession of straight segments).

I want the edges `client -> dns.google` and `client -> cloudflare-dns.com` to pass over the `haproxy` node (much like the `TLS` edges pass through the `haproxy` node in the submitted example).

```auto
digraph blind_doh_proxy {
  bgcolor=transparent;
/* splines=line; */
  
  client -> "haproxy" [label="TCP to proxy" color="darkgreen" fontsize="9" fontcolor="darkgreen"]
  client -> "haproxy" [label="TCP to proxy" color="indigo" fontsize="9" fontcolor="indigo"]
  
  "haproxy" -> "dns.google" [label="TCP to dns.google" color="darkgreen" fontsize="9" fontcolor="darkgreen"]
  "haproxy" -> "cloudflare-dns.com" [label="TCP to cloudflare-dns.com" color="indigo" fontsize="9" fontcolor="indigo"]
  "haproxy" [weight=10]

  client -> "dns.google" [label="HTTPS to dns.google"]
  client -> "cloudflare-dns.com" [label="HTTPS to cloudflare-dns.com"]

}

```

---

<div class="post-metadata">

**Author:** ![scnorth](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/scnorth/32/89_2.png) [@scnorth](https://forum.graphviz.org/u/scnorth)\
**Post date:** [July 9, 2021, 9:46pm UTC](https://forum.graphviz.org/t/force-straight-edges-above-through-a-node/741/2 "2021-07-09T21:46:29Z")

</div>

It would be (relatively) trivial to hack this.

I also realize now this should be done to try to remediate the situation when the codegen detected “lost U V edge”; at least draw something useful.

---

<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 9, 2021, 10:11pm UTC](https://forum.graphviz.org/t/force-straight-edges-above-through-a-node/741/3 "2021-07-09T22:11:46Z")

</div>

add explicit **pos** values and the run through **neato -n**  
see [FAQ | Graphviz](https://graphviz.org/faq/#FaqDotWithNodeCoords)

```auto
// use neato -n to produce this graph
// see https://graphviz.org/faq/#FaqDotWithNodeCoords
digraph blind_doh_proxy {
  bgcolor=transparent;
  splines=false; 
  // pos values were "eyeballed"
  client [pos="150,200"]
  haproxy [pos="150,130"]     
  "dns.google" [pos="75,30"]
  "cloudflare-dns.com" [pos="240,30"]
  client -> "haproxy" [label="TCP to proxy" color="indigo" fontsize="9" fontcolor="indigo"]
  
  "haproxy" -> "dns.google" [label="TCP to dns.google" color="darkgreen" fontsize="9" fontcolor="darkgreen"]
  "haproxy" -> "cloudflare-dns.com" [label="TCP to cloudflare-dns.com" color="indigo" fontsize="9" fontcolor="indigo"]
  "haproxy" [weight=10]

  client -> "dns.google" [label="HTTPS to dns.google"]
  client -> "cloudflare-dns.com" [label="HTTPS to cloudflare-dns.com"]
}

```

Giving:  
 ![straightEdge2](https://global.discourse-cdn.com/graphviz/original/1X/14a26600d5f5712581222f3301b85f8109fbdf3d.png)

---

<div class="post-metadata">

**Author:** ![erg](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/erg/32/34_2.png) [@erg](https://forum.graphviz.org/u/erg)\
**Post date:** [July 10, 2021, 9:08pm UTC](https://forum.graphviz.org/t/force-straight-edges-above-through-a-node/741/4 "2021-07-10T21:08:09Z")

</div>

Use splines=line and xlabels instead of labels:

```auto
digraph blind_doh_proxy {
  bgcolor=transparent;
  splines=line;

  client -> "haproxy" [xlabel="TCP to proxy"
    color="indigo" fontsize="9" fontcolor="indigo"]

  "haproxy" -> "dns.google" [xlabel="TCP to dns.google" color="darkgreen" fontsize="9" fontcolor="darkgreen"]
  "haproxy" -> "cloudflare-dns.com" [xlabel="TCP to cloudflare-dns.com" color="indigo" fontsize="9" fontcolor="indigo"]

  client -> "dns.google" [xlabel="HTTPS to dns.google"]
  client -> "cloudflare-dns.com" [xlabel="HTTPS to cloudflare-dns.com"]

}

```

I also removed the weight attribute on haproxy, as weights only work on edges, and the duplicate client → haproxy edge.

![out](https://global.discourse-cdn.com/graphviz/original/1X/636c8638ffc72770e5c4875e45120f7a0ecb45d2.png)
