I have the following code, and it results in the image below. As you can see, it's a little crowded around the edges and edge labels, especially around the "^a". What is the best way to create just a tad more space, so that one can clearly see which label belongs to which edge?
digraph finite_state_machine {
pad=0.2;
{
rank=same;
node [shape = point, style = invis]; q_0;
node [shape = doublecircle, style = solid]; q_5;
node [shape = circle];
q_1 [ label = <<i>q<sub>1</sub></i>> ];
q_2 [ label = <<i>q<sub>2</sub></i>> ];
q_3 [ label = <<i>q<sub>3</sub></i>> ];
q_4 [ label = <<i>q<sub>4</sub></i>> ];
q_5 [ label = <<i>q<sub>5</sub></i>> ];
q_0 -> q_1;
q_1 -> q_2 [ label = "." ];
q_1 -> q_2 [ label = <ε>, constraint=false ];
q_2 -> q_1 [ label = <ε>, constraint=false ];
q_2 -> q_3 [ label = <<i>a</i>> ];
q_3 -> q_4 [ label = <<i>^a</i>> ];
q_3 -> q_4 [ label = <ε>, constraint=false ];
q_4 -> q_3 [ label = <ε>, constraint=false ];
q_4 -> q_5 [ label = <<i>b</i>> ];
}
}
There is no attribute in Graphviz to adjust the margin/padding around edge labels. The closest you can probably get to the effect you require is to use \n
to introduce blank lines above/below your label to force space.
Obviously, this will not scale to anything automatic.
Alternately, you could try to use the ranksep
attribute to force in some additional space.
I know this is an old question, but this approach below might also be helpful, if this is what you are looking for. see the image below. i added the following to your code:
minlen=2 (to extend gaps between nodes)
tailport=n/s (to change location of the tail of the arrow to north/south)
headport=n/s (to change location of the head to the arrow to north or south)
digraph finite_state_machine {
pad=0.2;
{
rank=same;
node [shape = point, style = invis]; q_0;
node [shape = doublecircle, style = solid]; q_5;
node [shape = circle];
q_1 [ label = <<i>q<sub>1</sub></i>> ];
q_2 [ label = <<i>q<sub>2</sub></i>> ];
q_3 [ label = <<i>q<sub>3</sub></i>> ];
q_4 [ label = <<i>q<sub>4</sub></i>> ];
q_5 [ label = <<i>q<sub>5</sub></i>> ];
q_0 -> q_1;
q_1 -> q_2 [ label = "." ];
q_1 -> q_2 [ label = <ε>, constraint=false, minlen=2, tailport=n, headport=n];
q_2 -> q_1 [ label = <ε>, constraint=false, minlen=2, tailport=s, headport=s];
q_2 -> q_3 [ label = <<i>a</i>> ];
q_3 -> q_4 [ label = <<i>^a</i>> ];
q_3 -> q_4 [ label = <ε>, constraint=false, minlen=2, tailport=n, headport=n];
q_4 -> q_3 [ label = <ε>, constraint=false, minlen=2, tailport=s, headport=s];
q_4 -> q_5 [ label = <<i>b</i>> ];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With