# How to set edge trajectory

**URL:** <https://forum.graphviz.org/t/how-to-set-edge-trajectory/3164>\
**Category:** Help\
**Created:** [August 24, 2025, 2:28pm UTC](https://forum.graphviz.org/t/how-to-set-edge-trajectory/3164 "2025-08-24T14:28:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![FeelUs](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@FeelUs](https://forum.graphviz.org/u/FeelUs)\
**Post date:** [August 24, 2025, 2:28pm UTC](https://forum.graphviz.org/t/how-to-set-edge-trajectory/3164/1 "2025-08-24T14:28:03Z")

</div>

I have 4 nodes in row (A,B,C,D). Let’s say I want to route path A-\>D so that it goes from top of B and bottom of C.  
I’ve tried to do this:

```dot
digraph G {
	A [pos="0,0!", shape=star];
	B [pos="100,0!", shape=circle];
	C [pos="200,0!", shape=circle];
	D [pos="300,0!", shape=box];

	A -> D [
		pos="s,0,0 e,300,0 0,0 \
		0,100 150,100 150,0 \
		150,-100 300,-100 300,0"
	];
}

```

and compile it with `neato -n2 -Tpng tmp.dot -o tmp.png`  
But I get ugly graph:

 ![tmp](https://global.discourse-cdn.com/graphviz/original/2X/9/9e00ce03a19e75bbbf43e397879eb2c73fafa691.png)

**Question:**  
Is there way to draw edge line (using a preset trajectory) so that it doesn’t intersect start and end node’s bodies (and also shows the arrow direction correctly) without manually calculating intersections of curve and node’s bodies?

---

<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:** [August 25, 2025, 6:02pm UTC](https://forum.graphviz.org/t/how-to-set-edge-trajectory/3164/2 "2025-08-25T18:02:40Z")

</div>

You can probably achieve what you want, but no guarantees.

Does this [A program to "fix" simple edges](https://forum.graphviz.org/t/a-program-to-fix-simple-edges/1792) help?

---

<div class="post-metadata">

**Author:** ![FeelUs](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@FeelUs](https://forum.graphviz.org/u/FeelUs)\
**Post date:** [August 25, 2025, 9:32pm UTC](https://forum.graphviz.org/t/how-to-set-edge-trajectory/3164/3 "2025-08-25T21:32:49Z")

</div>

I don’t understand how to use your script.  
I’ve tried add `edge [edgeType=curved];` in dot file and after I run `gvpr -f alterSimpleEdge.gvpr tmp.dot` I get:

```auto
/////////////////////////////////////////////////////////
// DIR: 1
// edge: A->D >s,0,0 e,300,0 0,0 0,100 150,100 150,0 150,-100 300,-100 300,0<<  
// ti: 1 point: 300,0
// ti: 2 point: 300,-100
// ti: 3 point: 150,-100
// ti: 4 point: 150,0
// ti: 5 point: 150,100
// ti: 6 point: 0,100
// ti: 7 point: 0,0
// ti: 8 point: e,300,0
// before: >s,0,0
// after: >e,0,0
//FIXED backwards arrowhead
// 0 e,0,0
// arrowhead : e,0,0
// END: 0 START: 1
// 0 e,0,0 0 0
// 1 300,0
// 1 300,0 300 0
// 2 300,-100
// 2 300,-100 300 -100
// 3 150,-100
// 3 150,-100 150 -100
// 4 150,0
// 4 150,0 150 0
// 5 150,100
// 5 150,100 150 100
// 6 0,100
// 6 0,100 0 100
// 7 0,0
// 7 0,0 0 0
// 8 e,300,0
// arrowhead : e,300,0
// END: 8 START: 1
// 8 e,300,0 300 0
// tail2headDeltaX: 0 tail2headDeltaY: 0
// arrow e 0
// ArrowStart: 1 nextToarrowStart: 2 nextToarrowEnd: 8 arrowEnd: 8
// DISTANCE: 0
// setting edgeOffset to default of 36 points (.5 inches)
gvpr: 
 -- floating divide by 0

```

and I don’t understand what should I do with this.

I expected to get something like this:

```auto
digraph G {
	A [pos="0,0!", shape=star];
	B [pos="100,0!", shape=circle];
	C [pos="200,0!", shape=circle];
	D [pos="300,0!", shape=box];

	A -> D [
		pos="e,298,-15 10,30 \
		30,100 150,100 150,0 \
		150,-100 300,-100 297,-20"
	];
/* pos in source for comparizon:
		pos="s,0,0 e,300,0 0,0 \
		0,100 150,100 150,0 \
		150,-100 300,-100 300,0"
*/
}

```

but more accurate

 ![tmp2](https://global.discourse-cdn.com/graphviz/original/2X/1/1dd3ab4dc477f00686db769c9391637eba9e62a3.png)  
I need something in between `neato -n1` and `neato -n2`

---

<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:** [August 25, 2025, 10:28pm UTC](https://forum.graphviz.org/t/how-to-set-edge-trajectory/3164/4 "2025-08-25T22:28:37Z")

</div>

Oop, division by zero big. Fixable, but I’m away from my computer for another day or two.

Try this

- Define a new point P
- Pos= halfway between b and c
- Shape equals point
- Create two new edges a.n North to p. And p2d.s South
- Then use needle.n2 to finish this off

I think this will work or or at least maybe get you closer

---

<div class="post-metadata">

**Author:** ![FeelUs](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@FeelUs](https://forum.graphviz.org/u/FeelUs)\
**Post date:** [August 26, 2025, 10:46am UTC](https://forum.graphviz.org/t/how-to-set-edge-trajectory/3164/5 "2025-08-26T10:46:58Z")

</div>

with next trajectory (without `s,0,0 e,300,0 0`)

```auto
		pos="0,0 \
		0,100 150,100 150,0 \
		150,-100 300,-100 300,0"

```

your script works without errors but gets only comments:

```auto
/////////////////////////////////////////////////////////
// DIR: 1
// edge: A->D >0,0 0,100 150,100 150,0 150,-100 300,-100 300,0<<  
// 0 0,0
// 0 0,0 0 0
// 1 0,100
// 1 0,100 0 100
// 2 150,100
// 2 150,100 150 100
// 3 150,0
// 3 150,0 150 0
// 4 150,-100
// 4 150,-100 150 -100
// 5 300,-100
// 5 300,-100 300 -100
// 6 300,0
// 6 300,0 300 0
// tail2headDeltaX: 300 tail2headDeltaY: 0
// ArrowStart: 0 nextToarrowStart: 1 nextToarrowEnd: 5 arrowEnd: 6
// DISTANCE: 300
// setting edgeOffset to default of 36 points (.5 inches)
// FINAL Percent: 0.12 Offset: 36
// EDGE DIRECTION: cw
/////////// edgeType: curved
// pointAlongLine new point: 1 -- 0,0 0,300 -- 0,36
// pointAlongLine rslt: 0,36
// 90 rslt: 0,36
// aPoint: 0,36
// newX[2]/newY[2] :0,36
// newX[3]/newY[3] :300,36
// cnt, start, end 7 0 6
// CURVED
// Ac outStr > <
// mkPoint rslt: 0,0 
// mkPoint rslt: 0,36 
// mkPoint rslt: 300,36 
// mkPoint rslt: 300,0 
// B outStr > 0,0 0,36 300,36 300,0 <

```

---

<div class="post-metadata">

**Author:** ![FeelUs](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@FeelUs](https://forum.graphviz.org/u/FeelUs)\
**Post date:** [August 26, 2025, 10:51am UTC](https://forum.graphviz.org/t/how-to-set-edge-trajectory/3164/6 "2025-08-26T10:51:18Z")

</div>

make intermediate invisible nodes - is idea, but if nodes are close each other I still need manually calculate how many intermediate points are enough

---

<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:** [August 27, 2025, 11:13pm UTC](https://forum.graphviz.org/t/how-to-set-edge-trajectory/3164/7 "2025-08-27T23:13:56Z")

</div>

There is no way to partially position an edge. All or nothing.  
Maybe this will help:

> [@Fun with edges!](https://forum.graphviz.org/t/fun-with-edges/888):
>
> Did you know that it takes all the Graphviz engines at least 4 points to define an edge, even a straight edge? ([splineType | Graphviz](https://graphviz.org/docs/attr-types/splineType/)) Not being a mathematician, I don’t know much (anything) about cubic B-spline, so I decided to let Graphviz show me how these splines are defined. I wrote a small GVPR program (what else) to add a point-shaped node on top of every point included in an edge pos for any graph. What did I learn? After staring at hundreds of augmented graphs, splines start to mak…
