# tikz-Graph problem

I have the following graph which I defined:

\begin{figure}
\centering
\begin{tikzpicture}
[scale=.8,every node/.style={circle,fill=blue!20}]
\node (n1) at (1,10) {(D,D)};
\node (n2) at (3,8)  {(D,A)};
\node (n3) at (5,6)  {(D,N)};
\node (n4) at (7,4) {(D,O)};
\node (n5) at (7,2)  {\sout{(A,D)}};
\node (n6) at (5,0)  {(A,A)};
\node (n7) at (3,-2)  {(A,N)};
\node (n8) at (1,-4)  {(A,O)};
\node (n9) at (-1,-4)  {\sout{(N,D)}};
\node (n10) at (-3,-2)  {\sout{(N,A)}};
\node (n11) at (-5,0)  {(N,N)};
\node (n12) at (-7,2)  {(N,O)};
\node (n13) at (-7,4)  {(O,D)};
\node (n14) at (-5,6)  {(O,A)};
\node (n15) at (-3,8)  {(O,N)};
\node (n16) at (-1,10)  {(O,O)};

\path[->, every node/.style={font=\sffamily\small}]

(n1)    edge [bend right]  (n4)
edge [bend right]  (n3)
edge [bend right]  (n2)

(n2)    edge   (n6)
edge   (n7)
edge   (n8)

(n3)    edge   (n11)
edge   (n12)

(n4)    edge   (n13)
edge   (n14)
edge   (n15)
edge [bend left]  (n16)

(n6) edge [bend right]  (n7)
edge [bend right]  (n8)

(n7)    edge   (n11)
edge   (n12)

(n8)    edge   (n13)
edge   (n14)
edge   (n15)
edge   (n16)

(n12)    edge   (n13)
edge [bend right]  (n14)
edge [bend right]  (n15)
edge [bend right]  (n16)

(n13)    edge [bend right]  (n1)
edge   (n2)
edge   (n3)
edge   (n4)

(n14)    edge   (n6)
edge   (n7)
edge [bend left]  (n8)

(n15)    edge   (n11)
edge [bend left]  (n12)

(n16) edge [bend left]  (n13)
edge [bend left]  (n14)
edge [bend left]  (n15)

%selflloops for better graphic display:
(n1)  edge [loop above] node  (n1)

(n6)  edge [loop below] node  (n6)

(n11) edge [loop below] node  (n11)

(n16) edge [loop above] node  (n16)
%   (n11) edge [bend right] node  (n14)
%
\end{tikzpicture}
\caption{Graph with the possible states which could be reached.}
\end{figure}


But somehow I get the errors:

! Package tikz Error: (, +, coordinate, or node expected.

See the tikz package documentation for explanation.
Type  H <return>  for immediate help.
...

l.471 }

! Package tikz Error: A node must have a (possibly empty) label text.

See the tikz package documentation for explanation.
Type  H <return>  for immediate help.


Could somebody plz give me a hint how I could solve the paths properly?

• At the end of your code nodes need {} Commented Mar 25, 2014 at 20:59
• For solvers: +\usepackage{ulem}. Commented Mar 25, 2014 at 23:39

The problem was related to the selfloops: You tried to refer to its own nodes in an unusual way. I enclose the source code and a preview of the result.

%! *latex tikz-path.tex

\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{tikz}
\usepackage{ulem}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
[scale=.8,every node/.style={circle,fill=blue!20}]
\node (n1) at (1,10) {(D,D)};
\node (n2) at (3,8)  {(D,A)};
\node (n3) at (5,6)  {(D,N)};
\node (n4) at (7,4) {(D,O)};
\node (n5) at (7,2)  {\sout{(A,D)}};
\node (n6) at (5,0)  {(A,A)};
\node (n7) at (3,-2)  {(A,N)};
\node (n8) at (1,-4)  {(A,O)};
\node (n9) at (-1,-4)  {\sout{(N,D)}};
\node (n10) at (-3,-2)  {\sout{(N,A)}};
\node (n11) at (-5,0)  {(N,N)};
\node (n12) at (-7,2)  {(N,O)};
\node (n13) at (-7,4)  {(O,D)};
\node (n14) at (-5,6)  {(O,A)};
\node (n15) at (-3,8)  {(O,N)};
\node (n16) at (-1,10)  {(O,O)};

\path[->, every node/.style={font=\sffamily\small}]
(n1)    edge [bend right]  (n4)
edge [bend right]  (n3)
edge [bend right]  (n2)
(n2)    edge   (n6)
edge   (n7)
edge   (n8)
(n3)    edge   (n11)
edge   (n12)
(n4)    edge   (n13)
edge   (n14)
edge   (n15)
edge [bend left]  (n16)
(n6) edge [bend right]  (n7)
edge [bend right]  (n8)
(n7)    edge   (n11)
edge   (n12)
(n8)    edge   (n13)
edge   (n14)
edge   (n15)
edge   (n16)
(n12)    edge   (n13)
edge [bend right]  (n14)
edge [bend right]  (n15)
edge [bend right]  (n16)
(n13)    edge [bend right]  (n1)
edge   (n2)
edge   (n3)
edge   (n4)
(n14)    edge   (n6)
edge   (n7)
edge [bend left]  (n8)
(n15)    edge   (n11)
edge [bend left]  (n12)
(n16) edge [bend left]  (n13)
edge [bend left]  (n14)
edge [bend left]  (n15)
%selflloops for better graphic display:
(n1)  edge [loop above] (n1) %{}
(n6)  edge [loop below] (n6) %node  (n6) {}
(n11) edge [loop below] (n11) %node  (n11) {}
(n16) edge [loop above] (n16) %node  (n16) {}
(n11) edge [bend right] (n14);  %node  (n14) {};