0

How can you draw a graph with nodes having multiple inputs and outputs and edges connecting individual inputs and outputs? Like in the following image. graph nodes with inputs and outputs Image source

  • 1
    use of \pic can be handy, but first show us what you try so far! – Zarko Mar 1 '18 at 22:12
  • So far I've drawn an image on piece of paper and used it in the Latex document :D I know how to draw graphs using tikz, but I haven't found anything like this in the gallery or online examples. – DikobrAz Mar 1 '18 at 22:24
2
\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}

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.