I have a graph which I draw with my own command. I have to use that very often but normally in different colors. There are no problems with edges becaus I simply can use \draw[style=green](x)--(y)
to color the edge (x,y) green. But I also want to do that with specific nodes e.g: the node v1 should be red.
Here is my command:
\newcommand{\mygraph}{
\node[](x) at (0,0){$x$};
\node[](y) at (0,-4){$y$};
\foreach \a in {1,...,5}{
\node[](v\a) at (\a*180/6:4) {$v_\a$};
}
\foreach \a in {1,...,5}{
\draw (x)--(v\a);
}
}
And how I use it:
\begin{figure}[h]
\centering
\begin{tikzpicture}
\mygraph
\draw[dotted](x)--(y);
\draw[style=green](x)--(v1);
\end{tikzpicture}
\caption{Graph $G$}
\end{figure}
So is there a possibility to take one of the nodes and recolor it?