1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
% Copyright 2010 by Till Tantau
% Copyright 2011 by Jannis Pohlmann
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.
\ProvidesFileRCS{tikzlibrarygraphs.standard.code.tex}
%
% Basic graphs
%
\tikzgraphsset{
%
% An independent set $V$ of nodes.
%
declare={subgraph I_n}%
{
\foreach \tikz@lib@graph@node@num in \tikzgraphV
{ \tikz@lib@graph@node@num }
},
%
% An two-shore independent set $V$ with shores V and W.
%
declare={subgraph I_nm}%
{
subgraph I_n [name shore V] -- [no edges]
subgraph I_n [name shore W, V/.expand once=\tikzgraphW]
},
%
% The complete clique on $V$.
%
declare={subgraph K_n}%
{
[clique]
subgraph I_n
},
%
% A complete bipartite graph with shores V and W.
%
declare={subgraph K_nm}%
{
[color class=shore V,
color class=shore W,
complete bipartite={shore V}{shore W}]
subgraph I_n [name shore V, shore V] -- [no edges]
subgraph I_n [name shore W, V/.expand once=\tikzgraphW, shore W]
},
%
% A cycle with n nodes.
%
declare={subgraph C_n}%
{
[cycle]
subgraph I_n
},
%
% A path with n nodes.
%
declare={subgraph P_n}%
{
[path]
subgraph I_n
},
%
% A grid with n nodes.
%
declare={subgraph Grid_n}%
{
[grid]
subgraph I_n
},
%
% A random graph according to the G_{n,p} model: For each pair of
% vertices there is an edge between them with probability p.
%
p/.initial=0.5,
declare={subgraph G_np}%
{
[/utils/exec={
\pgfmathsetmacro\tikz@lib@lg@p{\pgfkeysvalueof{/tikz/graphs/p}}
\let\tikz@lib@gnp@edges\pgfutil@empty%
\foreach \tikz@lib@graph@node@a [count=\tikz@lib@g@count@a] in \tikzgraphV
\foreach \tikz@lib@graph@node@b [count=\tikz@lib@g@count@b] in \tikzgraphV
{
\ifnum\tikz@lib@g@count@a<\tikz@lib@g@count@b\relax
\pgfmathparse{rnd}
\ifdim\pgfmathresult pt<\tikz@lib@lg@p pt%
\ifx\tikz@lib@gnp@edges\pgfutil@empty
\xdef\tikz@lib@gnp@edges{\tikz@lib@graph@node@a--\tikz@lib@graph@node@b}%
\else
\xdef\tikz@lib@gnp@edges{\tikz@lib@gnp@edges,\tikz@lib@graph@node@a--\tikz@lib@graph@node@b}%
\fi
\fi
\fi
}
}]
\foreach \tikz@lg@temp in \tikz@lib@gnp@edges {
[parse/.expand once=\tikz@lg@temp]
}
},
}%
|