I need exactly this diagram drawn in LaTeX but frankly, I have absolutely no idea how to do it. I would greatly appreciate if anyone can draw it out in latex for me or could point me to a tool where I can draw it out graphically and the LaTeX is generated. Thank you so much! enter image description here

  • 3
    Welcome to TeX.SX! The tool you search for is Inkscape (if you are in a rush), because it may export to pdf with TeX fonts, but really TikZ is not that hard to learn. There are examples for this kind of graphics on the site. – TeXnician Jul 30 '18 at 14:19

From this question indexed letters inside circles there is a possibility also with tikz-cd.

enter image description here


    \node (X) [draw, shape=circle, inner sep=0] {\strut #1};}

\begin{tikzcd}[column sep=huge]
\encircle{A} \arrow[r, "W_{AB}"] \arrow[rd, "W_{AC}",sloped,near start] & \encircle{B} \arrow[r] & \mathrm{Output}_{\text B}\\
 & \encircle{C} \arrow[r] & \mathrm{Output}_{\text C} 

A simple solution with the psmatrix environment (from pst-node):

    \usepackage{pst-node, pst-arrow}


   \psset{arrows=-v, veearrowlinewidth=0.5pt, veearrowlength=4pt, veearrowangle=35, linewidth=0.6pt, nodesep=2pt, labelsep=1pt, rowsep=1cm}
    \def\pscolhookiii{\hskip -0.6cm}
    \begin{psmatrix} %%% nodes
     \circlenode{A}{A} & \circlenode{B}{B} & [name=outB] Output\textsubscript{B} \\ 
     & \circlenode{C}{C} & [name=outC] Output\textsubscript{C} 
    %%% nodes connections


enter image description here


Here is an option using basic tikz code, and written in a structured way.

RESULT: enter image description here


        %Environment Styles
            circle, %node shape is a circle
            draw, %shape is drawn
            line width=1pt, % Shape line width,
            font=\sf, % Font in serif
            on grid, % The coordinate is relative to a grid from center to center of nodes.
            line width =0.75pt,
            ->, % Type of arrow could be bidirectional <->, -Stealth see  http://tug.ctan.org/info/visualtikz/VisualTikZ.pdf#subsection.4.10
            shorten > =5pt, % Arrow end don't touch node in 5pt
            shorten < =5pt % idem Arrow start.
    %node[style] (node_name){Text_content};
    \node [cell](Cell-A){A};
    \node [cell, right=3.5cm of Cell-A](Cell-B){B}; % right=2cm of Cell-A is given by positioning library PGF manual section 17-5-3
    \node [cell, below=2.5cm of Cell-B](Cell-C){B}; 
    \draw[MyArrow] (Cell-A) -- (Cell-B) node [midway, anchor=south]{$\mathsf{W_{AB}}$};
    \draw[MyArrow] (Cell-A) -- (Cell-C) node [midway,sloped, anchor=south]{$\mathsf{W_{AC}}$};
    \draw[MyArrow] (Cell-B) -- ++(2,0) node [anchor=west]{$\mathsf{Output_{B}}$}; % ++(2,0) gives a poinr shifted relative to the previous node.
    \draw[MyArrow] (Cell-C) -- ++(2,0) node [anchor=west]{$\mathsf{Output_{C}}$};

PSD: you can see another more complicated example in How do I draw an LSTM cell in Tikz?


one more tikz solution:

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{arrows.meta, positioning, quotes}

           node distance = 12mm and 12mm,
             circ/.style = {circle, draw, thick,
                            inner sep= 1mm, outer sep=1mm},
       every edge/.style = {draw=gray, semithick, -Straight Barb},
every edge quotes/.style = {font=\small, sloped, anchor=south},
                    font = \sffamily, 
% nodes
\node (a) [circ]            {A};
\node (b) [circ,right=21mm of a] {B};
\node (c) [right=of b]      {Output\textsubscript{B}};
\node (d) [circ,below=of b] {B};
\node (e) [right=of d]      {Output\textsubscript{C}};
\draw   (a) edge ["$\mathsf{W_{AB}}$"] (b)
        (a) edge ["$\mathsf{W_{AB}}$"] (d)
        (b) edge (c)
        (d) edge (e);

enter image description here


Here is yet another solution using forest. Not quite as short as Sebastiano's nice answer, but very close.

  for tree={grow'=east,calign=first,
    minimum height=1cm,
  where n children=0{l=1cm}{draw},
    [B,edge label={node[midway, font=\small\sffamily,above]{W\textsubscript{AB}}}
    [C,edge label={node[midway, font=\small\sffamily,above,sloped]{W\textsubscript{AC}}}

enter image description here

  • You're very nice. I would certainly have voted in favour of your answer. +1 – Sebastiano Jul 31 '18 at 17:16

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.