I want to draw a tree where each edge has a certain weight visualized through both the line width as well as a label on the edge. Using TikZ, this is pretty easy:
\documentclass{standalone}
\usepackage{tikz-qtree}
\begin{document}
\begin{tikzpicture}[
clabel/.style = { fill=white, circle, inner sep=1pt,font=\scriptsize},
]
\Tree [.O
\edge [line width = 2] node [clabel] {2}; L
\edge [line width = 4] node [clabel] {4}; R
]
\end{tikzpicture}
\end{document}
Since the tree I want to draw is rather large, I want to factor out the edge code, i.e. I would like to have a macro like
\def\edgeweight#1{\edge [line width = #1] node [clabel] {#1}; }
Unfortunately, LaTeX complains about the \edge command when I call this macro which I assume is because it appears outside of the \Tree command. Is there a way to fix this?