I had a bad time last night trying to draw a graph for a tree representation of a game. My researches to find a usable tool to draw graphs, preferably a GUI editor, have been unsucessful so far. I was reluctant to use Pstricks even though this was probably the best way to achieve high quality graphics under Latex. Still, I decided to give it a try again. Here is how I did it: Use \usepackage{pstricks,pst-node,pst-tree} in the preamble, then call
\pstree[]{\Tcircle{8}} { ... }
to start a new tree with a root node labeled “8″. Then a subtree can be added by using the same structure in this last piece of code.
\pstree[]{\Tcircle{8}} { \pstree{ \Tcircle{7} \tlput{Label 1}}{ ... } ... }
\Tcircle can be replaced by \TR if you want get rid of the circle around the label. Also, \tlput was used to label an edge. For the details, you should read the doc or see this document “Create Trees and Figures in Graph Theory with PSTricks” .
Here comes the part where I ran into troubles. First of, I was not able to produce any graph even using the examples from the doc. The problem turned out to come from my Latex “editor” ie. a plugin for gedit. Something must go wrong with the way it calls the underlying Latex compiler or a problem occurs during the conversion to postscript or pdf. So if it fails for you also, do it by hand :
latex mytree.tex
dvips mytree.dvi
ps2pdf mytree.psThen you can include the pdf into another latex document using the \usepackage{graphicx} package this way:
\begin{landscape} \begin{figure} \begin{center} \includegraphics[scale=0.85]{mytree.pdf} \end{center} \end{figure} \end{landscape}
Here the landscape command, part of \usepackage{lscape}, is used because our graph fits better with this orientation.
The next problem I’ve been puzzling with was a simple but frustating one: how can you make your graph fit the page ? ! The solution is in the \scalebox command from pstricks. It can be used like this:
\scalebox{0.75}{ \begin{pspicture}(18,0)(0,0) { ... } ... }
Hope you will save a few minutes (hours) with this. See the code I attached to this post for testing.