I have a dense tree. I drew it using the forest package. The code is given below. It may be inefficient, but I am looking to move forward with the minimum code disruption possible. The questions I have are:
1. The tree is asymmetric. So, the default alignment is by level. How do I align all leaves at the same level?
2. How do I make some nodes squares while others remain circles?
3. How do I color a path a different color from root to a particular leaf?
4. I use \resizebox to fit the tree in the page. Assuming people who're seeing the tree turn the page into landscape mode, is there a global option I can set to turn all node text vertically?
Any other suggestions/ideas on how to best present this tree are welcome.
\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\geometry{paper=a5paper}
\usepackage{graphics}
\usepackage[T1]{fontenc}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage[toc,page]{appendix}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning}
\usepackage{color,soul}
\usepackage{url}
\usepackage{tikz-qtree}
\usepackage{forest}
\begin{document}
\resizebox{!}{\textheight}{%
\begin{forest} %Figure out how to align edge labels with the edge
for tree={grow=east,circle,draw, align=center}
[\tiny{HP}
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{NB}} %not built
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}} % not built and closed
[\tiny{C},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{HP}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{M}}
[\tiny{HP} %1st line copied for NB and closed. No IP involved here
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
] %Last line copied for NB and closed. No Ip.
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{HP} %1st line copied for NB and closed. No IP involved here
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
]
[\tiny{C},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{HP} %1st line copied for NB and closed. No IP involved here
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{M}}
[\tiny{HP} %1st line copied for NB and closed. No IP involved here
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{HP} %1st line copied for NB and closed. No IP involved here
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}} % not built and open
[\tiny{C},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{HP}
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{M}}
[\tiny{HP} %last line I added
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
] %last line I added
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{HP} %last line I added
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
] %last line I added
]
]
[\tiny{C},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{HP} %last line I added
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
] %last line I added
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{M}}
[\tiny{HP} %last line I added
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
] %last line I added
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{HP} %last line I added
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{NB}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{B}}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
] %last line I added
]
]
]
]
[\tiny{IP},edge label={node[midway,fill=white,font=\scriptsize]{B}} % built
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}} % built and closed
[\tiny{C},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{G}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{M}}
[\tiny{G}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{G}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
[\tiny{C},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{G}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{M}}
[\tiny{G}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{G}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}} % built and Open
[\tiny{C},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{IP}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{M}}
[\tiny{IP}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{IP}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
]
[\tiny{C},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{L}}
[\tiny{IP}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{M}}
[\tiny{IP}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
[\tiny{25},edge label={node[midway,fill=white,font=\scriptsize]{H}}
[\tiny{IP}
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{C}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
[\tiny{G},edge label={node[midway,fill=white,font=\scriptsize]{O}}
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{L}}]
[\tiny{35},edge label={node[midway,fill=white,font=\scriptsize]{H}}]
]
]
]
]
]
]
]
\end{forest}
}
\end{document}