Redesigned CapacityScaling algorithm with almost the same interface.
The new version does not use the ResidualGraphAdaptor for performance reasons.
Scaling can be enabled and disabled with a parameter of the run() function.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2007
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
19 #include <lemon/eps.h>
23 void EpsDrawer::defMacros()
25 out << "/clmode true def\n" <<
26 "/cshowmode false def\n" <<
27 "/defont (Helvetica) findfont def\n" <<
30 "/st { clmode { currentpoint stroke newpath moveto } if } bind def\n" <<
31 "/str { currentpoint stroke newpath moveto /clmode true def } bind def\n"
33 "/fl { currentpoint fill newpath moveto /clmode true def } bind def\n" <<
34 "/eofl { currentpoint eofill newpath moveto /clmode true def } bind def\n"
36 "/cl { currentpoint clip newpath moveto /clmode true def } bind def\n"
38 "/eocl { currentpoint eoclip newpath moveto /clmode true def } bind def\n"
41 "/l { moveto lineto st } bind def\n" <<
42 "/lt { lineto st } bind def\n" <<
43 "/mt { moveto } bind def\n" <<
44 "/c { dup 3 index add 2 index moveto 0 360 arc st } bind def\n" <<
45 "/collect { /clmode false def currentpoint newpath moveto } bind def\n" <<
47 "/fontset { defont fosi scalefont setfont } bind def\n" <<
48 "/stfs { /fosi exch def fontset } bind def\n" <<
49 "/cshow { dup stringwidth pop\n" <<
50 " neg 2 div 0 rmoveto show } bind def\n" <<
51 "/xshow { cshowmode { cshow } { show } ifelse } def\n" <<
59 void EpsDrawer::init(int x1,int y1,int x2,int y2)
61 out << "%!PS-Adobe-2.0 EPSF-2.0\n" <<
62 "%%BoundingBox: " << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 <<
67 void EpsDrawer::init(double x1,double y1,double x2,double y2)
69 out << "%!PS-Adobe-2.0\n" <<
70 "%%HiResBoundingBox: " <<
71 x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 <<
77 EpsDrawer::EpsDrawer(std::ostream &os,int x,int y) : local_stream(false),
83 EpsDrawer::EpsDrawer(std::ostream &os,int x1,int y1,int x2,int y2) :
90 EpsDrawer::EpsDrawer(std::ostream &os,dim2::Point<double> s) : local_stream(false),
93 init(0.0,0.0,s.x,s.y);
96 EpsDrawer::EpsDrawer(std::ostream &os,dim2::Point<double> a, dim2::Point<double> b) :
100 init(a.x,a.y,b.x,b.y);
104 EpsDrawer::EpsDrawer(const std::string &name,int x,int y) :
106 out(*new std::ofstream(name.c_str()))
111 EpsDrawer::EpsDrawer(const std::string &name,int x1,int y1,int x2,int y2) :
113 out(*new std::ofstream(name.c_str()))
118 EpsDrawer::EpsDrawer(const std::string &name,dim2::Point<double> s) :
120 out(*new std::ofstream(name.c_str()))
122 init(0.0,0.0,s.x,s.y);
125 EpsDrawer::EpsDrawer(const std::string &name,dim2::Point<double> a, dim2::Point<double> b) :
127 out(*new std::ofstream(name.c_str()))
129 init(a.x,a.y,b.x,b.y);
133 EpsDrawer::~EpsDrawer()
136 if(local_stream) delete &out;
139 EpsDrawer &EpsDrawer::save()
145 EpsDrawer &EpsDrawer::restore()
151 EpsDrawer &EpsDrawer::line(double x1,double y1,double x2,double y2)
153 out << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << " l\n";
158 EpsDrawer &EpsDrawer::lineTo(double x1,double y1)
160 out << x1 << ' ' << y1 << " lt\n";
165 EpsDrawer &EpsDrawer::moveTo(double x1,double y1)
167 out << x1 << ' ' << y1 << " mt\n";
171 EpsDrawer &EpsDrawer::circle(double x,double y, double r)
173 out << x << ' ' << y << ' ' << r << " c\n";
177 EpsDrawer &EpsDrawer::operator<<(const std::string &s)
179 out << "(" << s <<") xshow\n";
183 EpsDrawer &EpsDrawer::operator<<(const char *s)
185 out << "(" << s <<") xshow\n";
189 EpsDrawer &EpsDrawer::operator<<(int i)
191 out << "(" << i <<") xshow\n";
195 EpsDrawer &EpsDrawer::operator<<(double d)
197 out << "(" << d <<") xshow\n";
201 EpsDrawer &EpsDrawer::fontSize(double si)
203 out << si << " stfs\n";
206 EpsDrawer &EpsDrawer::font(std::string s)
208 out << "/defont ("<<s<<") findfont def fontset\n";
213 EpsDrawer &EpsDrawer::collect()
219 EpsDrawer &EpsDrawer::closePath()
221 out << "closepath\n";
225 EpsDrawer &EpsDrawer::stroke()
230 EpsDrawer &EpsDrawer::fill()
235 EpsDrawer &EpsDrawer::eoFill()
240 EpsDrawer &EpsDrawer::clip()
245 EpsDrawer &EpsDrawer::eoClip()
251 EpsDrawer &EpsDrawer::lineWidth(double w)
253 out << w << " setlinewidth\n";
257 EpsDrawer &EpsDrawer::lineCap(int i)
259 out << i << " setlinecap\n";
263 EpsDrawer &EpsDrawer::lineJoin(int i)
265 out << i << " setlinejoin\n";
269 EpsDrawer &EpsDrawer::miterLimit(double w)
271 out << w << " setmiterlimit\n";
275 EpsDrawer &EpsDrawer::color(double r, double g, double b)
277 out << r << ' ' << g << ' ' << b << " setrgbcolor\n";
281 EpsDrawer &EpsDrawer::translate(double x,double y)
283 out << x << ' ' << y << " translate\n";
287 EpsDrawer &EpsDrawer::rotate(double r)
289 out << r << " rotate\n";
292 EpsDrawer &EpsDrawer::scale(double sx, double sy)
294 out << sx << ' ' << sy << " scale\n";
298 EpsDrawer &EpsDrawer::clear()
300 out << "erasepage\n";
304 EpsDrawer &EpsDrawer::centerMode(bool m)
306 if(m) out << "/cshowmode true def\n";
307 else out << "/cshowmode false def\n";
312 EpsDrawer &EpsDrawer::flush()
319 EpsDrawer &EpsDrawer::node(NodeShapes t, double x, double y, double r,
320 Color col, Color brd)
323 << brd.red() << ' ' << brd.green() << ' ' << brd.blue()
327 out << "newpath " << x << ' ' << y << ' ' << r
328 << " dup 3 index add 2 index moveto 0 360 arc fill\n";
332 << x-r << ' ' << y-r << " moveto\n"
333 << x-r << ' ' << y+r << " lineto\n"
334 << x+r << ' ' << y+r << " lineto\n"
335 << x+r << ' ' << y-r << " lineto closepath fill\n";
339 << x-r << ' ' << y << " moveto\n"
340 << x << ' ' << y+r << " lineto\n"
341 << x+r << ' ' << y << " lineto\n"
342 << x << ' ' << y-r << " lineto closepath fill\n";
350 out << col.red() << ' ' << col.green() << ' ' << col.blue()
354 out << "newpath " << x << ' ' << y << ' ' << r
355 << " dup 3 index add 2 index moveto 0 360 arc fill\n";
359 << x-r << ' ' << y-r << " moveto\n"
360 << x-r << ' ' << y+r << " lineto\n"
361 << x+r << ' ' << y+r << " lineto\n"
362 << x+r << ' ' << y-r << " lineto closepath fill\n";
366 << x-r << ' ' << y << " moveto\n"
367 << x << ' ' << y+r << " lineto\n"
368 << x+r << ' ' << y << " lineto\n"
369 << x << ' ' << y-r << " lineto closepath fill\n";