Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using ground symbol to represent a null child in a binary tree. But the ground symbol has arrows in it. How do I remove them?

\documentclass{llncs}
\usepackage{llncsdoc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usetikzlibrary{shapes.geometric,arrows,fit,matrix,positioning,pgfplots.groupplots}
\usepackage{circuitikz}

\begin{document}
\tikzset
{
        treenode/.style = {circle, draw=black, align=center, minimum size=1cm},
        subtree/.style  = {isosceles triangle, draw=black, align=center, minimum height=0.5cm, minimum width=1cm, shape border rotate=90, anchor=north}
}
\begin{figure}[t]
\centering
\caption{A binary tree. \label{fig:simple}}
{
    \begin{tikzpicture}[->,scale=0.6, transform shape]
        %-----------------------------------------------------------------------
        \node (x)[treenode]                                 at (-3,0)       {$X$ \\ 100};
        \node (y)[treenode, fill=black!20]  at (-4.5,-1.5)  {$Y$ \\ 50};
        \node (a)[subtree]                                  at (-1,-1)      {\Large $\alpha$};
        \node (b)[subtree]                                  at (-6,-2.5)    {\Large $\beta$};
        \node (gnd)[ground]                                 at (-2.5,-2.5)  {}; 

        \path[every node/.style={font=\sffamily\small}]
        (-3, 1) edge node                   {} (x)
        (x)         edge node                   {} (y)
        (x)         edge node                   {} (a.north)
        (y)         edge node                   {}(b.north)
        (y)         edge node                   {}(gnd);
        %-----------------------------------------------------------------------
    \end{tikzpicture}
}
\end{figure}
\end{document}

output

share|improve this question

2 Answers 2

up vote 5 down vote accepted

I'd like to propose here an alternative, using the ground symbol from the circuits.ee.IEC library and using the powerful forest package to draw the tree:

enter image description here

The code:

\documentclass{llncs}
\usepackage{llncsdoc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,fit,matrix,positioning,pgfplots.groupplots,circuits.ee.IEC}
\usepackage{forest}

\tikzset{
  treenode/.style = {
    circle, 
    draw=black, 
    align=center, 
    minimum size=1cm
  },
  subtree/.style  = {
    isosceles triangle, 
    draw=black, 
    align=center, 
    minimum height=0.5cm,   
    minimum width=1cm, 
    shape border rotate=90, 
    anchor=north
  }
}

\newsavebox\mybox
\newcommand\Ground{%
  \begin{tikzpicture}[circuit ee IEC,scale=1.5]
  \draw (0,0) to +(0,-1.35ex) node[ground,rotate=-90,inner sep=0pt,xshift=0.65ex] {};
  \end{tikzpicture}%
}
\savebox\mybox{$\Ground$}

\begin{document}

\begin{figure}[t]
\centering
\caption{A binary tree. \label{fig:simple}}
\begin{forest}
for tree={
  scale=0.6,
  parent anchor=south,
  child anchor=north,
  edge={->},
  s sep=20pt,
}
[
  [$X$\\$100$,treenode
    [$Y$\\$50$,treenode,fill=gray!30
      [$\beta$,subtree]
      [\usebox\mybox,yshift=0.5cm]
    ]
    [$\alpha$,subtree
    ]
  ]
]
\end{forest}
\end{figure}

\end{document}
share|improve this answer

After one hour investigation, removing -> from tikzpicture environment to path command will solve the problem.

enter image description here

Code

\documentclass{llncs}
\usepackage{llncsdoc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{shapes.geometric,arrows,fit,matrix,positioning,pgfplots.groupplots}
\usepackage{circuitikz}

\begin{document}
\tikzset
{
        treenode/.style = {circle, draw=black, align=center, minimum size=1cm},
        subtree/.style  = {isosceles triangle, draw=black, align=center, minimum height=0.5cm, minimum width=1cm, shape border rotate=90, anchor=north}
}
\begin{figure}[t]
\centering
\caption{A binary tree. \label{fig:simple}}
{
    \begin{tikzpicture}[scale=0.6, transform shape]
        %-----------------------------------------------------------------------
        \node (x)[treenode]                                 at (-3,0)       {$X$ \\ 100};
        \node (y)[treenode, fill=black!20]  at (-4.5,-1.5)  {$Y$ \\ 50};
        \node (a)[subtree]                                  at (-1,-1)      {\Large $\alpha$};
        \node (b)[subtree]                                  at (-6,-2.5)    {\Large $\beta$};
        \node (gnd)[ground]                                 at (-2.5,-2.5)  {}; 

        \path[->,every node/.style={font=\sffamily\small}]
        (-3, 1) edge node                   {} (x)
        (x)         edge node                   {} (y)
        (x)         edge node                   {} (a.north)
        (y)         edge node                   {}(b.north)
        (y)         edge node                   {}(gnd);
        %-----------------------------------------------------------------------
    \end{tikzpicture}
}
\end{figure}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.