2

I'd like to create a tree with edges made from two separate arrows as shown in picture:

enter image description here

But I don't know how to change the edge to 'two separate arrows for each edge' Currently, I could only do the diagram below:

problematic latex

Below is the sample code:

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\pagestyle{empty}


\tikzstyle{level 1}=[level distance=3.5cm, sibling distance=3.5cm]
\tikzstyle{level 2}=[level distance=3.5cm, sibling distance=2cm]
\tikzstyle{bag} = [text width=4em, text centered]

\begin{tikzpicture}[sloped]
\node[bag] {1}
    child {
        node[bag] (2) {2}        
            child {
                node (4) {4}
                edge from parent [<->, thick]
                node[above] {e}
                node[below]  {f}
            }
            child {
                node (5) {5}
                edge from parent [<->, thick]
                node[above] {g}
                node[below]  {h}
            }
            edge from parent [<->, thick]
            node[above] {a}
            node[below]  {b}
    }
    child {
        node[bag] (3) {3}        
        child {
                node (6) {6}
                edge from parent [<->, thick]
                node[above] {i}
                node[below]  {j}
            }
            child {
                node (7) {7}
                edge from parent [<->, thick]
                node[above] {k}
                node[below]  {l}
            }
        edge from parent [<->, thick]          
            node[above] {c}
            node[below]  {d}
    };

\path (2) -- (3) node [midway] {$\cdots$};
\path (4) -- (5) node [midway] {$\cdots$};
\path (6) -- (7) node [midway] {$\cdots$};

\end{tikzpicture}

\end{document}

Appreciate any help. Thanks!

  • 2
    Welcome to TeX.SE! – Mensch Feb 15 at 23:27
0

Welcome to TeX.SE! Luckily this has been worked out in this great undervoted answer, which I just apply.

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{trees,arrows.meta}
\makeatletter

\pgfkeys{
  /pgf/arrow keys/.cd,
  Bidirectional/.style={
    length = +1.05pt 1.925 1,
    shear
  },
  shear/.code={
    \pgfarrowsthreeparameters{#1}%
    \expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\pgfarrowslinewidthdependentnew\pgfarrowstheparameters\pgfarrowshear\pgf@x}%
  },
  shear/.default = +0pt -.5 -.5
}
\newdimen\pgfarrowshear
\pgfarrowshear0pt
\def\pgfarrowslinewidthdependentnew#1#2#3{%
  \pgf@x#1%
  \ifdim\pgfinnerlinewidth>0pt%
    \pgf@arrows@inner@line@width@depnew{#2}{#3}%
  \else%  
    \advance\pgf@x by#2\pgflinewidth%
  \fi%
}
\def\pgf@arrows@inner@line@width@depnew#1#2{%
  % #1 * outer line width + #2 * inner line width = our new one = the following
  % (#1/2) * full line width + (#2-#1/2) * inner line width)
  % Compute "real" line width
  \pgf@xa.5\pgflinewidth%
  \pgf@xa#1\pgf@xa%
  \advance\pgf@x by\pgf@xa%
  \pgf@xa\pgfinnerlinewidth%
  \pgf@xb.5\pgf@xa%
  \advance\pgf@x by#2\pgf@xa%
  \advance\pgf@x by-#1\pgf@xb%
}
\def\pgf@arrow@drawer@shift#1#2#3{
  \pgftransformyshift\pgfarrowshear%
  \pgf@xb#2\pgftransformxshift{-\pgf@xb}%
  \pgf@xc#1%
  \advance\pgf@xc by\pgfarrowsep%
  \advance\pgf@xc by-\pgf@xb%
}
\makeatother
\begin{document}
\pagestyle{empty}


\begin{tikzpicture}[sloped,
level 1/.style={level distance=3.5cm, sibling distance=3.5cm},
level 2/.style={level distance=3.5cm, sibling distance=2cm},
bag/.style={text width=4em, text centered},
bidi/.style={thick,double,double
distance=3pt,{<[Bidirectional]}-{>[Bidirectional]}}]
\node[bag] {1}
    child {
        node[bag] (2) {2}        
            child {
                node (4) {4}
                edge from parent [bidi]
                node[above] {e}
                node[below]  {f}
            }
            child {
                node (5) {5}
                edge from parent [bidi]
                node[above] {g}
                node[below]  {h}
            }
            edge from parent [bidi]
            node[above] {a}
            node[below]  {b}
    }
    child {
        node[bag] (3) {3}        
        child {
                node (6) {6}
                edge from parent [bidi]
                node[above] {i}
                node[below]  {j}
            }
            child {
                node (7) {7}
                edge from parent [bidi]
                node[above] {k}
                node[below]  {l}
            }
        edge from parent [bidi]          
            node[above] {c}
            node[below]  {d}
    };

\path (2) -- (3) node [midway] {$\cdots$};
\path (4) -- (5) node [midway] {$\cdots$};
\path (6) -- (7) node [midway] {$\cdots$};

\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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