[Tex/LaTex] How to mark a node in a graph with a pattern

graphstikz-pgf

I would like to mark my nodes in a graph without using colors because it will be printed in black and white. For example by drawing a vertical line in the first vertex, a horizontal line in the second, two lines in the third,… . Or if there is a better way to do this, I would like to here it.

Thank you for your time.

\documentclass[a4paper,11pt,titlepage]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{figure*}[h!]
\centering
\begin{tikzpicture}[node distance=1.5cm,>=stealth',bend angle=45,auto]
    \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,fill=red!20,inner sep=0.05cm] (1) {$v_{1}$};
    \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,fill=green!20,inner sep=0.05cm, below of=1, xshift=2cm] (2) {$v_{2}$};
    \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,fill=cyan!20,inner sep=0.05cm,right of=2, xshift=1cm] (3) {$v_{3}$};
    \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,fill=purple!30,inner sep=0.05cm,below of=2, xshift=1.5cm] (5) {$v_{5}$};
    \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,fill=red!20,inner sep=0.05cm,below of=2, xshift=-2cm] (4) {$v_{4}$};

\end{tikzpicture}
\end{figure*}

\end{document}

Best Answer

Instead of patterns, I would recommend that you use a combination of different shadings, and line styles (thin, thick, ultra thick, or even draw=none) to distinguish the nodes. You can also adjust the text color (as suggested by @Jake), and use dotted or dashed lines (a few of which are probably to be avoided):

enter image description here

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}

\tikzset{every node/.append style={minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,inner sep=0.05cm}}%

\begin{document}
\begin{tikzpicture}
    \node[fill=gray!5,               thin     ] (1a) {$u_{1}$};
    \node[fill=gray!10, right of=1a, thick    ] (2a) {$u_{2}$};
    \node[fill=gray!30, right of=2a, thin     ] (3a) {$u_{3}$};
    \node[fill=gray!60, right of=3a, thick    ] (4a) {$u_{4}$};
    \node[fill=gray!30, right of=4a, draw=none] (5a) {$u_{5}$};

    \node[fill=black!10, below of=1a, thin     ,text=white] (1b) {$v_{1}$};
    \node[fill=black!10, right of=1b, thick    ,text=white] (2b) {$v_{2}$};
    \node[fill=black!30, right of=2b, thin     ,text=white] (3b) {$v_{3}$};
    \node[fill=black!60, right of=3b, thick    ,text=white] (4b) {$v_{4}$};
    \node[fill=black!30, right of=4b, draw=none,text=white] (5b) {$v_{5}$};

    \node[fill=black!10, below of=1b, thin     ,text=gray] (1c) {$x_{1}$};
    \node[fill=black!10, right of=1c, thick    ,text=gray] (2c) {$x_{2}$};
    \node[fill=black!30, right of=2c, thin     ,text=gray] (3c) {$x_{3}$};
    \node[fill=black!60, right of=3c, thick    ,text=gray] (4c) {$x_{4}$};
    \node[fill=black!30, right of=4c, draw=none,text=gray] (5c) {$x_{5}$};

    \node[fill=black!10, below of=1c, thin     ,dashed] (1d) {$y_{1}$};
    \node[fill=black!10, right of=1d, thick    ,dashed] (2d) {$y_{2}$};
    \node[fill=black!30, right of=2d, thin     ,dashed] (3d) {$y_{3}$};
    \node[fill=black!60, right of=3d, thick    ,dashed] (4d) {$y_{4}$};
    \node[fill=black!30, right of=4d, draw=none,dashed] (5d) {$y_{5}$};

    \node[fill=black!10, below of=1d, thin     ,dotted] (1e) {$z_{1}$};
    \node[fill=black!10, right of=1e, thick    ,dotted] (2e) {$z_{2}$};
    \node[fill=black!30, right of=2e, thin     ,dotted] (3e) {$z_{3}$};
    \node[fill=black!60, right of=3e, thick    ,dotted] (4e) {$z_{4}$};
    \node[fill=black!30, right of=4e, draw=none,dotted] (5e) {$z_{5}$};
\end{tikzpicture}
\end{document}