[Tex/LaTex] How to draw a joining line between two picture tikz-pgf

technical-drawingtikz-pgftikz-treestrees

I'am having draw two tree using the tikz-pgf package

 \begin{frame}

 \begin{columns}[c]

 \begin{column}{2cm}
    \begin{tikzpicture}[scale=0.5] 
    \tikzstyle{level 1}=[sibling distance=10mm] 
    \node{f} 
    child{node{a}}
    child{node{f} child{node{b}} child{[red] node{f }   child{node{a}} child{node{f} child{node{b}}child{node{b}}}      }}
    ;
    \end{tikzpicture}
\end{column}    
\begin{column}{2cm}
   \begin{tikzpicture}[scale=0.5] 
   \tikzstyle{level 1}=[sibling distance=10mm] 
   \node{f} 
    child{node{a}}
    child{node{f} child{node{b}} child{ node{f }   child{node{a}} child{node{g} child[missing] child{node{a}}}      }}
    ;
   \end{tikzpicture}
 \end{column}
 \end{columns}
\end{frame}

The result is :
enter image description here

Now i want to connect these two images by a curve line like this

enter image description here

i don't know how i will do it , any answer will be appreciates

Best Answer

You can name the nodes and, since the two nodes belong to different tikzpictures, you need to use the remember picture, overlay options to draw a line connecting them:

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

 \begin{frame}

 \begin{columns}[c]
 \begin{column}{2cm}
    \begin{tikzpicture}[remember picture,overlay,scale=0.5] 
    \tikzstyle{level 1}=[sibling distance=10mm] 
    \node{f} 
    child{node{a}}
    child{node{f} child{node{b}} child{[red] node (f1) {f }   child{node{a}} child{node{f} child{node{b}}child{node{b}}}      }}
    ;
    \end{tikzpicture}
\end{column}    
\begin{column}{2cm}
   \begin{tikzpicture}[remember picture,overlay,scale=0.5] 
   \tikzstyle{level 1}=[sibling distance=10mm] 
   \node (f2) {f} 
    child{node{a}}
    child{node{f} child{node{b}} child{ node{f }   child{node{a}} child{node{g} child[missing] child{node{a}}}      }}
    ;
\draw (f1) .. controls (-3,3) .. (f2);
   \end{tikzpicture}
 \end{column}
 \end{columns}
\end{frame}

\end{document}

enter image description here

If both trees are part of the same tikzpicture, there's no need to use remember picture,overlay (but I don't know if using two environments is esential in your actual document).