Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz Dot vertical alignment of nodes

Tags:

graphviz

dot

I got this dot graph and want the nodes A and D, B and E and C and F to be aligned. Here is the related dot code:

digraph{

A
B
C
D
E
F

{rank = same; B; C}
{rank = same; E; F}

A -> B [label="2", weight=2]
A -> C [label="0", style=dashed, weight=2]
B -> C [label="0", style=dashed, weight=2]
B -> D [label="2", style=dashed, weight=2]
C -> D [label="0", weight=2]
D -> E [label="1", style=dashed, weight=2]
D -> F [label="0", weight=2]
E -> F [label="0", weight=2]
F -> A
}

As you can see I already tried to apply weights to the edges, but that didn't work out

enter image description here

like image 687
user1839433 Avatar asked Nov 23 '14 16:11

user1839433


People also ask

What is vertical misalignment?

Vertical heterophoria (VH) is a type of binocular vision dysfunction (BVD) resulting from a vertical misalignment of the eyes. Vertical heterophoria occurs when one eye is slightly misaligned, resulting in serious vision problems.

How does vertical alignment work?

The vertical-align property in CSS controls how elements set next to each other on a line are lined up. In order for this to work, the elements need to be set along a baseline. As in, inline (e.g. <span> , <img> ) or inline-block (e.g. as set by the display property) elements.

What are vertical alignments?

WHAT IS VERTICAL ALIGNMENT? According to Dr. Jason Perez, “Vertical alignment is the process of organizing curriculum from one grade level or content area to the next.” The standards are a great place to begin, though not flawless.


1 Answers

It is possible to use the group attribute of the nodes to suggest aligning the edges between nodes of the same group in a straight line.

Declare the nodes with the group attribute:

A [group=g1]
{rank = same; B[group=g2]; C[group=g3]}
D [group=g1]
{rank = same; E[group=g2]; F[group=g3]}

Then make sure all of those nodes have an (invisible) edge between them:

edge[style=invis];
A -> D
B -> E
C -> F

Everything together:

digraph G {
  A [group=g1]
  {rank = same; B[group=g2]; C[group=g3]}
  D [group=g1]
  {rank = same; E[group=g2]; F[group=g3]}

  A -> B [label="2", weight=2]
  A -> C [label="0", style=dashed, weight=2]
  B -> C [label="0", style=dashed, weight=2]
  B -> D [label="2", style=dashed, weight=2]
  C -> D [label="0", weight=2]
  D -> E [label="1", style=dashed, weight=2]
  D -> F [label="0", weight=2]
  E -> F [label="0", weight=2]
  F -> A

  edge[style=invis];
  A -> D
  B -> E
  C -> F
}

Graphviz diagram

like image 140
marapet Avatar answered Oct 16 '22 07:10

marapet