Some bug fix.
Added: Concept check for maps and IdReader/Writer classes
Some runtime check
2 * demo/graph_to_eps.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
17 #include<lemon/graph_to_eps.h>
18 #include<lemon/maps.h>
19 #include<lemon/list_graph.h>
20 #include<lemon/graph_utils.h>
26 using namespace lemon;
33 typedef ListGraph::Node Node;
34 typedef ListGraph::NodeIt NodeIt;
35 typedef ListGraph::Edge Edge;
44 ListGraph::NodeMap<Xy> coords(g);
45 ListGraph::NodeMap<double> sizes(g);
46 ListGraph::NodeMap<int> colors(g);
47 ListGraph::NodeMap<int> shapes(g);
48 ListGraph::EdgeMap<int> ecolors(g);
49 ListGraph::EdgeMap<int> widths(g);
51 coords[n1]=Xy(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
52 coords[n2]=Xy(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2;
53 coords[n3]=Xy(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0;
54 coords[n4]=Xy(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1;
55 coords[n5]=Xy(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
59 e=g.addEdge(n1,n2); ecolors[e]=0; widths[e]=1;
60 e=g.addEdge(n2,n3); ecolors[e]=0; widths[e]=1;
61 e=g.addEdge(n3,n5); ecolors[e]=0; widths[e]=3;
62 e=g.addEdge(n5,n4); ecolors[e]=0; widths[e]=1;
63 e=g.addEdge(n4,n1); ecolors[e]=0; widths[e]=1;
64 e=g.addEdge(n2,n4); ecolors[e]=1; widths[e]=2;
65 e=g.addEdge(n3,n4); ecolors[e]=2; widths[e]=1;
67 IdMap<ListGraph,Node> id(g);
69 graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords).
70 title("Sample .eps figure").
71 copyright("(C) 2005 LEMON Project").
72 nodeScale(2).nodeSizes(sizes).
74 nodeColors(composeMap(colorSet,colors)).
75 edgeColors(composeMap(colorSet,ecolors)).
76 edgeWidthScale(.4).edgeWidths(widths).
77 nodeTexts(id).nodeTextSize(3).
80 graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10).
81 title("Sample .eps figure (with arrowheads)").
82 copyright("(C) 2005 LEMON Project").
83 nodeColors(composeMap(colorSet,colors)).
85 nodeScale(2).nodeSizes(sizes).
87 edgeColors(composeMap(colorSet,ecolors)).
88 edgeWidthScale(.4).edgeWidths(widths).
89 nodeTexts(id).nodeTextSize(3).
90 drawArrows().arrowWidth(1).arrowLength(1).
93 e=g.addEdge(n1,n4); ecolors[e]=2; widths[e]=1;
94 e=g.addEdge(n4,n1); ecolors[e]=1; widths[e]=2;
96 e=g.addEdge(n1,n2); ecolors[e]=1; widths[e]=1;
97 e=g.addEdge(n1,n2); ecolors[e]=2; widths[e]=1;
98 e=g.addEdge(n1,n2); ecolors[e]=3; widths[e]=1;
99 e=g.addEdge(n1,n2); ecolors[e]=4; widths[e]=1;
100 e=g.addEdge(n1,n2); ecolors[e]=5; widths[e]=1;
101 e=g.addEdge(n1,n2); ecolors[e]=6; widths[e]=1;
102 e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1;
104 graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10).
105 title("Sample .eps figure (parallel edges)").
106 copyright("(C) 2005 LEMON Project").
109 nodeScale(2).nodeSizes(sizes).
110 nodeColors(composeMap(colorSet,colors)).
111 edgeColors(composeMap(colorSet,ecolors)).
112 edgeWidthScale(.4).edgeWidths(widths).
113 nodeTexts(id).nodeTextSize(3).
114 enableParallel().parEdgeDist(1.5).
117 graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10).
118 title("Sample .eps figure (parallel edges and arrowheads)").
119 copyright("(C) 2005 LEMON Project").
120 nodeScale(2).nodeSizes(sizes).
123 nodeColors(composeMap(colorSet,colors)).
124 edgeColors(composeMap(colorSet,ecolors)).
125 edgeWidthScale(.3).edgeWidths(widths).
126 nodeTexts(id).nodeTextSize(3).
127 enableParallel().parEdgeDist(1).
128 drawArrows().arrowWidth(1).arrowLength(1).
131 graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4().
132 title("Sample .eps figure (fits to A4)").
133 copyright("(C) 2005 LEMON Project").
134 nodeScale(2).nodeSizes(sizes).
137 nodeColors(composeMap(colorSet,colors)).
138 edgeColors(composeMap(colorSet,ecolors)).
139 edgeWidthScale(.3).edgeWidths(widths).
140 nodeTexts(id).nodeTextSize(3).
141 enableParallel().parEdgeDist(1).
142 drawArrows().arrowWidth(1).arrowLength(1).
146 ListGraph::NodeMap<int> hcolors(h);
147 ListGraph::NodeMap<Xy> hcoords(h);
149 int cols=int(sqrt(double(colorSet.size())));
150 for(int i=0;i<int(colorSet.size());i++) {
152 hcoords[n]=Xy(i%cols,i/cols);
156 graphToEps(h,"graph_to_eps_demo_out_colors.eps").scale(60).
157 title("Sample .eps figure (parallel edges and arrowheads)").
158 copyright("(C) 2005 LEMON Project").
161 distantColorNodeTexts().
162 // distantBWNodeTexts().
163 nodeTexts(hcolors).nodeTextSize(.6).
164 nodeColors(composeMap(colorSet,hcolors)).