I'm attempting to diagram an extensive form game in GraphViz. Compiling the code results in a graph that is correct in all ways except one. I want the "War" label to be placed to the left of the edge it labels, such that the edge is closest to "r" and not "W".
This is my "game" or graph so far:
digraph hierarchy_of_D {
graph [rankdir ="UD"]
node [color=black,shape=circle]
//splines="polyline"
I [label="R"]
subgraph infoset1
{
label="whatever"
rank="same"
1 [label="C"]
2 [label="C"]
}
I -> 1 [label="War"] //fix how this floats right of the line
I -> 2 [label="Peace"]
1 -> 2 [style=dashed, dir=none]
subgraph info21
{
rank="same"
3 [label="(2,2)", rank=sink, shape="plaintext"]
4 [label="(5,1)", rank=sink, shape="plaintext"]
5 [label="(1,5)", rank=sink, shape="plaintext"]
6 [label="(4,4)", rank=sink, shape="plaintext"]
}
1 -> 3 [label="War"]
1 -> 4 [label="Peace"]
2 -> 5 [label="War"]
2 -> 6 [label="Peace"]
}
Any ideas? I've already tried the following, which does not do what I want:
1 -> 3 [label="War/l"]
See also this question and that question, neither of which have an answer. C'mon now, this is worth triple points!
Triple points? Well then, the correct answer is that you cannot choose the placement of edge labels.
However, you may play with headlabel
, labeldirection
and labelangle
:
digraph hierarchy_of_D {
node [color=black,shape=circle]
I [label="R"]
subgraph infoset1
{
label="whatever"
rank="same"
1 [label="C"]
2 [label="C"]
}
I -> 1 [headlabel="War", labeldistance=3, labelangle=40]
I -> 2 [headlabel="Peace", labeldistance=3, labelangle=-40]
1 -> 2 [style=dashed, dir=none]
subgraph info21
{
rank="same"
3 [label="(2,2)", rank=sink, shape="plaintext"]
4 [label="(5,1)", rank=sink, shape="plaintext"]
5 [label="(1,5)", rank=sink, shape="plaintext"]
6 [label="(4,4)", rank=sink, shape="plaintext"]
}
1 -> 3 [headlabel="War", labeldistance=3, labelangle=40]
1 -> 4 [headlabel="Peace", labeldistance=3, labelangle=-40]
2 -> 5 [headlabel="War", labeldistance=3, labelangle=40]
2 -> 6 [headlabel="Peace", labeldistance=3, labelangle=-40]
}
Output:
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