# Organization of two graphs

How it is possible to represent two graphs created with TikZ in the same figure?

The source code for a graph is as follows:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{trees}
\usetheme{Frankfurt}

\begin{document}
\begin{frame}{TITLE}

\begin{figure}[H]
\begin{center}
\begin{tikzpicture} [sibling distance=1.5cm]

%          \node [size=0.3cm](topnode) at (0,5) {\{1,2,3\}}
\node (topnode) at (0,5) {\{1,2,3\}}
child { node[size=0.3cm] {\{1,2\}\{3\}}}
child { node[size=0.3cm] {\{1,3\}\{2\}}}
child { node[size=0.3cm] {\{1\}\{2,3\}}}
;
\node [size=0.3cm](topnode) {\{1\}\{2\}\{3\}}
%         \node[minimum width=3cm]  at (0,5) {\{\{1,2,3\}\}}
;
\foreach \x in {-3}{
\draw  (topnode-1) -- (bottomnode-\x);
\draw  (topnode-3) -- (bottomnode-\x);
\draw  (topnode-2) -- (bottomnode-\x);
}

\end{tikzpicture}
\end{center}

\end{frame}

\end{document}


like that

-
Please, edit/rephrase your question. It is unclear what you refer to. –  JLDiaz Jul 10 '12 at 18:09
Please turn the example into a full compilable document, starting from \documentclass. Also, please explain in more detail what exactly it is you're trying to change. There is no matrix in your code, what are you referring to? –  Jake Jul 10 '12 at 18:10
That edit has not really helped to make the question clearer. Please complete your code to make a full document, and clearly explain what you want to achieve. A single sentence is not enough in this case. –  Jake Jul 10 '12 at 20:01
Please make sure your code is compilable. The figure environment is not closed, the size key isn't defined, the topnode is defined twice but the bottomnode is missing. Also, again: Please explain what you want to achieve. It is not clear from your question. –  Jake Jul 10 '12 at 20:28

It´s a simple observation but you can add to useful @ClaudioFiandrino's answer the possibility of insert both graphs inside the same \begin{tikzpicture} ... \end{tikzpicture} with the environment \begin{scope}[shift={(5,0)}] ... \end{scope} to separate them:

\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{trees}
\usetheme{Frankfurt}

\begin{document}
\begin{frame}{TITLE}

\begin{center}
\begin{tikzpicture} [sibling distance=1.5cm]
\node (topnode) at (0,5) {1}
child { node[minimum size=0.3cm] {2}}
child { node[minimum size=0.3cm] {3}}
child { node[minimum size=0.3cm] {4}}
;
\node [minimum size=0.3cm](bottomnode) {5};
\draw  (topnode-1) -- (bottomnode);
\draw  (topnode-3) -- (bottomnode);
\draw  (topnode-2) -- (bottomnode);

\begin{scope}[shift={(5,0)}]

\node (topnode) at (0,5) {1}
child { node[minimum size=0.3cm] {2}}
child { node[minimum size=0.3cm] {3}}
child { node[minimum size=0.3cm] {4}}
;
\node [minimum size=0.3cm](bottomnode) {5};
\draw  (topnode-1) -- (bottomnode);
\draw  (topnode-3) -- (bottomnode);
\draw  (topnode-2) -- (bottomnode);

\end{scope}

\end{tikzpicture}
\end{center}

\end{frame}

\end{document}


Proceeding in this way, you can handle the relative position of one graph with respect to the other and not just in x-axis direction. (The image in this case is the same as the shown before by Claudio.)

-

I tried to guess the request and to reproduce the picture uploaded.

For that example, it is not needed the exact syntax of code taken from Drawing a tree where many nodes have the same child in TikZ and Tree using Latex, so in my answer I simplified it.

Basically, if the question was: "how to place these two graphs side by side", you can adopt two approaches:

1. insert the two pictures side by side (maybe with an \hspace to separate them);
2. use the columns environment.

The right method depends on your needs: if you have just to display the two pictures you can use the second one, while if you need to insert also some text maybe the first one is better.

Method 1

Code:

\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{trees}
\usetheme{Frankfurt}

\begin{document}
\begin{frame}{TITLE}

\begin{center}
\begin{tikzpicture} [sibling distance=1.5cm]
\node (topnode) at (0,5) {1}
child { node[minimum size=0.3cm] {2}}
child { node[minimum size=0.3cm] {3}}
child { node[minimum size=0.3cm] {4}}
;
\node [minimum size=0.3cm](bottomnode) {5};
\draw  (topnode-1) -- (bottomnode);
\draw  (topnode-3) -- (bottomnode);
\draw  (topnode-2) -- (bottomnode);
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture} [sibling distance=1.5cm]
\node (topnode) at (0,5) {1}
child { node[minimum size=0.3cm] {2}}
child { node[minimum size=0.3cm] {3}}
child { node[minimum size=0.3cm] {4}}
;
\node [minimum size=0.3cm](bottomnode) {5};
\draw  (topnode-1) -- (bottomnode);
\draw  (topnode-3) -- (bottomnode);
\draw  (topnode-2) -- (bottomnode);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}


Result:

Method 2

Code:

\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{trees}
\usetheme{Frankfurt}

\begin{document}
\begin{frame}{TITLE}
\begin{columns}[T]
\begin{column}{0.5\textwidth}
\centering
\begin{tikzpicture} [sibling distance=1.5cm]
\node (topnode) at (0,5) {1}
child { node[minimum size=0.3cm] {2}}
child { node[minimum size=0.3cm] {3}}
child { node[minimum size=0.3cm] {4}}
;
\node [minimum size=0.3cm](bottomnode) {5};
\draw  (topnode-1) -- (bottomnode);
\draw  (topnode-3) -- (bottomnode);
\draw  (topnode-2) -- (bottomnode);
\end{tikzpicture}
\end{column}
\begin{column}{0.5\textwidth}
\centering
\begin{tikzpicture} [sibling distance=1.5cm]
\node (topnode) at (0,5) {1}
child { node[minimum size=0.3cm] {2}}
child { node[minimum size=0.3cm] {3}}
child { node[minimum size=0.3cm] {4}}
;
\node [minimum size=0.3cm](bottomnode) {5};
\draw  (topnode-1) -- (bottomnode);
\draw  (topnode-3) -- (bottomnode);
\draw  (topnode-2) -- (bottomnode);
\end{tikzpicture}
\end{column}
\end{columns}
\end{frame}
\end{document}


Result:

-