I have 3 styles called S1, S2 and S3. I want to conditionally color the nodes.
I tried the \ifnum with no luck. You can see the single line of code
that has been commented out. That is what I conceptually want. This example
is for 3 by 3 grid, but my actual grid is 6 by 6, so it would be great if I could describe the nodes for S1 and S2 using some sort of set notation.

```
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
[S1/.style={circle,draw=black,fill=white!80!black,minimum size=20},
S2/.style={circle,draw=black,fill=red!40,minimum size=20},
S3/.style={circle,draw=black,fill=green!40,minimum size=20}]
\foreach \i in {1,...,9}
\foreach \i in {1,...,9}
{
    \pgfmathtruncatemacro{\y}{(\i - 1) / 3};
    \pgfmathtruncatemacro{\x}{\i - 3 * \y};
    \pgfmathtruncatemacro{\label}{\x + 3 * (2 - \y)};
%     \node[ IF \label = 4,6,8 THEN S1 ELSE IF \label=1,9 THEN S2 ELSE S3]
 \node[S3]
    (\label) at (1.5*\x,1.5*\y) {\label};
    \node[above right=0mm of \label]  {\scriptsize\label};
}
\draw (1) -- (2);
\draw (2) -- (3);
\draw (4) -- (5);
\draw (5) -- (6);
\draw (7) -- (8);
\draw (8) -- (9);

\draw (1) -- (4);
\draw (2) -- (5);
\draw (3) -- (6);
\draw (4) -- (7);
\draw (5) -- (8);
\draw (6) -- (9);

\end{tikzpicture}

\end{document}

```