equal
deleted
inserted
replaced
12 * express or implied, and with no claim as to its suitability for any |
12 * express or implied, and with no claim as to its suitability for any |
13 * purpose. |
13 * purpose. |
14 * |
14 * |
15 */ |
15 */ |
16 |
16 |
17 #include<lemon/graph_to_eps.h> |
17 /// \ingroup demos |
18 #include<lemon/maps.h> |
18 /// \file |
19 #include<lemon/list_graph.h> |
19 /// \brief Demo of the graph grawing function \ref graphToEps() |
20 #include<lemon/graph_utils.h> |
20 /// |
|
21 /// This demo program shows examples how to use the function \ref |
|
22 /// graphToEps(). It takes no input but simply creates six |
|
23 /// <tt>.eps</tt> files demonstrating how to draw directed/undirected |
|
24 /// graphs, how to handle parallel egdes, how to change the properties |
|
25 /// (like color, shape, size, title etc.) of nodes and edges |
|
26 /// individually using appropriate \ref maps-page "graphmaps". |
21 |
27 |
22 #include <cmath> |
28 #include <cmath> |
23 |
29 |
|
30 #include<lemon/graph_to_eps.h> |
|
31 #include<lemon/list_graph.h> |
24 |
32 |
25 using namespace std; |
33 using namespace std; |
26 using namespace lemon; |
34 using namespace lemon; |
27 |
35 |
28 int main() |
36 int main() |
64 e=g.addEdge(n2,n4); ecolors[e]=1; widths[e]=2; |
72 e=g.addEdge(n2,n4); ecolors[e]=1; widths[e]=2; |
65 e=g.addEdge(n3,n4); ecolors[e]=2; widths[e]=1; |
73 e=g.addEdge(n3,n4); ecolors[e]=2; widths[e]=1; |
66 |
74 |
67 IdMap<ListGraph,Node> id(g); |
75 IdMap<ListGraph,Node> id(g); |
68 |
76 |
|
77 cout << "Create 'graph_to_eps_demo_out.eps'" << endl; |
69 graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords). |
78 graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords). |
70 title("Sample .eps figure"). |
79 title("Sample .eps figure"). |
71 copyright("(C) 2005 LEMON Project"). |
80 copyright("(C) 2005 LEMON Project"). |
72 nodeScale(2).nodeSizes(sizes). |
81 nodeScale(2).nodeSizes(sizes). |
73 nodeShapes(shapes). |
82 nodeShapes(shapes). |
75 edgeColors(composeMap(colorSet,ecolors)). |
84 edgeColors(composeMap(colorSet,ecolors)). |
76 edgeWidthScale(.4).edgeWidths(widths). |
85 edgeWidthScale(.4).edgeWidths(widths). |
77 nodeTexts(id).nodeTextSize(3). |
86 nodeTexts(id).nodeTextSize(3). |
78 run(); |
87 run(); |
79 |
88 |
|
89 |
|
90 cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl; |
80 graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10). |
91 graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10). |
81 title("Sample .eps figure (with arrowheads)"). |
92 title("Sample .eps figure (with arrowheads)"). |
82 copyright("(C) 2005 LEMON Project"). |
93 copyright("(C) 2005 LEMON Project"). |
83 nodeColors(composeMap(colorSet,colors)). |
94 nodeColors(composeMap(colorSet,colors)). |
84 coords(coords). |
95 coords(coords). |
99 e=g.addEdge(n1,n2); ecolors[e]=4; widths[e]=1; |
110 e=g.addEdge(n1,n2); ecolors[e]=4; widths[e]=1; |
100 e=g.addEdge(n1,n2); ecolors[e]=5; widths[e]=1; |
111 e=g.addEdge(n1,n2); ecolors[e]=5; widths[e]=1; |
101 e=g.addEdge(n1,n2); ecolors[e]=6; widths[e]=1; |
112 e=g.addEdge(n1,n2); ecolors[e]=6; widths[e]=1; |
102 e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1; |
113 e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1; |
103 |
114 |
|
115 cout << "Create 'graph_to_eps_demo_out_par.eps'" << endl; |
104 graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10). |
116 graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10). |
105 title("Sample .eps figure (parallel edges)"). |
117 title("Sample .eps figure (parallel edges)"). |
106 copyright("(C) 2005 LEMON Project"). |
118 copyright("(C) 2005 LEMON Project"). |
107 nodeShapes(shapes). |
119 nodeShapes(shapes). |
108 coords(coords). |
120 coords(coords). |
112 edgeWidthScale(.4).edgeWidths(widths). |
124 edgeWidthScale(.4).edgeWidths(widths). |
113 nodeTexts(id).nodeTextSize(3). |
125 nodeTexts(id).nodeTextSize(3). |
114 enableParallel().parEdgeDist(1.5). |
126 enableParallel().parEdgeDist(1.5). |
115 run(); |
127 run(); |
116 |
128 |
|
129 cout << "Create 'graph_to_eps_demo_out_par_arr.eps'" << endl; |
117 graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10). |
130 graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10). |
118 title("Sample .eps figure (parallel edges and arrowheads)"). |
131 title("Sample .eps figure (parallel edges and arrowheads)"). |
119 copyright("(C) 2005 LEMON Project"). |
132 copyright("(C) 2005 LEMON Project"). |
120 nodeScale(2).nodeSizes(sizes). |
133 nodeScale(2).nodeSizes(sizes). |
121 coords(coords). |
134 coords(coords). |
126 nodeTexts(id).nodeTextSize(3). |
139 nodeTexts(id).nodeTextSize(3). |
127 enableParallel().parEdgeDist(1). |
140 enableParallel().parEdgeDist(1). |
128 drawArrows().arrowWidth(1).arrowLength(1). |
141 drawArrows().arrowWidth(1).arrowLength(1). |
129 run(); |
142 run(); |
130 |
143 |
|
144 cout << "Create 'graph_to_eps_demo_out_a4.eps'" << endl; |
131 graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4(). |
145 graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4(). |
132 title("Sample .eps figure (fits to A4)"). |
146 title("Sample .eps figure (fits to A4)"). |
133 copyright("(C) 2005 LEMON Project"). |
147 copyright("(C) 2005 LEMON Project"). |
134 nodeScale(2).nodeSizes(sizes). |
148 nodeScale(2).nodeSizes(sizes). |
135 coords(coords). |
149 coords(coords). |
151 Node n=h.addNode(); |
165 Node n=h.addNode(); |
152 hcoords[n]=Xy(i%cols,i/cols); |
166 hcoords[n]=Xy(i%cols,i/cols); |
153 hcolors[n]=i; |
167 hcolors[n]=i; |
154 } |
168 } |
155 |
169 |
|
170 cout << "Create 'graph_to_eps_demo_out_colors.eps'" << endl; |
156 graphToEps(h,"graph_to_eps_demo_out_colors.eps").scale(60). |
171 graphToEps(h,"graph_to_eps_demo_out_colors.eps").scale(60). |
157 title("Sample .eps figure (parallel edges and arrowheads)"). |
172 title("Sample .eps figure (ColorSet demo)"). |
158 copyright("(C) 2005 LEMON Project"). |
173 copyright("(C) 2005 LEMON Project"). |
159 coords(hcoords). |
174 coords(hcoords). |
160 nodeScale(.45). |
175 nodeScale(.45). |
161 distantColorNodeTexts(). |
176 distantColorNodeTexts(). |
162 // distantBWNodeTexts(). |
177 // distantBWNodeTexts(). |