Cplex interface has improved a lot.
2 * src/lemon/demo/graph_to_eps.cc -
3 * Part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
6 * (Egervary Combinatorial Optimization Research Group, EGRES).
8 * Permission to use, modify and distribute this software is granted
9 * provided that this copyright notice appears in all copies. For
10 * precise terms see the accompanying LICENSE file.
12 * This software is provided "AS IS" with no warranty of any kind,
13 * express or implied, and with no claim as to its suitability for any
18 #include<lemon/graph_to_eps.h>
19 #include<lemon/maps.h>
20 #include<lemon/list_graph.h>
21 #include<lemon/graph_utils.h>
25 using namespace lemon;
32 typedef ListGraph::Node Node;
33 typedef ListGraph::NodeIt NodeIt;
34 typedef ListGraph::Edge Edge;
43 ListGraph::NodeMap<Xy> coords(g);
44 ListGraph::NodeMap<double> sizes(g);
45 ListGraph::NodeMap<int> colors(g);
46 ListGraph::NodeMap<int> shapes(g);
47 ListGraph::EdgeMap<int> ecolors(g);
48 ListGraph::EdgeMap<int> widths(g);
50 coords[n1]=Xy(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
51 coords[n2]=Xy(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2;
52 coords[n3]=Xy(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0;
53 coords[n4]=Xy(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1;
54 coords[n5]=Xy(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
58 e=g.addEdge(n1,n2); ecolors[e]=0; widths[e]=1;
59 e=g.addEdge(n2,n3); ecolors[e]=0; widths[e]=1;
60 e=g.addEdge(n3,n5); ecolors[e]=0; widths[e]=3;
61 e=g.addEdge(n5,n4); ecolors[e]=0; widths[e]=1;
62 e=g.addEdge(n4,n1); ecolors[e]=0; widths[e]=1;
63 e=g.addEdge(n2,n4); ecolors[e]=1; widths[e]=2;
64 e=g.addEdge(n3,n4); ecolors[e]=2; widths[e]=1;
66 IdMap<ListGraph,Node> id(g);
68 graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords).
69 title("Sample .eps figure").
70 copyright("(C) 2005 LEMON Project").
71 nodeScale(2).nodeSizes(sizes).
73 nodeColors(composeMap(colorSet,colors)).
74 edgeColors(composeMap(colorSet,ecolors)).
75 edgeWidthScale(.4).edgeWidths(widths).
76 nodeTexts(id).nodeTextSize(3).
79 graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10).
80 title("Sample .eps figure (with arrowheads)").
81 copyright("(C) 2005 LEMON Project").
82 nodeColors(composeMap(colorSet,colors)).
84 nodeScale(2).nodeSizes(sizes).
86 edgeColors(composeMap(colorSet,ecolors)).
87 edgeWidthScale(.4).edgeWidths(widths).
88 nodeTexts(id).nodeTextSize(3).
89 drawArrows().arrowWidth(1).arrowLength(1).
92 e=g.addEdge(n1,n4); ecolors[e]=2; widths[e]=1;
93 e=g.addEdge(n4,n1); ecolors[e]=1; widths[e]=2;
95 e=g.addEdge(n1,n2); ecolors[e]=1; widths[e]=1;
96 e=g.addEdge(n1,n2); ecolors[e]=2; widths[e]=1;
97 e=g.addEdge(n1,n2); ecolors[e]=3; widths[e]=1;
98 e=g.addEdge(n1,n2); ecolors[e]=4; widths[e]=1;
99 e=g.addEdge(n1,n2); ecolors[e]=5; widths[e]=1;
100 e=g.addEdge(n1,n2); ecolors[e]=6; widths[e]=1;
101 e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1;
103 graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10).
104 title("Sample .eps figure (parallel edges)").
105 copyright("(C) 2005 LEMON Project").
108 nodeScale(2).nodeSizes(sizes).
109 nodeColors(composeMap(colorSet,colors)).
110 edgeColors(composeMap(colorSet,ecolors)).
111 edgeWidthScale(.4).edgeWidths(widths).
112 nodeTexts(id).nodeTextSize(3).
113 enableParallel().parEdgeDist(1.5).
116 graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10).
117 title("Sample .eps figure (parallel edges and arrowheads)").
118 copyright("(C) 2005 LEMON Project").
119 nodeScale(2).nodeSizes(sizes).
122 nodeColors(composeMap(colorSet,colors)).
123 edgeColors(composeMap(colorSet,ecolors)).
124 edgeWidthScale(.3).edgeWidths(widths).
125 nodeTexts(id).nodeTextSize(3).
126 enableParallel().parEdgeDist(1).
127 drawArrows().arrowWidth(1).arrowLength(1).
130 graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4().
131 title("Sample .eps figure (fits to A4)").
132 copyright("(C) 2005 LEMON Project").
133 nodeScale(2).nodeSizes(sizes).
136 nodeColors(composeMap(colorSet,colors)).
137 edgeColors(composeMap(colorSet,ecolors)).
138 edgeWidthScale(.3).edgeWidths(widths).
139 nodeTexts(id).nodeTextSize(3).
140 enableParallel().parEdgeDist(1).
141 drawArrows().arrowWidth(1).arrowLength(1).
145 ListGraph::NodeMap<int> hcolors(h);
146 ListGraph::NodeMap<Xy> hcoords(h);
148 int cols=int(sqrt(double(colorSet.size())));
149 for(int i=0;i<int(colorSet.size());i++) {
151 hcoords[n]=Xy(i%cols,i/cols);
155 graphToEps(h,"graph_to_eps_demo_out_colors.eps").scale(60).
156 title("Sample .eps figure (parallel edges and arrowheads)").
157 copyright("(C) 2005 LEMON Project").
160 distantColorNodeTexts().
161 // distantBWNodeTexts().
162 nodeTexts(hcolors).nodeTextSize(.6).
163 nodeColors(composeMap(colorSet,hcolors)).