Crossing branches in tikz-qtree

These do not necessarily look like trees, so I would not necessarily recommend to use a library specialized on trees for that.

\documentclass{article}
\usepackage{subfig}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}

\begin{figure}[h]
\centering
\subfloat[][]{\begin{tikzpicture}
\matrix (mat) [matrix of nodes,column sep=1em,row sep=1em,
 nodes={align=center,inner sep=2pt},ampersand replacement=\&]
 {
 \& a \& \\
 b \& \& c\\
 \& d \&\\
 };
 \draw (mat-2-1.north) -- (mat-1-2.south) -- (mat-2-3.north)
 (mat-2-1.south) -- (mat-3-2.north) -- (mat-2-3.south);
\end{tikzpicture}}
\qquad
\subfloat[][]{\begin{tikzpicture}
\matrix (mat) [matrix of nodes,column sep=1em,row sep=1em,
 nodes={align=center},ampersand replacement=\&]
 {
 \& a \& \\
 b \& \& c\\
 e \&  \& d\\
 };
 \draw (mat-2-1.north) -- (mat-1-2.south) -- (mat-2-3.north)
 (mat-2-1) -- (mat-3-3) (mat-2-3) -- (mat-3-1);
\end{tikzpicture}}
\end{figure}
\end{document}

enter image description here


Even though these are not trees, you can still get the effect with tikz-qtree if you want. Here's how. I don't necessarily recommend this, but for a one-off example it works fine. I've used a slightly different method for the first tree; your method of joining two trees using scope is probably simpler for that case.

\documentclass{article}
\usepackage{tikz-qtree,tikz-qtree-compat}
\begin{document}
\begin{tikzpicture}
[every tree node/.style={align=center,anchor=base}]
\Tree [.a [.\node(b) {\strut b}; ] \edge[draw=none]; [.\node(x) {};  ] [.\node(c) {\strut c}; ]]
\node (d) [below of=x] {d};
\draw (d.north) -- (b.south);
\draw (d.north) -- (c.south);
\end{tikzpicture}

\bigskip
\begin{tikzpicture}
[every tree node/.style={align=center,anchor=base},sibling distance=.5cm]
\Tree [.a [.\node(b) {\strut b}; \edge[draw=none]; [.\node(e) {\strut e}; ]]  [.\node(c) {\strut c}; \edge[draw=none]; [.\node(d){\strut d}; ]]]
\draw (e.north) -- (c.south);
\draw (d.north) -- (b.south);
\end{tikzpicture}

\end{document}

output of code


An alternative to marmot's nice answer:

\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption}
\begin{document}
\begin{figure}
    \centering
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \begin{tikzpicture}[y=1.5cm]
            \node (a) at (0,0) {a};
            \node (b) at (-1,-1) {b};
            \node (c) at (1,-1) {c};
            \node (d) at (0,-2) {d};
            \draw (b.north)--(a.south)--(c.north);
            \draw (b.south)--(d.north)--(c.south);
        \end{tikzpicture}  
        \caption{}
    \end{subfigure}%
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \begin{tikzpicture}[y=1.5cm]
            \node (a) at (0,0) {a};
            \node (b) at (-1,-1) {b};
            \node (c) at (1,-1) {c};
            \node (d) at (1,-2) {d};
            \node (e) at (-1,-2) {e};
            \draw (b.north)--(a.south)--(c.north);
            \draw (b.south)--(d.north);
            \draw (c.south)--(e.north);
        \end{tikzpicture}  
        \caption{}
    \end{subfigure}
\end{figure}
\end{document}

enter image description here

But I prefer this

\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption}
\begin{document}
\begin{figure}
    \centering
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \begin{tikzpicture}[y=1.5cm,every node/.style={circle,draw,minimum size=0.75cm}]
            \node (a) at (0,0) {a};
            \node (b) at (-1,-1) {b};
            \node (c) at (1,-1) {c};
            \node (d) at (0,-2) {d};
            \draw (b)--(a)--(c)--(d)--(b);
        \end{tikzpicture}  
        \caption{}
    \end{subfigure}%
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \begin{tikzpicture}[y=1.5cm,every node/.style={circle,draw,minimum size=0.75cm}]
            \node (a) at (0,0) {a};
            \node (b) at (-1,-1) {b};
            \node (c) at (1,-1) {c};
            \node (d) at (1,-2) {d};
            \node (e) at (-1,-2) {e};
            \draw (d)--(b)--(a)--(c)--(e);
        \end{tikzpicture}  
        \caption{}
    \end{subfigure}
\end{figure}
\end{document}

enter image description here