1

I am very new to Graphviz and trying to create an family tree. I have written this DOT format for my experimentation purposes.

digraph {
  graph [splines=ortho]
  edge [dir=none]

  a [label="a"]
  b [label="b"]
  mid [shape=point]
  {rank = same; a, b, mid}
  a -> mid 
  mid -> b

  c [shape=point]
  cl [shape=point]
  cr [shape=point]
  {rank = same; c, cl, cr} 

  mid -> c
  cl -> c
  c -> cr

  e [label="e"]
  d [label="d"]

  cl -> e
  cr -> d
}

And this is how it comes out to be:

enter image description here

If you notice carefully, the edges to nodes 'e' & 'd' are not in middle. What would you write if you would want it in the middle? for example ,Can I use following formula?

splines=false/true 
RF1991
  • 2,037
  • 4
  • 8
  • 17
Hemant Bhargava
  • 3,251
  • 4
  • 24
  • 45

1 Answers1

0

Nope, splines=false/true just gives a syntax error. (Or did I misunderstand the question?)

Try to avoid splines=ortho. The ortho implementation is rather buggy - sometimes it works, but often not. (It might well work here, I did not check)

The important change to you code is using the group attribute (https://graphviz.org/docs/attrs/group/). It will usually line up nodes in the non-rankdir direction. Most of the other changes were just to make things more readable - to me.

digraph {
  graph [splines=false ]   //ortho] 
  edge [dir=none]

  {rank = same;
    a  
    b  
    mid [shape=point]
    a -> mid  
    mid -> b  
  }
  
  {rank = same
    node [shape=point]
    c cl [group=A1]  cr  [group=A3]
  }

  {rank = same
    e [group=A1] 
    d [group=A3] 
  }

  mid  -> c  
  cl -> c
  c  -> cr
  
  cl -> e  
  cr -> d 
}

Giving:
enter image description here

sroush
  • 5,375
  • 2
  • 5
  • 11