battousai1983
battousai1983

Reputation: 111

How to make the tree-like graph in Latex?

I need to use LaTeX to create the following graph. I am just completely stuck with no idea how to get started. It seems there are some packages like TikZ that I could use to plot tree type of images, however I could not find anything to my example.

graph

Notice that some of those are arrows, while some are just line segments. And most examples I found are vertical structure, but this one is horizontal.

Any tips would be appreciated.

Upvotes: 6

Views: 10283

Answers (1)

MattAllegro
MattAllegro

Reputation: 7355

To provide my best suggestion I used trees library from TikZ.

The code:

\documentclass[tikz,margin=2mm]{standalone}
\usetikzlibrary{trees,arrows}
\begin{document}
\tikzstyle{level 1}=[level distance=30mm, sibling distance=30mm]
\tikzstyle{level 2}=[level distance=30mm, sibling distance=15mm]
\tikzstyle{level 3}=[level distance=20mm]
\begin{tikzpicture}[grow=right,->,>=angle 60]
%\begin{scope}[yshift=0]
  \node {$A_{1,1}$}
    child {node {$A_{2,2}$}
      child {node {$A_{3,2}$}
        child[-] {node{$S^{<4>}$}}  
      }
      child {node{$A_{3,1}$}
        child[-] {node{$S^{<3>}$}}  
      }
    }
    child {node {$A_{2,1}$}
      child {node{$A_{3,2}$}
        child[-] {node{$S^{<2>}$}}  
      }
      child {node{$A_{3,1}$}
        child[-] {node{$S^{<1>}$}}  
      }
    };
%\end{scope}
\begin{scope}[yshift=-6cm]
  \node {$A_{1,2}$}
    child {node {$A_{2,2}$}
      child {node {$A_{3,2}$}
        child[-] {node{$S^{<8>}$}}  
      }
      child {node {$A_{3,1}$}
        child[-] {node{$S^{<7>}$}}  
      }
    }
    child {node {$A_{2,1}$}
      child {node {$A_{3,2}$}
        child[-] {node{$S^{<6>}$}}
      }
      child {node {$A_{3,1}$}
        child[-] {node{$S^{<5>}$}}  
      }
    };
\end{scope}
\end{tikzpicture}
\end{document}

And the output, very similar to yours.

output image

Notice how no arrows at level 3 are provided by the syntax child[-] instead of child (default is ->,>=angle 60).

Upvotes: 12

Related Questions