Individual node colors in TiKZ

I have the following code:

 \begin{tikzpicture}
\graph[circular placement,
empty nodes, nodes={circle,draw, minimum size=0.01cm}] {
\foreach \x in {a,...,c} {
\foreach \y in {\x,...,c} {
\x -- \y;
};
};
};
\draw (a) edge[red, thick] (b);
\draw (b) edge[red, thick] (c);
\draw (c) edge[blue, thick] (a);
\end{tikzpicture}


which produces a complete graph with the edges colored red/blue. I want to color node (a) blue and (b), (c) red. Or some other configuration. I can use the fill=red!30 in the nodes={} area, but this causes all of the nodes to be red. How can I specify a single node?

In general, is there a way to fill color a specific node?

Something like this?

\documentclass[border=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs}
\begin{document}

\begin{tikzpicture}
\graph[counterclockwise=6,
empty nodes, nodes={circle,draw, minimum size=0.01cm}] {
a[fill=blue],  b[fill=red], c[fill=red]
};
\draw (a) edge[red, thick] (b);
\draw (b) edge[red, thick] (c);
\draw (c) edge[blue, thick] (a);
\end{tikzpicture}
\end{document}

• Almost, but this seems "hard coded" for $K_{3}$ and I also only care about the fill color of the nodes. Is there no way to do something like '\node (a) fill=red!30' ? I also have much large graphs where I want to fill color individual nodes. Nov 1 '15 at 18:06
• @Ozera If you just want to fill, add only fill=red in the node options. Nov 1 '15 at 18:12
• Oh wow so it is simply a[fill=red] if I want to fill color the node (a) red! Thank you. Nov 1 '15 at 18:15
• @TorbjornT., your solution work only with LuaLaTeX. However, if you not use library graphdrawing, your solution also work in pgfLaTeX. Also -- before node b and -> before node c seems to be unnecessary. Nov 1 '15 at 18:21
• @Zarko Meant to remove those, were left over from testing, thanks. You're also right about graphdrawing, I'm just not that familiar with these kinds of things (not something I've ever needed), so I don't know exactly which libraries are needed. I removed that library. Nov 1 '15 at 18:24

You can use a conditional fill for your convenience. For the first node only you should add \x[fill={\ifnum\i=1 blue\else white\fi}], but for all other nodes, you can add \y[fill={\ifnum\j=2 red\else\ifnum\j=3 red\else white\fi\fi}]. Sure, you can choose any number of desired nodes individually.

\documentclass[border=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs}
\begin{document}

\begin{tikzpicture}
\graph[circular placement,
empty nodes, nodes={circle,draw, minimum size=0.01cm}] {
\foreach \x[count=\i] in {a,...,c} {
\foreach \y[count=\j] in {\x,...,c} {
\x[fill={\ifnum\i=1 blue\else white\fi}] -- \y[fill={\ifnum\j=2 red\else\ifnum\j=3 red\else white\fi\fi}];
};
};
};
\draw (a) edge[red, thick] (b);
\draw (b) edge[red, thick] (c);
\draw (c) edge[blue, thick] (a);
\end{tikzpicture}

\end{document}


• Ah this is also great information! Thank you for taking the time to help me answer my question. Nov 1 '15 at 18:38