

\tikzstyle{smallNode} = [shape=circle,minimum size = 4pt, draw=black, inner sep =0, fill = \colOrange]
\tikzstyle{smallNodeNotInf} = [shape=circle,minimum size = 3.5pt, draw=black, inner sep =0]
\newcommand{\tri}[4]{ \draw[rounded corners, draw=black,#4] #1--#2--#3 --#1; } 
\newcommand{\vDiff}{0.8}
\newcommand{\hDiff}{0.9}
\newcommand{\triWidth}{0.8}
\newcommand{\triHeight}{1.5}
\newcommand{\padding}{0.2}
\newcommand{\smallwidth}{0.3}
% \tikzstyle{every node}=[shape =circle, draw=black]




% \newcommand{\lca}{\omega_{\mathrm{LCA}}}
% \newcommand{\pz}{\vec{\omega}}
% \newcommand{\activenodes}{\vec{X}^\star}
% \newcommand{\candidates}{\mathcal{C}}

\tikzset{snake it/.style={decorate, decoration={snake,amplitude=.3mm, segment length=3mm}}}

% \resizebox{\textwidth}{!}{
\begin{tikzpicture}[decoration=brace,
  grow cyclic,
  shape = circle,
  level distance=2em,
  scale = 0.9]
  
%   \input{circleTree}
  
    \node[node,dottetReplace, inner sep =1] (root) at (0,0) {\tiny$\lca$};
    
    \node[node] (c1) at (-2.2,-0.3) {};
    \node[node] (c11) at ($(c1)+(-\hDiff,-\vDiff)$) {};
    % \node[node] (c12) at ($(c1)+(0,-\vDiff)$) {};
    \node[node] (c13) at ($(c1)+(\hDiff,-\vDiff)$) {};
    \draw(c1) edge (c11);
    % \draw(c1) edge (c12);
    \draw(c1) edge (c13);
    \tri{(c11)}{+(-\triWidth,-\triHeight)}{+(\triWidth,-\triHeight)}{}
    % \tri{(c12)}{+(-\triWidth,-\triHeight)}{+(\triWidth,-\triHeight)}
    \tri{(c13)}{+(-\triWidth,-\triHeight)}{+(\triWidth,-\triHeight)}{}
     \draw[\colGreen, rounded corners] ($(c1.north)+(-\hDiff,0)+(-\triWidth,0)+(-\padding,\padding)$) rectangle ($(c1)+(\hDiff,-\vDiff)+(\triWidth,-\triHeight)+(\padding,-\padding)$);% node[below right = 0.4ex and 0]{$T_{\activenodes}^{\lca}$};
     
    \node[smallNode] (s12) at ($(c11) + (-\triWidth,-\triHeight) + (\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s13) at ($(c11) + (-\triWidth,-\triHeight) + (2*\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s14) at ($(c11) + (-\triWidth,-\triHeight) + (3*\smallwidth,0.1) $) {};
    \node[smallNode] (s15) at ($(c11) + (-\triWidth,-\triHeight) + (4*\smallwidth,0.1) $) {};
    \draw[snake it] (c11) -- (s12);
    \draw[snake it] (c11) -- (s13);
    \draw[snake it] (c11) -- (s14);
    \draw[snake it] (c11) -- (s15);
    
    \node[smallNode] (s22) at ($(c13) + (-\triWidth,-\triHeight) + (\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s23) at ($(c13) + (-\triWidth,-\triHeight) + (2*\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s24) at ($(c13) + (-\triWidth,-\triHeight) + (3*\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s25) at ($(c13) + (-\triWidth,-\triHeight) + (4*\smallwidth,0.1) $) {};
    \draw[snake it] (c13) -- (s22);
    \draw[snake it] (c13) -- (s25);
    \draw[snake it] (c13) -- (s23);
    \draw[snake it] (c13) -- (s24);
    
    \node[node] (c2) at (2.2,-0.3) {};
    \node[node] (c21) at ($(c2)+(-\hDiff,-\vDiff)$) {};
    % \node[node] (c22) at ($(c2)+(0,-\vDiff)$) {};
    \node[node] (c23) at ($(c2)+(\hDiff,-\vDiff)$) {};
    \draw(c2) edge (c21);
    % \draw(c2) edge (c22);
    \draw(c2) edge (c23);
    \tri{(c21)}{+(-\triWidth,-\triHeight)}{+(\triWidth,-\triHeight)}{}
    % \tri{(c22)}{+(-\triWidth,-\triHeight)}{+(\triWidth,-\triHeight)}
    \tri{(c23)}{+(-\triWidth,-\triHeight)}{+(\triWidth,-\triHeight)}{}{}
     \draw[\colGreen, rounded corners] ($(c2.north)+(-\hDiff,0)+(-\triWidth,0)+(-\padding,\padding)$) rectangle ($(c2)+(\hDiff,-\vDiff)+(\triWidth,-\triHeight)+(\padding,-\padding)$);
     \draw[\colBlue, rounded corners] ($(c1.north)+(-\hDiff,0)+(-\triWidth,0)+(-\padding,0)+(-\padding,0)+(0,0.6)$) rectangle ($(c2)+(\hDiff,-\vDiff)+(\triWidth,-\triHeight)+(2*\padding,-2*\padding)$);%node[below left = 0.4ex and 2*\triWidth+2*\hDiff]{$T^{v}_{\activenodes}$};
     
    
    \node[smallNode] (s32) at ($(c21) + (-\triWidth,-\triHeight) + (\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s33)at ($(c21) + (-\triWidth,-\triHeight) + (2*\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s34)at ($(c21) + (-\triWidth,-\triHeight) + (3*\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s35)at ($(c21) + (-\triWidth,-\triHeight) + (4*\smallwidth,0.1) $) {};
    \draw[snake it] (c21) -- (s32);
    \draw[snake it] (c21) -- (s33);
    \draw[snake it] (c21) -- (s34);
    \draw[snake it] (c21) -- (s35);
     
     
    \node[smallNodeNotInf] (s42) at ($(c23) + (-\triWidth,-\triHeight) + (\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s43)at ($(c23) + (-\triWidth,-\triHeight) + (2*\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s44)at ($(c23) + (-\triWidth,-\triHeight) + (3*\smallwidth,0.1) $) {};
    \node[smallNodeNotInf] (s45)at ($(c23) + (-\triWidth,-\triHeight) + (4*\smallwidth,0.1) $) {};
    \draw[snake it] (c23) -- (s42);
    \draw[snake it] (c23) -- (s43);
    \draw[snake it] (c23) -- (s44);
    \draw[snake it] (c23) -- (s45);
     
    
    \node[node,dottetReplace] (c3) at ($(root)+(0,\vDiff)+(0,0.2)$) {$\scriptsize v$};
    \node[node,dottetReplace] (c31) at ($(c3)+(-\hDiff,0.4*\vDiff)$) {};
    % \node[node] (c32) at ($(c3)+(0,-\vDiff)$) {};
    \node[node,dottetReplace] (c33) at ($(c3)+(\hDiff,0.4*\vDiff)$) {};
    \draw(c3) edge (c31);
    % \draw(c3) edge (c32);
    \draw(c3) edge (c33);
    \tri{(c31)}{+(-\triWidth,\triHeight)}{+(\triWidth,\triHeight)}{dottetReplace}
    % \tri{(c32)}{+(-\triWidth,-\triHeight)}{+(\triWidth,-\triHeight)}
    \tri{(c33)}{+(-\triWidth,\triHeight)}{+(\triWidth,\triHeight)}{dottetReplace}
    \node[node,dottetReplace] (c31) at (c31) {};
    % \node[node] (c32) at ($(c3)+(0,-\vDiff)$) {};
    \node[node,dottetReplace] (c33) at (c33) {};
    
    
    
    \node[smallNodeNotInf] (s52) at ($(c33) + (-\triWidth,\triHeight) + (\smallwidth,-0.1) $) {};
    \node[smallNodeNotInf] (s53)at ($(c33) + (-\triWidth,\triHeight) + (2*\smallwidth,-0.1) $) {};
    \node[smallNodeNotInf] (s54)at ($(c33) + (-\triWidth,\triHeight) + (3*\smallwidth,-0.1) $) {};
    \node[smallNodeNotInf] (s55)at ($(c33) + (-\triWidth,\triHeight) + (4*\smallwidth,-0.1) $) {};
    \draw[snake it] (c33) -- (s52);
    \draw[snake it] (c33) -- (s53);
    \draw[snake it] (c33) -- (s54);
    \draw[snake it] (c33) -- (s55);
    \node[smallNodeNotInf] (s62) at ($(c31) + (-\triWidth,\triHeight) + (\smallwidth,-0.1) $) {};
    \node[smallNodeNotInf] (s63)at ($(c31) + (-\triWidth,\triHeight) + (2*\smallwidth,-0.1) $) {};
    \node[smallNodeNotInf] (s64)at ($(c31) + (-\triWidth,\triHeight) + (3*\smallwidth,-0.1) $) {};
    \node[smallNodeNotInf] (s65)at ($(c31) + (-\triWidth,\triHeight) + (4*\smallwidth,-0.1) $) {};
    \draw[snake it] (c31) -- (s62);
    \draw[snake it] (c31) -- (s63);
    \draw[snake it] (c31) -- (s64);
    \draw[snake it] (c31) -- (s65);
    % \draw[rounded corners, \colLil]($(c33) +(\triWidth,-\triHeight)+ (\padding,-\padding) $)  -- ($(c31) +(-\triWidth,-\triHeight)+ (-\padding,-\padding)$ ) -- ($(c31) +(-\triWidth,0)+ (\padding,)$ ) -- ($ (root) +(-3*\padding, -3*\padding )$)-- ($ (root) +(-3*\padding, 3*\padding )$)-- ($ (root) +(3, 3*\padding )$) -- node[above right= 0.4ex]{$\mathcal{P}$}($(c3.north east) + (\padding,\padding)  +(0,0.6)$) -- ($(c33.east)+(\padding,0)$) -- cycle;
    
     \draw[-|, dashed, rounded corners] ($(root.east)+(\padding, 0)$) -- node[above right =-0.9ex and 0.1ex]{$t^*_v$} ($(c3.north east)+(\padding, 0)+(0.05,0)  $);
    %  \draw[dashed] ($(root.north east)+(\padding, 0)$) --  ; 
     \draw[|-|] ($(root.east)+(0,0)+(0.2, 0 )$) -- node[above right=0.8ex and 0.1ex] {$t^*_{\lca}$} ($(root.east)+ (0,-0.3)+(0,0-\triHeight-\vDiff)+(0.2, 0 )$) ;
    
    % -- ($(c33) + (\padding, 0) $)
    
    
    \draw (root) edge (c1);
    \draw (root) edge (c2);
    \draw (root) edge (c3);
    
    
    \node[] (legend) at ($(c11) + (0, -\triHeight) + (-0.5, -1)+ (-\betweenDist/2,0)$) {};
    \draw[] ($(legend) + (-\padding, \padding)$) rectangle ($(legend) + 3*(\padding, -\padding)+ (7, 0)$) ; 
    \node[smallNode, label={[label distance=4]0:$\activenodes$}] (activeNodes) at ($(legend) + (\padding, -\padding)$) {} ;
    \node[node, dottetReplace, label={[label distance=0.1]0:$\candidates$}] (candidates) at ($(legend) + (\padding, -\padding)+ (2, 0)$) {};
    \node[shape = rectangle, draw = \colBlue, label={[label distance=0.1]0:$\cT^{v}_{\activenodes}$}] (blue) at ($(legend) + (\padding, -\padding)+ 2*(2, 0)$) {};
    \node[shape = rectangle, draw = \colGreen, label={[label distance=0.1]0:$\cT_{\activenodes}^{\lca}$}] (blue) at ($(legend) + (\padding, -\padding)+ 3*(2, 0)$) {};
      
    % \node[] (legend) at ($(c3) + (4*\triWidth, \triHeight) + (\hDiff, 0.5)+(0.4,-0.5)$) {};
    % \draw[] ($(legend) + (-2*\padding, \padding)$) rectangle ($(legend) + 3*(\padding, -\padding)+ 4*(0.25, -1.2)$) ; 
    % \node[smallNode, label={[label distance=4]0:$\activenodes$}] (activeNodes) at ($(legend) + (\padding, -2*\padding)$) {} ;
    % \node[node, dottetReplace, label={[label distance=0.1]0:$\candidates$}] (candidates) at ($(legend) + (\padding, -2*\padding)+ (0, -1.5)$) {};
    % \node[shape = rectangle, draw = \colBlue, label={[label distance=0.1]0:$\cT^{v}_{\activenodes}$}] (blue) at ($(legend) + (\padding, -2*\padding)+ 2*(0, -1.5)$) {};
    % \node[shape = rectangle, draw = \colGreen, label={[label distance=0.1]0:$\cT_{\activenodes}^{\lca}$}] (blue) at ($(legend) + (\padding, -2*\padding)+ 3*(0, -1.5)$) {};
\end{tikzpicture}
% }


% Legenden nach unten in einer Zeile (T_X*), Kasten kleiner
% todo (max): \distactive{v} instead of t_{v}^*