Disjunktive Graphen von Job-Shop-Planungsproblemen

Disjunktive Graphen von Job-Shop-Planungsproblemen

Kann mir jemand helfen, die folgende Grafik in TikZ zu zeichnen? Bildbeschreibung hier eingeben

Ich habe mit so etwas angefangen:

\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}

aber es ist sehr zeitaufwändig, es anhand der verfügbaren Dokumentation fertigzustellen. Vielen Dank (die dünnen Pfeile, die Sie im Bild sehen, können gestrichelt werden, wie im Codeausschnitt vorgeschlagen).

Antwort1

Hier erfahren Sie zunächst, wie Sie die Knoten platzieren und sie in zwei Schleifen mit Werten verbinden.

Hierzu chainshilft die Bibliothek dabei, Knoten regelmäßig zu platzieren und zu verbinden. Ihr Abstand zueinander wird durch angegeben node distance.

Der 0Knoten wird links von der Mitte der Westseite der Knoten 1/3 und 1/4 platziert, so dass er vertikal zentriert sitzt.

Schließlich habe ich über die graphSyntax/Bibliothek einige einfache Verbindungen zwischen den vorhandenen Knoten hinzugefügt.

Code


    \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}

Ausgabe

Bildbeschreibung hier eingeben

verwandte Informationen