# Adding a new edge to Tikz graph breaks layout

Whilst laying out a flow diagram using Tikz algorithmic graphing capabilities, my code renders the following output (reasonably sufficient to convey the key ideas).

Now, I intend to connect the 'no' output of the decision box $x < y$ back to the iterative search node. However, the layout goes haywire upon doing so, resulting in the following output.

Instead of using the positioning library and specifying relative locations, I chose to use Tikz' automated graphing capabilities because I need to wire up a lot of nodes and edges. Towards the end, I intend to dynamically try out various algorithms to a desired one.

Hence, I am looking for a 'scalable' solution (i.e. not nudging nodes by hand) to my problem here.

The offending line in my LuaTex code below is line number 52. You can get the two pictures by toggling the comment string on this line.

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

\usepackage{mathtools}
\usepackage{circuitikz}
\newsavebox{\selectorswitch}

\begin{document}

\begin{tikzpicture}[
accregularnode/.style={draw,semithick, minimum width = 12mm, minimum height = 8mm},
accsumnode/.style={draw,circle,semithick},
accgainnode/.style={draw,isosceles triangle,semithick},
commongainnode/.style={draw,isosceles triangle,semithick,minimum size=1.5cm},
commonstylenode/.style={draw,semithick, minimum width = 1.2cm, minimum height = 1cm, node distance=4mm and 1.3cm},
commonstyledecisionbox/.style={draw,semithick,shape aspect=1,diamond,inner sep=2pt},
accstyledecisionbox/.style={draw,semithick,shape aspect=1,diamond,inner sep=2pt},
>=Stealth,auto
]

% \graph [binary tree layout,grow=right,components go right top aligned,edges=rounded corners,sibling distance=8mm,level distance=8mm]
\graph [layered layout,grow'=right,level sep=1cm,sibling sep=5mm]
{
-> "sumofpowers"/"$\Sigma$"[accsumnode]
-> [sloped] "scalebydteff"/"e" [accgainnode]
-> [sloped,parent anchor=east,] "powerselector"/"f" [draw,semithick]
-> [sloped] "scalebyncells"/"g" [commongainnode]
-> [sloped] "scalebysurfacearea"/"$\div$" [commonstylenode]
-> [sloped] "lionsimba"/"h"  [align=center,commonstylenode];
;

"iterativesearchalgo"/"Iterative Search \\$n_{min}\le n^{(i)}\le n_{max}$"[commonstylenode,align=center]
->[sloped]"surfaceareacalc"/"i"[commongainnode]
->[sloped,parent anchor=east] scalebysurfacearea;

//[layered layout,grow=down,level sep=5mm]
{
lionsimba
-> "temperaturecheck"/"x<y" [align=center,commonstyledecisionbox]
->[edge label=\tiny{yes}] "cutoffvoltagecheck"/"p<q" [align=center,accstyledecisionbox]
->[edge label=\tiny{yes}]"cutoffsoccheck"/"m>n" [align=center,accstyledecisionbox]
->[edge label=\tiny{yes}] "noptaccgivenTcombo"/"long node name" [align=center,commonstylenode]
-> "noptgivenTcombo"/"very long node name" [double,align=right,commonstylenode]
};

temperaturecheck ->[parent anchor=west,child anchor=south,edge label= \tiny{no}] iterativesearchalgo;

};

\end{tikzpicture}
\end{document}

• Is temperaturecheck ->[parent anchor=east,child anchor=north,edge label= \tiny{no}] iterativesearchalgo; an option for you? – Bobyandbob Jun 14 '17 at 21:49
• I recommend thinking carefully about whether the automated layout algorithms are appropriate for the diagram you want or need. They may work well if the structural relations matter, but the particular layout does not. Usually, in flow charts, that's just not the case and I don't think the algorithms are generally suitable there. – cfr Jun 15 '17 at 0:30
• Does adding the extra edge as separate graph get what is required? Nodes can be resued by putting parentheses around them: \graph {(temperaturecheck) ->[parent anchor=west,child anchor=south,edge label=\tiny{no}] (iterativesearchalgo);}; – Mark Wibrow Jun 16 '17 at 7:52