Mercurial > hg > truffle
comparison doc/design/graphdrawing.tex @ 2517:8c6e31c62fba
added initial version of design docs, fixed .hgignore (regex, . -> \.)
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 27 Apr 2011 15:59:38 +0200 |
parents | |
children | 550b291f56c4 |
comparison
equal
deleted
inserted
replaced
2513:3452f96a1139 | 2517:8c6e31c62fba |
---|---|
1 | |
2 % graph drawing | |
3 \newcommand{\digraph}[3][scale=1]{ | |
4 \newwrite\dotfile | |
5 \immediate\openout\dotfile=dot_temp_#2.dot | |
6 \immediate\write\dotfile{digraph dot_temp_#2 {\string#3}} | |
7 \immediate\closeout\dotfile | |
8 \immediate\write18{bash -c "dot -Tpdf dot_temp_#2.dot > dot_temp_#2.pdf"} | |
9 \IfFileExists{dot_temp_#2.pdf} | |
10 % the pdf exists: include it | |
11 { \includegraphics[#1]{dot_temp_#2} } | |
12 % the pdf was not created - show a hint | |
13 { \fbox{ \begin{tabular}{l} | |
14 The file \texttt{dot_temp_#2.pdf} hasn't been created from | |
15 \texttt{dot_temp_#2.dot} yet. \\ | |
16 We attempted to create it with:\\ | |
17 `\texttt{dot -Tpdf dot_temp_#2.dot > dot_temp_#2.pdf}' \\ | |
18 but that seems not to have worked. You need to execute `\texttt{pdflatex}' with \\ | |
19 the `\texttt{-shell-escape} option. | |
20 \end{tabular}} | |
21 } | |
22 } | |
23 | |
24 \NewEnviron{digraphenv}[2]{\digraph[#1]{#2}{ margin=0; pad=0; \BODY }} | |
25 | |
26 \newcommand{\control}[2]{#1:successors:s -> #2:predecessors:n [color=red];} | |
27 \newcommand{\controllabel}[2]{#1 -> #2:predecessors:n [color=red];} | |
28 \newcommand{\data}[2]{#2:usages:s -> #1:inputs [color=black,dir=back];} | |
29 \newcommand{\datalabel}[2]{#2:usages:s -> #1:n [color=black,dir=back];} | |
30 | |
31 \newcommand{\genericnodestart}[1]{#1 [shape=plaintext, label=< <TABLE BORDER="0" CELLSPACING="0"><TR><TD CELLPADDING="0"><TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0"><TR><TD WIDTH="15" HEIGHT="5" PORT="predecessors" BGCOLOR="rosybrown1"></TD></TR></TABLE></TD><TD COLSPAN="2" CELLPADDING="0" ALIGN="RIGHT"><TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0"><TR>} | |
32 \newcommand{\genericnodeend}[0]{</TR></TABLE></TD><TD CELLPADDING="0"><TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0"><TR><TD WIDTH="15" HEIGHT="5" PORT="usages" BGCOLOR="lightgrey"></TD></TR></TABLE></TD></TR></TABLE>>]} | |
33 \newcommand{\portinput}[1]{<TD WIDTH="15" HEIGHT="5" PORT="#1" BGCOLOR="lightgrey"></TD>} | |
34 \newcommand{\portsuccessor}[1]{<TD WIDTH="15" HEIGHT="5" PORT="#1" BGCOLOR="rosybrown1"></TD>} | |
35 \newcommand{\portempty}[0]{<TD WIDTH="15" HEIGHT="5"></TD>} | |
36 \newcommand{\genericnodelabel}[1]{</TR></TABLE></TD></TR><TR><TD BORDER="1" COLSPAN="3">#1</TD></TR><TR><TD COLSPAN="2" CELLPADDING="0" ALIGN="RIGHT"><TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0"><TR>} | |
37 | |
38 \newcommand{\node}[2]{\genericnodestart{#1} \portempty \portinput{inputs} \genericnodelabel{#2} \portsuccessor{successors} \portempty \genericnodeend } | |
39 \newcommand{\nodebi}[2]{\genericnodestart{#1} \portinput{in1} \portinput{in2} \genericnodelabel{#2} \portsuccessor{successors} \portempty \genericnodeend } | |
40 \newcommand{\nodetri}[2]{\genericnodestart{#1} \portinput{in1} \portinput{in2} \portinput{in3} \genericnodelabel{#2} \portsuccessor{successors} \portempty \portempty \genericnodeend } | |
41 \newcommand{\nodesplit}[2]{\genericnodestart{#1} \portempty \portinput{inputs} \genericnodelabel{#2} \portsuccessor{succ1} \portsuccessor{succ2} \genericnodeend } | |
42 | |
43 %%%%%%%%%%%%%% example: | |
44 | |
45 % \begin{digraphenv}{scale=0.5}{MyGraph} | |
46 % \node{start}{start} | |
47 % \node{end}{end} | |
48 % % input projections | |
49 % \node{a}{proj:a} | |
50 % \node{b}{proj:b} | |
51 % \data{a}{start} | |
52 % \data{b}{start} | |
53 % % if | |
54 % \nodebi{cmp1}{<} | |
55 % \datalabel{cmp1:in1}{a} | |
56 % \datalabel{cmp1:in2}{b} | |
57 % \nodesplit{if}{if} | |
58 % \data{if}{cmp1} | |
59 % \control{start}{if} | |
60 % % branches | |
61 % \nodebi{add1}{+} | |
62 % \datalabel{add1:in1}{a} | |
63 % \datalabel{add1:in2}{b} | |
64 % \nodebi{sub1}{-} | |
65 % \datalabel{sub1:in1}{a} | |
66 % \datalabel{sub1:in2}{b} | |
67 % \controllabel{if:succ1}{add1} | |
68 % \controllabel{if:succ2}{sub1} | |
69 % % merge | |
70 % \nodebi{merge}{merge} | |
71 % \control{add1}{merge} | |
72 % \control{sub1}{merge} | |
73 % % phi | |
74 % \nodebi{phi1}{phi} | |
75 % \datalabel{phi1:in1}{add1} | |
76 % \datalabel{phi1:in2}{sub1} | |
77 % % ret | |
78 % \node{ret}{ret} | |
79 % \data{ret}{phi1} | |
80 % \control{merge}{ret} | |
81 % \control{ret}{end} | |
82 % \end{digraphenv} | |
83 | |
84 %%%%%%%%%%%%%%% |