2 * src/lemon/demo/graph_to_eps.cc -
3 * Part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2004 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>
24 using namespace lemon;
26 class ColorSet : public MapBase<int,Color>
29 Color operator[](int i) const
32 case 0: return Color(0,0,0);
33 case 1: return Color(1,0,0);
34 case 2: return Color(0,1,0);
35 case 3: return Color(0,0,1);
36 case 4: return Color(1,1,0);
37 case 5: return Color(1,0,1);
38 case 6: return Color(0,1,1);
39 case 7: return Color(1,1,1);
45 class IdMap :public MapBase<ListGraph::Node,int>
49 IdMap(const ListGraph &_g) :g(_g) {}
50 Value operator[](Key n) const { return g.id(n); }
56 typedef ListGraph::Node Node;
57 typedef ListGraph::NodeIt NodeIt;
58 typedef ListGraph::Edge Edge;
67 ListGraph::NodeMap<Xy> coords(g);
68 ListGraph::NodeMap<double> sizes(g);
69 ListGraph::NodeMap<int> colors(g);
70 ListGraph::EdgeMap<int> ecolors(g);
71 ListGraph::EdgeMap<int> widths(g);
73 coords[n1]=Xy(50,50); sizes[n1]=1; colors[n1]=1;
74 coords[n2]=Xy(50,70); sizes[n2]=2; colors[n2]=2;
75 coords[n3]=Xy(70,70); sizes[n3]=1; colors[n3]=3;
76 coords[n4]=Xy(70,50); sizes[n4]=2; colors[n4]=4;
77 coords[n5]=Xy(85,60); sizes[n5]=3; colors[n5]=5;
81 e=g.addEdge(n1,n2); ecolors[e]=0; widths[e]=1;
82 e=g.addEdge(n2,n3); ecolors[e]=0; widths[e]=1;
83 e=g.addEdge(n3,n5); ecolors[e]=0; widths[e]=3;
84 e=g.addEdge(n5,n4); ecolors[e]=0; widths[e]=1;
85 e=g.addEdge(n4,n1); ecolors[e]=0; widths[e]=1;
86 e=g.addEdge(n2,n4); ecolors[e]=1; widths[e]=2;
87 e=g.addEdge(n3,n4); ecolors[e]=2; widths[e]=1;
91 graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords).
92 nodeScale(2).nodeSizes(sizes).
93 nodeColors(composeMap(colorSet,colors)).
94 edgeColors(composeMap(colorSet,ecolors)).
95 edgeWidthScale(.4).edgeWidths(widths).
96 nodeTexts(id).nodeTextSize(3);
98 graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10).coords(coords).
99 nodeScale(2).nodeSizes(sizes).
100 nodeColors(composeMap(colorSet,colors)).
101 edgeColors(composeMap(colorSet,ecolors)).
102 edgeWidthScale(.4).edgeWidths(widths).
103 nodeTexts(id).nodeTextSize(3).
104 drawArrows().arrowWidth(1).arrowLength(1);
106 e=g.addEdge(n1,n4); ecolors[e]=2; widths[e]=1;
107 e=g.addEdge(n4,n1); ecolors[e]=1; widths[e]=2;
109 e=g.addEdge(n1,n2); ecolors[e]=1; widths[e]=1;
110 e=g.addEdge(n1,n2); ecolors[e]=2; widths[e]=1;
111 e=g.addEdge(n1,n2); ecolors[e]=3; widths[e]=1;
112 e=g.addEdge(n1,n2); ecolors[e]=4; widths[e]=1;
113 e=g.addEdge(n1,n2); ecolors[e]=5; widths[e]=1;
114 e=g.addEdge(n1,n2); ecolors[e]=6; widths[e]=1;
115 e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1;
117 graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10).coords(coords).
118 nodeScale(2).nodeSizes(sizes).
119 nodeColors(composeMap(colorSet,colors)).
120 edgeColors(composeMap(colorSet,ecolors)).
121 edgeWidthScale(.4).edgeWidths(widths).
122 nodeTexts(id).nodeTextSize(3).
123 enableParallel().parEdgeDist(1.5);
125 graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10).coords(coords).
126 nodeScale(2).nodeSizes(sizes).
127 nodeColors(composeMap(colorSet,colors)).
128 edgeColors(composeMap(colorSet,ecolors)).
129 edgeWidthScale(.3).edgeWidths(widths).
130 nodeTexts(id).nodeTextSize(3).
131 enableParallel().parEdgeDist(1).
132 drawArrows().arrowWidth(1).arrowLength(1);