Debian Codegraph @

texmf-dist/doc/latex/causets/causets_example2.tex

raw
1 \documentclass[tikz]{standalone}
2 \usepackage[black]{causets}
3 \usetikzlibrary{fit,shapes.geometric}
4 % Set colours and style:
5 \colorlet{future colour}{green!50!black}
6 \colorlet{past colour}{yellow!50!orange!80!black}
7 \colorlet{anywhere colour}{red!80!black}
8 \tikzset{prob arrow/.style={line width=1.5pt}}
9 % Define some helper functions:
10 \def\defCevents#1#2#3{\xdef\Ea{#1}\xdef\Eb{#2}\xdef\Ec{#3}}
11 \def\defDevents#1#2#3#4{\expandafter\defCevents#1#2#3\xdef\Ed{#4}}
12 \newcommand*{\semiopaque}[1]{% Adds a transparency group.
13 \begin{scope}[transparency group, opacity=0.5]
14 #1
15 \end{scope}
16 }
17 \newcommand*{\drawprobarrow}[4][]{% Draws a (probability) arrow.
18 \draw[prob arrow] (#2) -- node[sloped, midway, below, #1] {$#3$} (#4);
19 }
20 \newcommand{\drawlegendsymbol}{% Draws the symbol for a legend entry.
21 \draw[prob arrow] (0,0) -- +(10pt, 6pt);
22 }
23 \newcommand{\legendsymbol}[1]{% Creates the legend symbol.
24 \begin{tikzpicture}
25 \ifnum#1=0
26 \drawlegendsymbol
27 \else
28 \semiopaque{\drawlegendsymbol}
29 \fi
30 \end{tikzpicture}
31 }
32 \begin{document}
33 \begin{tikzpicture}[-stealth]
34 \def\ystep{2.0cm}
35 \def\xstep{0.60cm}
36 % Create nodes of all causets with 1 to 4 events:
37 \begin{scope}[nodes={draw, thin, circle, minimum size=1.1cm}]
38 \node (C1) at ( 0, 0) {\pcauset{1}};
39 \node (C12) at (-4*\xstep, 1*\ystep) {\pcauset{1,2}};
40 \node (C21) at ( 4*\xstep, 1*\ystep) {\pcauset{2,1}};
41 \foreach \perm [count=\i from 0] in {123, 132, 312, 213, 321}{%
42 \expandafter\defCevents\perm
43 \node (C\perm) at (4*\i*\xstep-8*\xstep, 2*\ystep) {\pcauset{\Ea,\Eb,\Ec}};
44 }
45 \foreach \perm [count=\i from 0] in {1234, 1243, 1423, 1324, 1432, 4123, 4132, 3124, 3412, 3142, 4312, 2134, 2143, 4213, 3214, 4321}{%
46 \expandafter\defDevents\perm
47 \node (C\perm) at (2*\i*\xstep-15*\xstep, 3.75*\ystep) {\pcauset{\Ea,\Eb,\Ec,\Ed}};
48 }
49 \end{scope}
50 % Add graph edges for expandings ...
51 % ... to the past (additionally):
52 \begin{scope}[past colour]
53 \foreach \perma/\permb in {12/213, 123/3124, 123/2134, 132/1243, 132/3142, 132/2143, 312/1423, 312/4213, 213/1324, 213/3124, 213/3214, 321/1432, 321/4132, 21/132}
54 \semiopaque{\drawprobarrow{C\perma}{}{C\permb}};
55 \end{scope}
56 % ... to anywhere (additionally, further):
57 \begin{scope}[anywhere colour]
58 \semiopaque{\drawprobarrow{C123}{}{C1324}};
59 \end{scope}
60 % ... to the future:
61 \begin{scope}[prob arrow, future colour]
62 \drawprobarrow{C1}{p_{12}}{C12}
63 \drawprobarrow{C12}{p_{123}}{C123}
64 \drawprobarrow{C123}{p_{1234}}{C1234}
65 \drawprobarrow[near end]{C123}{p_{1243}}{C1243}
66 \drawprobarrow[near end]{C123}{p_{1423}}{C1423}
67 \drawprobarrow[near start, above]{C123}{p_{4123}}{C4123}
68 \drawprobarrow[above]{C12}{p_{132}}{C132}
69 \drawprobarrow[near end]{C132}{p_{1342}}{C1423}
70 \drawprobarrow[near end]{C132}{p_{1324}}{C1324}
71 \drawprobarrow[midway, above]{C132}{p_{1432}}{C1432}
72 \drawprobarrow[near start]{C132}{p_{4132}}{C4132}
73 \drawprobarrow[near start, above]{C12}{p_{312}}{C312}
74 \drawprobarrow[near end]{C312}{p_{3124}}{C3124}
75 \drawprobarrow[near end]{C312}{p_{3412}}{C3412}
76 \drawprobarrow[near end]{C312}{p_{3142}}{C3142}
77 \drawprobarrow[near start]{C312}{p_{4312}}{C4312}
78 \drawprobarrow{C1}{p_{21}}{C21}
79 \drawprobarrow[near start, above]{C21}{p_{231}}{C312}
80 \drawprobarrow[near start]{C312}{p_{2341}}{C4123}
81 \drawprobarrow[near end]{C312}{p_{2431}}{C4132}
82 \drawprobarrow{C21}{p_{213}}{C213}
83 \drawprobarrow[above]{C213}{p_{2134}}{C2134}
84 \drawprobarrow[near start]{C213}{p_{2413}}{C3142}
85 \drawprobarrow[near end]{C213}{p_{2143}}{C2143}
86 \drawprobarrow[near end]{C213}{p_{4213}}{C4213}
87 \drawprobarrow{C21}{p_{321}}{C321}
88 \drawprobarrow[near start, above]{C321}{p_{3421}}{C4312}
89 \drawprobarrow[near end]{C321}{p_{3241}}{C4213}
90 \drawprobarrow[near end]{C321}{p_{3214}}{C3214}
91 \drawprobarrow{C321}{p_{4321}}{C4321}
92 \end{scope}
93 % Add legend:
94 \node[above left, align=left, draw, inner sep=3ex, fill=gray!05]
95 at (15*\xstep, 0)
96 {Expanding towards\\
97 \bfseries\color{future colour}\legendsymbol{0}\ the future\\
98 \bfseries\color{past colour}\legendsymbol{1}\ + the past\\
99 \bfseries\color{anywhere colour}\legendsymbol{1}\ + anywhere};
100 \end{tikzpicture}
101 \end{document}