4

In the following Tikz flow diagram constructed specifically using the automatic placement of graphs using \graph construct (i.e. instead of placing nodes using the fit library),

here,

how can I have the node X below node $\gamma$? The division work flow requires this in order to be mathematically correct.

The following is my LuaTeX code:

\RequirePackage{luatex85}
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, graphs, shapes, calc, arrows.meta, intersections}
\usetikzlibrary{graphdrawing}
\usegdlibrary{trees,layered,force}
\usepackage{mathtools}

\begin{document}
\begin{figure}
\begin{tikzpicture}[
    regularnode/.style={draw,semithick, minimum width = 12mm, minimum height = 8mm},
    sumnode/.style={draw,circle,semithick},
    gainnode/.style={draw,isosceles triangle,semithick},
    stylenode/.style={draw,semithick, minimum width = 1.2cm, minimum height = 1cm, node distance=4mm and 1.3cm},
    styledecisionbox/.style={draw,semithick,shape aspect=1,diamond,inner sep=2pt},
    >=Stealth,auto
    ]

    \graph [layered layout,grow=right,level sep=1cm]
    {
        {"power"/"1"[regularnode],"dragpower"/"2"[regularnode],"rollpower"/"3"[regularnode],"gradpower"/"4"[regularnode]}
        -> "sumofpowers"/"$\Sigma$"[sumnode]
        ->  "scalebydteff"/"$\alpha$" [gainnode]
        ->  "powerselector"/"$\beta$" [regularnode]
        ->  "scalebyncells"/"$\gamma$" [gainnode]
        ->  "scalebysurfacearea"/"$\div$" [stylenode]
        ->  "lionsimba"/"d"  [align=center,stylenode];
        ;
        "surfaceareacalc"/"X"[red,minimum size=1cm,circle,draw,ultra thick,fill=green!40]-> scalebysurfacearea;
    };

\end{tikzpicture}
\end{figure}
\end{document}
3

Use grow'=right instead grow=right to change the order of the children:

\RequirePackage{luatex85}
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, graphs, shapes, calc, arrows.meta, intersections}
\usetikzlibrary{graphdrawing}
\usegdlibrary{trees,layered,force}
\usepackage{mathtools}

\begin{document}
%\begin{figure}
\begin{tikzpicture}[
    regularnode/.style={draw,semithick, minimum width = 12mm, minimum height = 8mm},
    sumnode/.style={draw,circle,semithick},
    gainnode/.style={draw,isosceles triangle,semithick},
    stylenode/.style={draw,semithick, minimum width = 1.2cm, minimum height = 1cm, node distance=4mm and 1.3cm},
    styledecisionbox/.style={draw,semithick,shape aspect=1,diamond,inner sep=2pt},
    >=Stealth,auto
    ]

    \graph [layered layout,grow'=right,level sep=1cm]
    {
        {"power"/"1"[regularnode],"dragpower"/"2"[regularnode],"rollpower"/"3"[regularnode],"gradpower"/"4"[regularnode]}
        -> "sumofpowers"/"$\Sigma$"[sumnode]
        ->  "scalebydteff"/"$\alpha$" [gainnode]
        ->  "powerselector"/"$\beta$" [regularnode]
        ->  "scalebyncells"/"$\gamma$" [gainnode]
        ->  "scalebysurfacearea"/"$\div$" [stylenode]
        ->  "lionsimba"/"d"  [align=center,stylenode];
        ;
        "surfaceareacalc"/"X"[red,minimum size=1cm,circle,draw,ultra thick,fill=green!40]
        -> scalebysurfacearea
        ;
    };

\end{tikzpicture}
%\end{figure}
\end{document}

Result:

enter image description here

But note that also the order of "1", "2", "3" and "4" is changed.

  • I am afraid that this is a less than ideal solution. In my workflow, the 'X' branch (and it's upstream parents to be drawn later) comes logically after the gamma branch. Is there any other way to coax the desired placement after the gamma branch codes have been written? – Krishna Jun 14 '17 at 14:26
  • @Krishna I have changed my answer. – esdd Jun 14 '17 at 14:31
  • indeed that works. Thank you very much for your help. I have marked yours as the right answer. – Krishna Jun 14 '17 at 14:35

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.