-
Notifications
You must be signed in to change notification settings - Fork 4
/
dm_tikz_makros.tex
53 lines (49 loc) · 1.3 KB
/
dm_tikz_makros.tex
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
% this file contains tikz-makros
% counter for numbering the nodes
\newcounter{nodecount}
% #1 ... list of degrees, where the nodes are placed
% #2 ... radius of the node-placement
\def \fullyConnectedGraph #1#2{%
\setcounter{nodecount}{0}
\foreach \x in {#1}
{
\stepcounter{nodecount}
\node (n\the\value{nodecount}) at (\x:#2) {};
};
\foreach \i in {1,...,\the\value{nodecount}}
{
\fill (n\i) circle(2pt);
\foreach \j in {\i,...,\the\value{nodecount}}
{
\path (n\i) edge (n\j);
};
};%
}
% draw a graph
% #1 ... list of x/y coordinates for the nodes
% #2 ... list of pahtes between nodes, beginning with 1
\def \drawGraph #1#2{%
\setcounter{nodecount}{0}
\foreach \x/\y in {#1} {
\stepcounter{nodecount}
\node (n\the\value{nodecount}) at (\x,\y) {};
\fill (n\the\value{nodecount}) circle(2pt);
};
\foreach \i/\j in {#2} {
\path (n\i) edge (n\j);
};
}
% draw a directed graph
% #1 ... list of x/y coordinates for the nodes
% #2 ... list of pahtes between nodes, beginning with 1
\def \drawDirGraph #1#2{%
\setcounter{nodecount}{0}
\foreach \x/\y in {#1} {
\stepcounter{nodecount}
\node (n\the\value{nodecount}) at (\x,\y) {};
\fill (n\the\value{nodecount}) circle(2pt);
};
\foreach \i/\j in {#2} {
\path (n\i) edge[->] (n\j);
};
}