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