Aliases added to some graphToEps() named params.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
21 /// \brief Demo of the graph grawing function \ref graphToEps()
23 /// This demo program shows examples how to use the function \ref
24 /// graphToEps(). It takes no input but simply creates six
25 /// <tt>.eps</tt> files demonstrating the capability of \ref
26 /// graphToEps(), and showing how to draw directed/graphs,
27 /// how to handle parallel egdes, how to change the properties (like
28 /// color, shape, size, title etc.) of nodes and arcs individually
29 /// using appropriate \ref maps-page "graph maps".
31 /// \include graph_to_eps_demo.cc
33 #include <lemon/math.h>
35 #include<lemon/graph_to_eps.h>
36 #include<lemon/list_graph.h>
37 #include<lemon/graph_utils.h>
40 using namespace lemon;
45 Palette paletteW(true);
48 typedef ListDigraph::Node Node;
49 typedef ListDigraph::NodeIt NodeIt;
50 typedef ListDigraph::Arc Arc;
51 typedef dim2::Point<int> Point;
59 ListDigraph::NodeMap<Point> coords(g);
60 ListDigraph::NodeMap<double> sizes(g);
61 ListDigraph::NodeMap<int> colors(g);
62 ListDigraph::NodeMap<int> shapes(g);
63 ListDigraph::ArcMap<int> ecolors(g);
64 ListDigraph::ArcMap<int> widths(g);
66 coords[n1]=Point(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
67 coords[n2]=Point(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2;
68 coords[n3]=Point(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0;
69 coords[n4]=Point(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1;
70 coords[n5]=Point(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
74 e=g.addArc(n1,n2); ecolors[e]=0; widths[e]=1;
75 e=g.addArc(n2,n3); ecolors[e]=0; widths[e]=1;
76 e=g.addArc(n3,n5); ecolors[e]=0; widths[e]=3;
77 e=g.addArc(n5,n4); ecolors[e]=0; widths[e]=1;
78 e=g.addArc(n4,n1); ecolors[e]=0; widths[e]=1;
79 e=g.addArc(n2,n4); ecolors[e]=1; widths[e]=2;
80 e=g.addArc(n3,n4); ecolors[e]=2; widths[e]=1;
82 IdMap<ListDigraph,Node> id(g);
84 cout << "Create 'graph_to_eps_demo_out_pure.eps'" << endl;
85 graphToEps(g,"graph_to_eps_demo_out_pure.eps").
88 title("Sample .eps figure").
89 copyright("(C) 2003-2007 LEMON Project").
92 cout << "Create 'graph_to_eps_demo_out.eps'" << endl;
93 graphToEps(g,"graph_to_eps_demo_out.eps").
96 title("Sample .eps figure").
97 copyright("(C) 2003-2007 LEMON Project").
98 absoluteNodeSizes().absoluteArcWidths().
99 nodeScale(2).nodeSizes(sizes).
101 nodeColors(composeMap(palette,colors)).
102 arcColors(composeMap(palette,ecolors)).
103 arcWidthScale(.4).arcWidths(widths).
104 nodeTexts(id).nodeTextSize(3).
108 cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl;
109 graphToEps(g,"graph_to_eps_demo_out_arr.eps").
111 title("Sample .eps figure (with arrowheads)").
112 copyright("(C) 2003-2007 LEMON Project").
113 absoluteNodeSizes().absoluteArcWidths().
114 nodeColors(composeMap(palette,colors)).
116 nodeScale(2).nodeSizes(sizes).
118 arcColors(composeMap(palette,ecolors)).
119 arcWidthScale(.4).arcWidths(widths).
120 nodeTexts(id).nodeTextSize(3).
121 drawArrows().arrowWidth(1).arrowLength(1).
124 e=g.addArc(n1,n4); ecolors[e]=2; widths[e]=1;
125 e=g.addArc(n4,n1); ecolors[e]=1; widths[e]=2;
127 e=g.addArc(n1,n2); ecolors[e]=1; widths[e]=1;
128 e=g.addArc(n1,n2); ecolors[e]=2; widths[e]=1;
129 e=g.addArc(n1,n2); ecolors[e]=3; widths[e]=1;
130 e=g.addArc(n1,n2); ecolors[e]=4; widths[e]=1;
131 e=g.addArc(n1,n2); ecolors[e]=5; widths[e]=1;
132 e=g.addArc(n1,n2); ecolors[e]=6; widths[e]=1;
133 e=g.addArc(n1,n2); ecolors[e]=7; widths[e]=1;
135 cout << "Create 'graph_to_eps_demo_out_par.eps'" << endl;
136 graphToEps(g,"graph_to_eps_demo_out_par.eps").
138 title("Sample .eps figure (parallel arcs)").
139 copyright("(C) 2003-2007 LEMON Project").
140 absoluteNodeSizes().absoluteArcWidths().
143 nodeScale(2).nodeSizes(sizes).
144 nodeColors(composeMap(palette,colors)).
145 arcColors(composeMap(palette,ecolors)).
146 arcWidthScale(.4).arcWidths(widths).
147 nodeTexts(id).nodeTextSize(3).
148 enableParallel().parArcDist(1.5).
151 cout << "Create 'graph_to_eps_demo_out_par_arr.eps'" << endl;
152 graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").
154 title("Sample .eps figure (parallel arcs and arrowheads)").
155 copyright("(C) 2003-2007 LEMON Project").
156 absoluteNodeSizes().absoluteArcWidths().
157 nodeScale(2).nodeSizes(sizes).
160 nodeColors(composeMap(palette,colors)).
161 arcColors(composeMap(palette,ecolors)).
162 arcWidthScale(.3).arcWidths(widths).
163 nodeTexts(id).nodeTextSize(3).
164 enableParallel().parArcDist(1).
165 drawArrows().arrowWidth(1).arrowLength(1).
168 cout << "Create 'graph_to_eps_demo_out_a4.eps'" << endl;
169 graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4().
170 title("Sample .eps figure (fits to A4)").
171 copyright("(C) 2003-2007 LEMON Project").
172 absoluteNodeSizes().absoluteArcWidths().
173 nodeScale(2).nodeSizes(sizes).
176 nodeColors(composeMap(palette,colors)).
177 arcColors(composeMap(palette,ecolors)).
178 arcWidthScale(.3).arcWidths(widths).
179 nodeTexts(id).nodeTextSize(3).
180 enableParallel().parArcDist(1).
181 drawArrows().arrowWidth(1).arrowLength(1).
185 ListDigraph::NodeMap<int> hcolors(h);
186 ListDigraph::NodeMap<Point> hcoords(h);
188 int cols=int(sqrt(double(palette.size())));
189 for(int i=0;i<int(paletteW.size());i++) {
191 hcoords[n]=Point(i%cols,i/cols);
195 cout << "Create 'graph_to_eps_demo_out_colors.eps'" << endl;
196 graphToEps(h,"graph_to_eps_demo_out_colors.eps").
198 title("Sample .eps figure (Palette demo)").
199 copyright("(C) 2003-2007 LEMON Project").
201 absoluteNodeSizes().absoluteArcWidths().
203 distantColorNodeTexts().
204 // distantBWNodeTexts().
205 nodeTexts(hcolors).nodeTextSize(.6).
206 nodeColors(composeMap(paletteW,hcolors)).