측면에서 이진 트리의 깊이 지정

측면에서 이진 트리의 깊이 지정

나무를 그리려고 하는데 화살표에 깊이가 적힌 양방향 화살표를 사용하여 측면을 따라 깊이를 지정하고 싶습니다. 지금까지 내가 가진 것은 다음과 같습니다.

\begin{tikzpicture}[<-, >=stealth', auto, semithick, level/.style={sibling distance=60mm/#1}]
%\node  {} child {
\node [circle,draw] (z){$\land$}
  child {node [circle,draw] (a) {$\lor$}
    child {node [circle,draw] (b) {$\land$}
      child {node {$\vdots$}
        child {node [rectangle,draw] (d) {$x_1$}}
        child {node [rectangle,draw] (e) {$x_2$}}
      } 
      child {node {$\vdots$}}
    }
    child {node [circle,draw] (g) {$\land$}
      child {node {$\vdots$}}
      child {node {$\vdots$}}
    }
  }
  child {node [circle,draw] (j) {$\lor$}
    child {node [circle,draw] (k) {$\land$}
      child {node {$\vdots$}}
      child {node {$\vdots$}}
    }
  child {node [circle,draw] (l) {$\land$}
    child {node {$\vdots$}}
    child {node (c){$\vdots$}
      child {node [rectangle,draw] (o) {$x_{n-1}$}}
      child {node [rectangle,draw] (p) {$x_n$}
        %child [grow=right] {node (q) {$=$} edge from parent[draw=none]
          %child [grow=right] {node (q) {$O_{k = \lg n}(n)$} edge from parent[draw=none]
            %child [grow=up] {node (r) {$\vdots$} edge from parent[draw=none]
             % child [grow=up] {node (s) {$O_2(n)$} edge from parent[draw=none]
               % child [grow=up] {node (t) {$O_1(n)$} edge from parent[draw=none]
                %  child [grow=up] {node (u) {$O_0(n)$} edge from parent[draw=none]}
               % }
             % }
            %}
           % child [grow=down] {node (v) {$O(n \cdot \lg n)$}edge from parent[draw=none]}
          %}
        %}
      }
     }
  }
};

\path (o) -- (e) node (x) [midway] {$\cdots$}
  child [grow=down] {
    node (y) {}%{$O\left(\displaystyle\sum_{i = 0}^k 2^i \cdot \frac{n}{2^i}\right)$}
    edge from parent[draw=none]
  };
  node (w) {};%[midway] {$O\left(\displaystyle\sum_{i = 0}^k n\right) = O(k \cdot n)$};
% \path (q) -- (v) node [midway] {=};
% \path (e) -- (x) node [midway] {+};
% \path (o) -- (x) node [midway] {+};
% \path (y) -- (w) node [midway] {$=$};
% \path (v) -- (w) node [midway] {$\Leftrightarrow$};
%\path (r) -- (c) node [midway] {$\cdots$};
\end{tikzpicture}
\end{preview}

코드를 수정하려고 합니다.여기. 이 문제를 어떻게 해결할 수 있나요?

(관련 없음: 루트 노드에서도 화살표가 나오도록 할 수 있는 방법이 있나요?)

답변1

이 제안된 솔루션이 OP를 잘 이해하기를 바랍니다. 여기서 이중 머리 화살표는 다음을 통해 정의됩니다.\pgfarrowsdeclarecombine

여기에 이미지 설명을 입력하세요

암호

\documentclass[border=20pt]{standalone}%
\usepackage{tikz}
\usetikzlibrary{shapes,calc,positioning,arrows,}

\pgfarrowsdeclarecombine{twotriang}{twotriang}%    double headed arrow
{stealth'}{stealth'}{stealth'}{stealth'} 

\begin{document}

\begin{tikzpicture}[<-, >=stealth', auto, semithick,
 level/.style={sibling distance=60mm/#1}
]

%\node  {} child {
\node [circle,draw] (z){$\land$}
  child {node [circle,draw] (a) {$\lor$}
    child {node [circle,draw] (b) {$\land$}
      child {node {$\vdots$}
        child {node [rectangle,draw] (d) {$x_1$}}
        child {node [rectangle,draw] (e) {$x_2$}}
      } 
      child {node {$\vdots$}}
    }
    child {node [circle,draw] (g) {$\land$}
      child {node {$\vdots$}}
      child {node {$\vdots$}}
    }
  }
  child {node [circle,draw] (j) {$\lor$}
    child {node [circle,draw] (k) {$\land$}
      child {node {$\vdots$}}
      child {node {$\vdots$}}
    }
  child {node [circle,draw] (l) {$\land$}
    child {node {$\vdots$}}
    child {node (c){$\vdots$}
      child {node [rectangle,draw] (o) {$x_{n-1}$}}
      child {node [rectangle,draw] (p) {$x_n$}
      }
     }
  }
};

\path (o) -- (e) node (x) [midway] {$\cdots$}
  child [grow=down] {
    edge from parent[draw=none]
  };
\draw [twotriang-twotriang] ($(7cm,0)+(z.north)$)  coordinate(P)--node[midway]{\rotatebox[origin=c]{270}{depth}} (P|-p.south);
\draw [->] (z) -- ++(0,1cm);
\end{tikzpicture}

\end{document}

관련 정보