LaTeX forum ⇒ Graphics, Figures & TablesTree Traversal Diagram

Information and discussion about graphics, figures & tables in LaTeX documents.
Posts: 2
Joined: Mon Jul 15, 2013 1:54 pm

Tree Traversal Diagram

Postby sourlife » Mon Jul 15, 2013 2:10 pm

Dear community,

I'm having trouble drawing an Euler traversal of a tree. You can see an example of an Euler traversal on the picture on the corrsponding wiki page.

As an example, I have the following simple tree:

  1. \pstree{\Tc[name=n1]{3pt}\nput{90}{\pssucc}{$1$}}{%
  2. \Tc{name=n2]{3pt}\nput{270}{\pssucc}{$2$}%
  3. \Tc{name=n3]{3pt}\nput{270}{\pssucc}{$3$}%
  4. }%

I would like to draw an Euler path around it. I tried to do something like this:
  1. \ncline[linestyle=dashed,offset=-5pt]{n1}{n2}
  2. \ncline[linestyle=dashed,offset=5pt]{n1}{n2}

but have no idea on how to then connect the endpoints of these two lines in order to make an arc below node 2.

I thought that one solution would be to somehow declare a new node at these two endpoints. That would make it easy then by using the \nccurve command, but I do not know how to declare new nodes for these endpoints.

Another problem of course is the second \ncline. Its starting point should actually be below the root node (node 1), so that I can continue from that point to the other node (node 3).

Does anyone have a solution or an example of how to draw tours or point me to the right direction how to do it?

Thank you!


Posts: 4
Joined: Wed May 29, 2013 11:29 am

Postby dicker2 » Sat Jul 20, 2013 1:35 pm


have you taken a look at tikz-qtree? It makes tree building slightly easier and allows e.g. lines between nodes. The tikz-qtree manual on page 6 shows something remotely similar to what you want to do.

If all fails, draw it manually in Inkscape?

Best wishes

Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 6 guests