[pstricks] Unbalanced trees with pstree

Jean-Come Charpentier Jean-Come.Charpentier at wanadoo.fr
Tue Nov 2 03:45:10 CET 2004


Mårten Trolin wrote:

> Hello,
>
> I want to make a three-level tree where the nodes on the second level 
> have different number of sons. The code I use is as follows
>
> \pstree[]
>          { \TR{$M_\rho$}}
>           { \pstree{ \TR{$M_{\beta_1}$}}
>               {\TR{$S_{\alpha_1}$} \TR{$S_{\alpha_2}$} }
>             \pstree{ \TR{$M_{\beta_2}$}}
>               {\TR{$S_{\alpha_3}$} \TR{$S_{\alpha_4}$}
>                 \TR{$S_{\alpha_5}$} \TR{$S_{\alpha_6}$} }
>             \pstree{ \TR{$M_{\beta_3}$}}
>               {\TR{$S_{\alpha_7}$} \TR{$S_{\alpha_8}$}
>                 \TR{$S_{\alpha_9}$} }
>          }
>
> I want the subtrees to be evenly spaced (e.g., I want the edge between 
> M_\rho and M_{\beta_2} to be vertical). I have experimented with
> treenodesize, thistreenodesize and treesep without any luck. Any ideas 
> are very welcome!


In fact, it's a good idea. With treenodesize=0pt and treesep 
proportional to 1/(n-1) where n is the number of leaves in each subtree.

\newdimen\base \base=4mm
\pstree[treenodesize=0pt]
         { \TR{$M_\rho$}}
          { \pstree[treesep=6\base]{ \TR{$M_{\beta_1}$}}
              {\TR{$S_{\alpha_1}$} \TR{$S_{\alpha_2}$} }
            \pstree[treesep=2\base]{ \TR{$M_{\beta_2}$}}
              {\TR{$S_{\alpha_3}$} \TR{$S_{\alpha_4}$}
                \TR{$S_{\alpha_5}$} \TR{$S_{\alpha_6}$} }
            \pstree[treesep=3\base]{ \TR{$M_{\beta_3}$}}
              {\TR{$S_{\alpha_7}$} \TR{$S_{\alpha_8}$}
                \TR{$S_{\alpha_9}$} }
         }

Is there a better way?

  Jean-Côme Charpentier







More information about the PSTricks mailing list