I had a bad time last night try­ing to draw a graph for a tree rep­re­sen­ta­tion of a game. My researches to find a usable tool to draw graphs, prefer­ably a GUI edi­tor,  have been unsucess­ful so far. I was reluc­tant to use Pstricks even though this was prob­a­bly the best way to achieve high qual­ity graph­ics 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 pre­am­ble, then call

\pstree[]{\Tcircle{8}}
{
...
}

to start a new tree with a root node labeled “8”. Then a sub­tree can be added by using the same struc­ture in this last piece of code.

 \pstree[]{\Tcircle{8}} {
                    \pstree{ \Tcircle{7} \tlput{Label 1}}{
                        ...
                 }
       ...
 }

\Tcir­cle can be replaced by \TR if you want get rid of the cir­cle around the label. Also, \tlput was used to label an edge. For the details, you should read the doc or see this doc­u­ment “Cre­ate Trees and Fig­ures in Graph The­ory with PSTricks” .

Here comes the part where I ran into trou­bles. First of, I was not able to pro­duce any graph even using the exam­ples from the doc. The prob­lem turned out to come from my Latex “edi­tor” ie.  a plu­gin for gedit. Some­thing must go wrong with the way it calls the under­ly­ing Latex com­piler or a prob­lem occurs dur­ing the con­ver­sion to post­script or pdf. So if it fails for you also, do it by hand :

latex mytree.tex
dvips mytree.dvi
ps2pdf mytree.ps

Then you can include the pdf into another latex doc­u­ment using the \usepackage{graphicx} pack­age this way:

\begin{landscape}
\begin{figure}
\begin{center}
\includegraphics[scale=0.85]{mytree.pdf}
\end{center}
\end{figure}
\end{landscape}

Here the land­scape com­mand, part of \usepackage{lscape}, is used because our graph fits bet­ter with this orientation.

The next prob­lem I’ve been puz­zling with was a sim­ple but frus­tat­ing one: how can you make your graph fit the page ? ! The solu­tion is in the \scale­box com­mand from pstricks. It can be used like this:

\scalebox{0.75}{
    \begin{pspicture}(18,0)(0,0) { ... }
         ...
}

Hope you will save a few min­utes (hours) with this. See the code I attached to this post for testing.

test.tex
test.pdf