How to set edge trajectory

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:

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:

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?

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

Does this A program to "fix" simple edges help?

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:

/////////////////////////////////////////////////////////
// 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:

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


I need something in between neato -n1 and neato -n2

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

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

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

your script works without errors but gets only comments:

/////////////////////////////////////////////////////////
// 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 <

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

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