1

Below example will draw a tree with tikz. but if the tree has only left or right branch, it will be drawed vertically so we don't know if it's left or right branch.

\documentclass{article}
\usepackage{tikz}  
\usetikzlibrary{shapes.geometric,arrows,fit,matrix,positioning}
\pagestyle{empty}             % do not remove
% The settings below are copied from fullpage.sty
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-3cm}
\setlength{\oddsidemargin}{1.5cm}
\addtolength{\oddsidemargin}{-2.54cm}
\setlength{\evensidemargin}{\oddsidemargin}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-\headheight}
\addtolength{\textheight}{-\headsep}
\addtolength{\textheight}{-\footskip}
\addtolength{\textheight}{-3cm}
\setlength{\topmargin}{1.5cm}
\addtolength{\topmargin}{-2.54cm}
\usepackage[active, tightpage]{preview}

\begin{document}
\begin{preview}
\tikzset{
  treenode/.style = {circle, draw=black, align=center, 
    minimum size=1cm, anchor=center},
}
\begin{tikzpicture}[->,>=stealth',level/.style={sibling distance = 5cm/#1,
      level distance = 1.5cm},scale=0.6, transform shape]
  \node [treenode] {1}
  child {
    node [treenode] {2} 
    child {
      node [treenode] {3} 
      child {
        node [treenode] {4} 
      }
      child {
        node [treenode] {5} 
      }
    }
    child [child anchor=north] {
      node [treenode] {6} 
    }
  }
  child [child anchor=north] {
    node [treenode] {7}
    child [child anchor=north] { 
        node [treenode] {8}
    } 
  };
\end{tikzpicture}
\end{preview}
\end{document

The output:

enter image description here

In this example, how can we make node "8" as a left branch?

Browse other questions tagged or ask your own question.