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):
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%):
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:
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?
graphs
andgraphs.standard
libraries are loaded (in that order). I don't see why this requirement would be intentional... maybe a bug?subgraph
keyword. It is not documented (alone)... and it offers no protection against errors: you may use any word after it without error (and without effect).graphs
as being needed, so I wasn't sure if this was expected/intended or not.graphs.standard
is required to usesubgraph K_n
orsubgraph I_n
. The documentation only listsgraphs
becausesubgraph ...
is used only to built an arbitrary graph in these examples.