复杂树/森林场景树

复杂树/森林场景树

我尝试过尝试不同的树结构,并浏览过这里的一些线索,但我甚至无法接近我想要的:

在此处输入图片描述

困难:

  • 如何绘制“生成器”术语。

  • 如何创建不同的根 (y^1、y^2、y^3)。

  • 如何在顶部创建间隔来映射不同的阶段(I_0^1、I_1^1、..、)

  • 如何创建从 Y^2 到​​ Y^k 的点,应该“告诉”读者存在多个这样的根。

  • 将文字放在边缘上。

有人能帮助我解决这些问题吗?

答案1

好了,代码应该相当完整了。享受 Ti 的美吧Z!

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{positioning}

\begin{document}
\begin{figure}
  \begin{tikzpicture}[
    , font = \sffamily % I love sans serif in figures
    , thick % this is also my preference
    % define some styles that can be reused
    , n f/.style = { % node fill
      , draw
      , fill = black
      , circle
      , inner sep = 0
      , outer sep = 0
      , minimum width = 1mm
    }
    , n o/.style = { % node outline
      , draw
      , circle
      , inner sep = 0
      , outer sep = 0
      , minimum width = 1mm
    }
    , n v/.style = { % node vertical
      , draw
      , fill
      , inner sep = 0
      , outer sep = .3mm
      , minimum width = .4mm
      , minimum height = 3mm
    }
  ]
    \node (generator) {Generator};
    \foreach \x in {-45, -15, 15, 45} {
      \draw [->, shorten < = 2mm] ([xshift = -2mm]generator.east) -- ++(\x:10mm);
    }
    \foreach [count = \i] \y in {30, 0, -40} { % y is the position of y
      \def\k{\ifnum\i=3k\else\i\fi} % the superscript
      \node (y-\i) [right = 20mm of generator, yshift = \y mm, minimum width = 5mm] {$y^\k$};
      \node (y-\i-n) at (y-\i.east) [n f] {};
      \foreach [count = \j] \yc in {10, 0, -10} {
        \draw (y-\i-n.center) -- ++ (20mm, \yc mm) node (C-\i-\j) [n f] {}
                                                   node [midway, above, font = \scriptsize] {$B_\j^1$}
                                                   node (C-\i-\j) [above] {$C_\j^\k$}
                              -- ++ (30mm, 0)      node (e-\i-\j) [right, n o] {}
                                                   node [midway, above, font = \small] {$\ifnum\i=1C_\j^\k+k+Z\else\dots\fi$};
      }
    }
    \draw [dashed] (y-2-n) -- (y-3-n);
    \node (a-1) [n v] at ([yshift = 20mm]C-1-1.center) {};
    \draw [shorten > = -.5mm] (a-1.center) -- ++ (+30mm, 0) node [midway, above, font = \small] {$I_1^1,I_1^2$}
                                                            node [right, n v] {};
    \draw [shorten > = -.5mm] (a-1.center) -- ++ (-20mm, 0) node [midway, above, font = \small] {$I_0^1$}
                                                            node [left , n v] {};
  \end{tikzpicture}%
\end{figure}
\end{document}

我特别喜欢\foreach\ifnum\if

结果

相关内容