Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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"
}
share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

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...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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