topnush
I am trying to draw a tree with edge labels. This is failing attempt so far:


\documentclass{standalone}
\usepackage{forest}

\begin{document}

\begin{forest}
label tree,
for tree={
circle,draw,
s sep'=10pt,
edge+=thick,
font=\strut\footnotesize\sffamily,
},
[root
[10,edge label={node[midway,left,font=\scriptsize]{(10,10)}}]
[0,edge label={node[midway,left,font=\scriptsize]{(0,10)}}]
[,edge label={node[midway,right,font=\scriptsize]{(9,9)}}

[9, edge label={node[midway,right,font=\scriptsize]{(10,10)}}]
]
[,edge label={node[midway,font=\scriptsize]{(3,3)}}]
[,edge label={node[midway,font=\scriptsize]{(2,2)}}]
[7,edge label={node[midway,font=\scriptsize]{(7,9)}}]
]
\end{forest}

\end{document}


I get errors:

Paragraph ended before \forestset was complete. \end{forest}

Extra }, or forgotten \endgroup. \end{forest}

Package pgfkeys Error: I do not know the key '/tikz/label tree' and I am going to ignore it. Perhaps you misspelled it. \end{forest}

Also, the edge labels are much too big and overlap each other. I would ideally like the labels to be small and maybe run along the edge?

Ultimately the picture I would like to draw is:

![drawing.png](/image?hash=02a6c03beb9dd987b3dee031a0c9543e04301bb0bd6d07ae07b6506ef78713f2)

Of course the circles should all be the same size as should the fonts (node labels all the same, the edge labels can be smaller than the node labels) and everything should be aligned properly.


samcarter
Like @निरंजन already said, don't leave empty lines in trees.

Besides this I suggest:

- to use sloped for the labels to make them easier to read
- increase the vertical distance with l sep to get a bit more space to place the labels
- manually adding a couple of phantom notes to get more homogeneous spacing in the second row


\documentclass{standalone}
\usepackage{forest}

\tikzset{mylabel/.style={midway,font=\tiny,above,sloped}}

\begin{document}

\begin{forest}
%label tree,
for tree={
circle,
draw,
edge+=thick,
l sep=10mm,
minimum width=2em,
minimum height=2em,
inner sep=0pt,
font=\strut\footnotesize\sffamily,
},
[root
[10,edge label={node[mylabel,very near end]{(10,10)}}]
[,phantom]
[0,edge label={node[mylabel,near end]{(0,10)}}]
[,phantom]
[,edge label={node[mylabel,near end]{(9,9)}}
[9, edge label={node[mylabel]{(10,10)}}]
[, edge label={node[mylabel]{(6,6)}}
[8, edge label={node[mylabel]{(10,10)}}]
[5, edge label={node[mylabel]{(7,10)}}]
]
[6, edge label={node[mylabel]{(7,10)}}]
]
[,edge label={node[mylabel,near end]{(3,3)}}
[4, edge label={node[mylabel]{(5,10)}}]
[3, edge label={node[mylabel]{(4,10)}}]
]
[,edge label={node[mylabel,near end]{(2,2)}}
[2, edge label={node[mylabel]{(3,10)}}]
[1, edge label={node[mylabel]{(2,10)}}]
]
[,phantom]
[7,rectangle,edge label={node[mylabel,very near end]{(7,10)}}]
]
\end{forest}

\end{document}

![document.png](/image?hash=bd571493e9504bb7b1f4d95d650f0a8692fa453a8108e329e68dc55a618bab7b)


Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.