绘制具有多个输入和输出的节点的图形

绘制具有多个输入和输出的节点的图形

如何绘制一个图形,其中节点具有多个输入和输出,并且边连接各个输入和输出?如下图所示。 具有输入和输出的图形节点 图像来源

答案1

\documentclass[tikz, border = 3pt]{standalone}

\usetikzlibrary{quotes}

\tikzset{
  node23/.pic ={
    \coordinate (A) at (0, 0);
    \coordinate (B) at (2, 3.5);
    \draw[pic actions] (A) rectangle (B) node [pos = 0.5]{\large\tikzpictext};
    \foreach \y in {0.5, 1.5, 2.5} \fill[pic actions] (2, \y) rectangle (2.5, \y + 0.5);
    \foreach \y in {0.75, 2.25} \fill[pic actions] (0, \y) rectangle (-0.5, \y + 0.5);
  },
  node12/.pic ={
    \coordinate (A) at (0, 0);
    \coordinate (B) at (2, 2.5);
    \draw[pic actions] (A) rectangle (B) node [pos = 0.5]{\large\tikzpictext};
    \foreach \y in {0.5, 1.5} \fill[pic actions] (2, \y) rectangle (2.5, \y + 0.5);
    \foreach \y in {1.0} \fill[pic actions] (0, \y) rectangle (-0.5, \y + 0.5);
  }
}

\begin{document}
\begin{tikzpicture}
  \pic[color = red, "F"] (F) {node23};
  \pic[color = blue , "r"] (r) at (4, 0) {node12};
  \pic[color = orange , "G"] (G) at (8, 0) {node23};
  \pic[color = cyan , "H"] (H) at (8, -4) {node23};
  \draw[->] (2.6, 2.75) -- (3.4, 1.25);
  \draw[->] (6.6, 1.75) -- (7.4, 2.50);
  \draw[->] (6.6, 0.75) -- (7.4, -1.50);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容