1

I'm using xy package to draw a simple graph representation. How can I add the labels to the egdes?

Here is the code I've produced so far:

\xygraph{
!{<0cm,0cm>;<1cm,0cm>:<0cm,1cm>::}
!{(0,1) }*+{\bullet_{r}}="r"
!{(3,0) }*+{\bullet_{k1}}="k1"
!{(4,1) }*+{\bullet_{a}}="a"
!{(2,1) }*+{\bullet_{b}}="b"
!{(3,2) }*+{\bullet_{c}}="c"
!{(2,3) }*+{\bullet_{d}}="d"
!{(1,2) }*+{\bullet_{e}}="e"
"k1":"a" "k1":"b"
"b":"c" "a":"c"
"b":"r"
"c":"d" "d":"e"
"e":"b"
}
4

For the record:

There are a few possibilities to add labels to edges.

  • "a":"b"^{e_1} adds the label above the edge (above as when going from a to b)
  • "a":"b"_{e_1} adds the label below the edge
  • "a":"b"|{e_1} adds the label on the edge

When placing a label on the edge itself, it makes sense to do it like "a":"b"|*+{e_1}, as this ensures the edge is broken and the text easily readable.

You could also change the position of the label using "a":"b"^(0.2){e_1}, which places the label 20 % into the edge. This works with all three ways.

It is amazing what you can do using xypic once you begin to understand it - which I am far away from...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.