You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.5 KiB
109 lines
2.5 KiB
% 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}
|
|
|
|
\usetikzlibrary{graphs}%
|
|
|
|
%
|
|
% 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]
|
|
}
|
|
},
|
|
}%
|
|
|