作业车间调度问题的析取图

作业车间调度问题的析取图

有人能帮我在 TikZ 中绘制以下图表吗? 在此处输入图片描述

我从这样的事情开始:

\begin{tikzpicture}[  ->,  >=Stealth,  shorten >=1pt,  auto,  node distance=2cm,  thick,  main node/.style={circle,draw,font=\sffamily\Large\bfseries}  ]

  % Nodes
  \node[main node] (b) at (0,0) {b};
  
  \node[main node] (7) at (2,2) {7};
  \node[main node] (4) at (2,0) {4};
  \node[main node] (1) at (2,-2) {1};
  
  \node[main node] (8) at (4,2) {8};
  \node[main node] (5) at (4,0) {5};
  \node[main node] (2) at (4,-2) {2};
  
  \node[main node] (9) at (6,2) {9};
  \node[main node] (6) at (6,0) {6};
  \node[main node] (3) at (6,-2) {3};

  \node[main node] (e) at (8,0) {e};

  % Solid edges
  \draw (b) -- (1);
  \draw (b) -- (4);
  \draw (b) -- (7);
  
  \draw (1) -- (4);
  \draw (2) -- (5);
  \draw (3) -- (6);
  
  \draw (4) -- (7);
  \draw (5) -- (8);
  \draw (6) -- (9);
  
  \draw (7) -- (e);
  \draw (8) -- (e);
  \draw (9) -- (e);

  % Dashed edges
  \draw[dashed] (1) -- (8);
  \draw[dashed] (8) -- (1);
  \draw[dashed] (2) -- (3);
  
  \draw[dashed] (4) -- (5);
  \draw[dashed] (5) -- (6);
  
  \draw[dashed] (7) -- (8);
  \draw[dashed] (8) -- (9);
  
\end{tikzpicture}

但按照现有文档完成它非常耗时。谢谢(图片中看到的细箭头可以画成虚线,如代码片段所示)。

答案1

从这里开始放置节点并将它们与两个循环中的值连接起来。

为此,该chains库有助于以规则的方式放置和连接节点。它们的距离通过 给出node distance

0节点放置在节点 1/3 和 1/4 西侧中间左侧,以便垂直居中放置。

graph最后,我通过语法/库在现有节点之间添加了一些简单的连接。

代码


    \documentclass[tikz]{standalone}
    \usetikzlibrary{arrows.meta, chains, calc, graphs, quotes, shapes.multipart}
    \begin{document}
    \begin{tikzpicture}[
      node distance=1cm,
      all nodes/.style={shape=circle, draw, minimum size=1cm},
      node BF/.style 2 args={
        all nodes, node other/.code=,shape=circle,
        name=#1 #2,node contents=$#1_{#2}$},
      node 7/.style={node BF={B}{#1}}, node 8/.style={node BF={F}{#1}},
      node other/.style 2 args={
        all nodes, shape=circle solidus, inner sep=.1em, name=#1 #2,
        node contents={#2 \nodepart{lower} #1}},
      >=Latex, every join/.style={->},
      start chain=rows going below,
    ]
    \foreach[count=\rowi] \rows in {{1, 3, 6, 7, 3, 6, -33},
                                    {8, 5, 10, 10, 10, 4, -61},
                                    {5, 4, 8, 9, 1, 7, -44},
                                    {5, 5, 5, 3, 8, 9, -45},
                                    {9, 3, 5, 4, 3, 1, -32},
                                    {3, 3, 9, 10, 4, 1, -39}}{
      \node[on chain, node other=\rowi 1];
      \tikzset{start branch={row\rowi} going right}
      \foreach[count=\coli from 2] \elem in \rows 
        \node[on chain, node \coli/.try=\rowi,
                        node other=\rowi\coli, join=by "$\elem$"];
    }
    \node[all nodes, left=2cm of $(3 1.west)!.5!(4 1.west)$](0){$0$}
      foreach \rowi in {1, ..., 6}{
        (0) edge[every join, "0" sloped] (\rowi\space 1)};
    
    \path[dashed] graph[edges=every join, use existing nodes]{
      1 1 ->[bend left]  3 1 ->[bend left]  5 1,
      2 1 ->[bend right] 4 1 ->[bend right] 6 1
    };
    \foreach \up/\Row/\above/\rows in {+/1/above/{1,2,3}, -/6/below/{6,5,4}}
      \foreach[count=\i from 0] \row in \rows
        \draw[rounded corners, every join] (0)
          |- node[at end, \above] {$0$} ([shift={(0,\up 1)}]B \Row.center)
          to[out=0, in/.evaluated={\up(\i==0?135:60)}, out looseness={1+1.5*sign(\i)}](F \row);
    \end{tikzpicture}
    \end{document}

输出

在此处输入图片描述

相关内容