Originally Posted by
Kcal Can anyone tell me how to display a prime factor tree? For example:
It can be done using the package PGF.
Here is an example :
Code:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[
level 1/.style={sibling distance=20mm},
level 2/.style={sibling distance=10mm},
]
\node{80}
child{node {8}
child{node {2}}
child{node {2}}
child{node {2}}
}
child{node {10}
child{node {2}}
child{node {5}}
};
\end{tikzpicture}
\caption{Simple tree}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[
level 1/.style={sibling distance=40mm},
level 2/.style={sibling distance=20mm},
level 3/.style={sibling distance=10mm}
]
\node[rounded corners, draw]{720}
child{node [rounded corners, draw] {20}
child{node [fill=red!30,rounded corners] {2}}
child{node [rounded corners, draw] {10}
child{node [fill=red!30,rounded corners] {5}}
child{node [fill=red!30,rounded corners] {2}}
}
}
child{node [rounded corners, draw] {36}
child{node [rounded corners, draw] {6}
child{node [fill=red!30,rounded corners] {2}}
child{node [fill=red!30,rounded corners] {3}}
}
child{node [rounded corners, draw] {6}
child{node [fill=red!30,rounded corners] {2}}
child{node [fill=red!30,rounded corners] {3}}
}
};
\end{tikzpicture}
\caption{Elaborated tree}
\end{figure}
\end{document}