LaTeX forum ⇒ Graphics, Figures & TablesNodes and edges labes Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
vejn
Posts: 8
Joined: Wed Jan 30, 2013 12:59 pm

Nodes and edges labes

Postby vejn » Mon Nov 17, 2014 10:48 am

I need labes of edges in tikz example on page. There is only one edge with label
  1. $x$
. Could some help me to label others. I need this today.
Thanks
http://www.texample.net/tikz/examples/red-black-tree/
  1. \begin{tikzpicture}[->,>=stealth',level/.style={sibling distance = 5cm/#1,
  2. level distance = 1.5cm}]
  3. \node [arn_n] {33}
  4. child{ node [arn_r] {15}
  5. child{ node [arn_n] {10}
  6. child{ node [arn_r] {5} edge from parent node[above left]
  7. {$x$}} %for a named pointer
  8. child{ node [arn_x] {}}
  9. }
  10. child{ node [arn_n] {20}
  11. child{ node [arn_r] {18}}
  12. child{ node [arn_x] {}}
  13. }
  14. }
  15. child{ node [arn_r] {47}
  16. child{ node [arn_n] {38}
  17. child{ node [arn_r] {36}}
  18. child{ node [arn_r] {39}}
  19. }
  20. child{ node [arn_n] {51}
  21. child{ node [arn_r] {49}}
  22. child{ node [arn_x] {}}
  23. }
  24. }
  25. ;
  26. \end{tikzpicture}

Tags:

User avatar
Stefan Kottwitz
Site Admin
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Feb 23, 2015 3:20 pm

It's already a long time ago, but as I don't like to leave a problem unsolved, here's a way: simply add

edge from parent node[above left] {your label}

directly after a child node, such as

  1. ...
  2. child{ node [arn_r] {49} edge from parent node[above left] {$y$}}
  3. ...


tikz-tree.png
tikz-tree.png (17.71 KiB) Viewed 3240 times


If a Infominimal working example would have been posted, I'm pretty sure somebody would have tested it to provide a solution. For example, the styles arn_r, arn_n and arn_x are unknown, I had to follow the link to example.net to get the code from there.

Stefan
Site admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 11 guests