[Tex/LaTex] Problems with the `graphs` library

graphstikz-graphstikz-pgf

According to the documentation for version 3.0.0 of PGF/TikZ (Section 19 Specifying Graphs, page 258), the powerful graphs library:

[…] offers a powerful path command for specifying how the nodes in a
graph are connected by edges and arcs: The graph path command, which
becomes available when you load the graphs library.

A few lines below there are some examples of the use of the path; amongst those examples one finds:

\tikz
  \graph [nodes={draw, circle}, clockwise, radius=.5cm, empty nodes, n=5] {
    subgraph I_n [name=inner] --[complete bipartite]
    subgraph I_n [name=outer]
};

and

\tikz
\graph [nodes={draw, circle}, clockwise, radius=.75cm, empty nodes, n=8] {
subgraph C_n [name=inner] <->[shorten <=1pt, shorten >=1pt]
subgraph C_n [name=outer]
};

which should produce the following images (taking directly from the documentation):

enter image description here

However, when I try the exact same code in a "real" document:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs}

\begin{document}

 \tikz
  \graph [nodes={draw, circle}, clockwise, radius=.5cm, empty nodes, n=5] {
    subgraph I_n [name=inner] --[complete bipartite]
    subgraph I_n [name=outer]
};
\tikz
  \graph [nodes={draw, circle}, clockwise, radius=.75cm, empty nodes, n=8] {
    subgraph C_n [name=inner] <->[shorten <=1pt, shorten >=1pt]
    subgraph C_n [name=outer]
};


\end{document}

This is all I get (image zoomed at 400%):

enter image description here

Even more disppointing is the following example on page 276:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs}

\begin{document}

\tikz \graph [simple] {
subgraph K_n [n=8, clockwise];
% Get rid of the following edges:
1 -!- 2;
3 -!- 4;
6 -!- 8;
% And make one edge red:
1 --[red] 3;
};

\end{document}

The documentation shows this as the result:

enter image description here

but I only get an error message:

! Missing $ inserted.
<inserted text> 
$
l.15 }
    ;
? 

Am I missing something? Is some other library required in order to get the expected graphs?

Best Answer

Based on looking through the pgf documentation's LaTeX source and also this answer, I believe that the documentation should list that both the graphs and graphs.standard libraries are included to produce these graphics.

All your examples work if I use \usetikzlibrary{graphs,graphs.standard} instead of only \usetikzlibrary{graphs}. Here is one sample:

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard} % both are required, in this order

\begin{document}
\tikz \graph [simple] {
  subgraph K_n [n=8, clockwise];
  % Get rid of the following edges:
  1 -!- 2;
  3 -!- 4;
  6 -!- 8;
  % And make one edge red:
  1 --[red] 3;
};
\end{document}

Output

enter image description here