# Insert command in path after each node with certain style

I would like to make a mindmap and connect each leaf with an outside node. How can I do this?

In the following example I'd like to connect each

Example code:

\tikzset{
top concept/.style = {mindmap, concept color=orange},
is6/.style = {concept},
to6/.style = {concept},
isConc/.style = {concept},
toConc/.style = {concept}
}

\begin{tikzpicture}

\node[circle,draw] (thatnode) at (10,0)  {that other node};

\path[top concept] (0,20cm) node[isConc, insert path={circle[fill=red,radius=5cm]}] {Statistic} [clockwise from=0]
child[toConc] { node[isConc] {general theory}
child[to6] { node[is6] {intro to propability} }
child[to6] { node[is6] {asymptotics and Law of large number} }
child[to6] { node[is6] {asymptotics and Central Limit Theorem} }
}
child[toConc] { node[isConc] {distributions} [clockwise from=90]
child[to6] { node[is6] {binomial distrubtion} }
child[to6] { node[is6] {normal distribution} }
child[to6] { node[is6] {poisson distribution} }
}
child[toConc] { node[isConc] {statistics} [clockwise from=-30]
child[to6] { node[is6] {variability, variance} }
child[to6] { node[is6] {expected value} }
}
child[toConc] { node[isConc] {propability}
child[to6] { node[is6] {propability mass functions} }
child[to6] { node[is6] {propability density functions} }
child[to6] { node[is6] {baye's rule} }
child[to6] { node[is6] {independence} }
}
child[toConc] { node[isConc] {hypothesis testing}
child[to6] { node[is6] {standard error of mean} }
child[to6] { node[is6] {T confidence intervals} }
child[to6] { node[is6] {T tests} }
child[to6] { node[is6] {hypothesis testing} }
child[to6] { node[is6] {two group testing} }
child[to6] { node[is6] {pvalues} }
child[to6] { node[is6] {power} } % (propability of rejecting null hypothesis when false)
child[to6] { node[is6] {bootstrapping} }
child[to6] { node[is6] {permutation tests} }
}
;
\end{tikzpicture}


I thought about something along those lines:

\tikzset{
is6/.style = {concept, concept color=col6, alias=this, append after command={(this) -- (thatnode)}},
to6/.style = {concept, concept color=colI!50!col6},
}


### Small working example:

I'd like to get the (this) -- (othernode) into the style.

\documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{tikz} \usetikzlibrary{shapes,arrows,chains,positioning,calc,trees,mindmap}

\tikzset{ is6/.style = {concept, concept color=green, text=black, alias=this}, to6/.style={concept}, isConc/.style={concept, color=orange, text=black}, toConc/.style={concept, text=black}}

\begin{document}

\begin{tikzpicture} \node[fill=red, circle] (othernode) at (7,7) {adsf}; \path[mindmap, concept, color=orange] (0,0cm) node[isConc] {Statistic} [clockwise from=90]     child[toConc] { node[isConc] {general theory}       child[to6] { node[is6] {intro}  (this) -- (othernode) }         child[to6] { node[is6] {outro} (this)  -- (othernode) }     }   child[toConc] { node[isConc] {distributions} [clockwise from=0]         child[to6] { node[is6] {binomial}  (this) -- (othernode)  }         child[to6] { node[is6] {normal} (this)  -- (othernode)  }   }   ;

\end{tikzpicture}

\end{document}


Btw. Tikz \draw as part of style (Drawing something inside each node of certain type) is not the same ;-).

• Could you please complete your code so we can compile it? – cfr Dec 1 '15 at 20:25
• If your nodes have regular names, you can just use a loop at the end of the map to join them up. I'd demonstrate if I had a working example but I don't have time for guessing games at the minute. – cfr Dec 1 '15 at 20:27
• @cfr: Here you are :-). – Make42 Dec 1 '15 at 22:42
• I meant that, if you named the nodes, you could loop over them at the end of the map to join them to whatever node. But that wouldn't make it part of a style you could apply to the node because the node's a node. – cfr Dec 1 '15 at 23:58
• @cfr: But then I would have to name each node with a different name (right?) and in my real application I hava LOT of them. Also: How can I loop over them? I would have to put them in an array or something like that (right?) - how would I do that? – Make42 Dec 2 '15 at 9:34

If othernode is defined before drawing the mindmap, you can use a \pgfextra command inside style to draw a link between mindmap nodes and othernode.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,chains,positioning,calc,trees,mindmap}

\tikzset{
is6/.style = {concept, concept color=green,
text=black, alias=this,
append after command={
\pgfextra{
\draw[red,dashed] (this)--(othernode);}
}},
to6/.style={concept},
isConc/.style={concept, color=orange, text=black},
toConc/.style={concept, text=black}}

\begin{document}

\begin{tikzpicture}
\node[fill=red, circle] (othernode) at (7,7) {adsf};
\path[mindmap, concept, color=orange] (0,0cm)
node[isConc] {Statistic} [clockwise from=90]
child[toConc]{node[isConc] {general theory}
child[to6] {node[is6] {intro}}
child[to6] {node[is6] {outro}}}
child[toConc] {node[isConc] {distributions} [clockwise from=0]
child[to6] {node[is6] {binomial}}
child[to6] {node[is6] {normal}}
};
\end{tikzpicture}

\end{document}


• I understand what \pgfextra does, but I am not sure I understand what append after command. I understood that the reason, by usage of append after command did not work is, because it appended the code after the construction of the path (so just before ;). Why then would \pgfextra help? I'd expect that \pgfextra would just be appended after the construction of the path, which - again - would be useless in my case. So why does it work? – Make42 Dec 2 '15 at 9:50
• @user49283 I also don't deeply understand how it works but \pgfextra interrupts the path construction and starts a new one, when it finishes the interrupted continues. This is the reason why \draw or \path are needed inside a \pgfextra command. A regular append after command uses the still not finished \path command to complete its task. Does it helps you? – Ignasi Dec 2 '15 at 10:00
• 1) Now my bubbles have a dashed line around them... e.g. around the green bubbles is a green dashed circle... how do I get rid of it? 2) ALSO: I want the lines to be underneath the bubbles: How do I do that? – Make42 Dec 2 '15 at 10:03
• regarding the path interruption: I get the path interruption, but I don't get what is considered a "command" from "append after command". Was I wrong to assume it is the path? Is it the node? What code is the code appended to? – Make42 Dec 2 '15 at 10:06
• @user49283 Not sure to understand your last comments but \path doesn't "draw" just places objects and append after command inside it does the same. But append after command=\pgfextra{\draw ... inside a path command interrupts path and stars a \draw-ing command. – Ignasi Dec 2 '15 at 10:19