绘制多链结构

绘制多链结构

我试图根据这个例子,从一开始就绘制一个有多个链的结构http://www.texample.net/tikz/examples/assignment-structure/

我目前有的是:

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols}
\tikzset{
>=stealth',
  punktchain/.style={
    rectangle, 
    rounded corners, 
    % fill=black!10,
    draw=black, very thick,
    text width=10em, 
    minimum height=3em, 
    text centered, 
    on chain},
  line/.style={draw, thick, <-},
  element/.style={
    tape,
    top color=white,
    bottom color=blue!50!black!60!,
    minimum width=8em,
    draw=blue!40!black!90, very thick,
    text width=10em, 
    minimum height=3.5em, 
    text centered, 
    on chain},
  every join/.style={->, thick,shorten >=1pt},
  decoration={brace},
  tuborg/.style={decorate},
  tubnode/.style={midway, right=2pt},
}

\begin{document}

\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance=.8cm,
  start chain=1 going below, start chain=2 going below]
     \node[punktchain, join] (start) {Static MC};

     \node[punktchain, join] (probf)      {Uniform Generator};
     \node[punktchain, join] (u) {U};
     \node[punktchain, join] (rules) {Transformation Rules};
     \node[punktchain, join, ] (simrv) {Simulated r.v. X};
      \node (loop) [punktchain ]  {Simulation algorithm (loop)};
        %Left Branch 
        \begin{scope}[start branch=left,
                every join/.style={->, thick, shorten <=1pt}, ]
                \node[punktchain, on chain=going left, join=by {<-}] (var) {Variance Reduction};
        \end{scope}

        %Lower branch
        \node[punktchain, join] (paths) {Sample paths};
        \node[punktchain, join] (law) {Law of large numbers};
         \node[punktchain, join] (estim) {Monte Carlo Estimation}; 
    \draw[tuborg] let
    \p1=(loop.west), \p2=(loop.east) in
    ($(\x1,\y1+2.5em)$) -- ($(\x2,\y2+2.5em)$) node[below, midway]  {};
\end{tikzpicture}
\caption{}
\label{fig:6forces}
\end{figure}
\end{document}

到目前为止看起来像这样部分图表

从现在开始,我想做的就是上面用黑色勾勒出的形状。也就是说,我想要在现有链条的右侧再添加一条链条,该链条与(循环)节点相连,并且其中也有一个分叉。

有人能帮我吗?我已经看过 tikz 手册了,但没什么进展。

干杯,克里斯托斯

答案1

这是第一次尝试,因为我不太明白如何连接循环节点附近的两个链。

我的解决方案是:

在此处输入图片描述

以下是代码:

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols}
\tikzset{
>=stealth',
  punktchain/.style={
    rectangle, 
    rounded corners, 
    % fill=black!10,
    draw=black, very thick,
    text width=10em, 
    minimum height=3em, 
    text centered, 
    on chain},
   small punktchain/.style={
    rectangle, 
    rounded corners, 
    % fill=black!10,
    draw=black, very thick,
    text width=5em, 
    minimum height=3em, 
    text centered, 
    on chain},
  line/.style={draw, thick, <-},
  element/.style={
    tape,
    top color=white,
    bottom color=blue!50!black!60!,
    minimum width=8em,
    draw=blue!40!black!90, very thick,
    text width=10em, 
    minimum height=3.5em, 
    text centered, 
    on chain},
  every join/.style={->, thick,shorten >=1pt},
  decoration={brace},
  tuborg/.style={decorate},
  tubnode/.style={midway, right=2pt},
}

\begin{document}

\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance=.8cm,
  start chain=1 going below, start chain=2 going below]
     \node[punktchain, join] (start) {Static MC};

     \node[punktchain, join] (probf)      {Uniform Generator};
     \node[punktchain, join] (u) {U};
     \node[punktchain, join] (rules) {Transformation Rules};
     \node[punktchain, join, ] (simrv) {Simulated r.v. X};
      \node (loop) [punktchain ]  {Simulation algorithm (loop)};
        %Left Branch 
        \begin{scope}[start branch=left,
                every join/.style={->, thick, shorten <=1pt}, ]
                \node[punktchain, on chain=going left, join=by {<-}] (var) {Variance Reduction};
        \end{scope}

        %Lower branch
        \node[punktchain, join] (paths) {Sample paths};
        \node[punktchain, join] (law) {Law of large numbers};
         \node[punktchain, join] (estim) {Monte Carlo Estimation}; 
    \draw[tuborg] let
    \p1=(loop.west), \p2=(loop.east) in
    ($(\x1,\y1+2.5em)$) -- ($(\x2,\y2+2.5em)$) node[below, midway]  {};

    % SECOND CHAIN
    \node[punktchain, right=2cm of start] (x) {...};
    \node[punktchain,join] (y) {...};
    \node[punktchain, join] (z) {...}
    child{node[small punktchain, join, right=1cm of rules] (wa) {...}
    child{node[small punktchain, join] (wc) {...}}
     }
    child[->,thick]{node[small punktchain,right=2cm of wa] (wb) {...}
    child{node[small punktchain, join] (wd) {...}}}
    ;

    % connections with the first one
    \draw[thick,->](simrv.south)--($(simrv.south)+(0,-1em)$);

    \draw[thick] (wd.south)--($(wd.south)+(0,-1em)$);
    \draw[thick] (wc.south)--($(wc.south)+(0,-1em)$);
    \draw[thick,->] ($(wd.south)+(0,-1em)$)--($(simrv.south)+(0,-1em)$);
    \draw[thick,->]($(simrv.south)+(0,-1em)$)--(loop.north);


\end{tikzpicture}
\caption{}
\label{fig:6forces}
\end{figure}
\end{document}

我的解决方案的关键点是:

  1. 第二条链的起始节点(称为 )的定义,x放置在 位置right=2cm of start
  2. 使用 的语法trees将链与节点 分成两个子链z
  3. 使用一种新元素small punktchain来表示子链中的节点;它基本上是该风格的复制品,punktchain只是小了一点;
  4. 使用calc库将两个子链与初始链连接起来(一旦提供更多细节,这部分将会得到改进)。

答案2

关于链条的小提醒

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}

\begin{document}
\begin{tikzpicture}
\begin{scope}[start chain=1 going below,start chain=2 going right]
\node[on chain=1] (A) {A};
\node[on chain=1] (C) {C};
\node[on chain=1] (D) {D};
\node[on chain=1] (G) {G};
\node[on chain=1] (H) {H};
\chainin (A);
\node[on chain=2,] (B) {B};
\node[continue chain=going below,on chain=2] (E) {E};
\node[on chain=2] (F) {F};
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容