COIN-OR::LEMON - Graph Library

source: lemon-0.x/lemon/graph_to_eps.h @ 1907:9f9eeb4d5c69

Last change on this file since 1907:9f9eeb4d5c69 was 1907:9f9eeb4d5c69, checked in by Alpar Juttner, 18 years ago

MALE and FEMALE node shape added.

File size: 37.5 KB
Line 
1/* -*- C++ -*-
2 * lemon/graph_to_eps.h - Part of LEMON, a generic C++ optimization library
3 *
4 * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
6 *
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.
10 *
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
13 * purpose.
14 *
15 */
16
17#ifndef LEMON_GRAPH_TO_EPS_H
18#define LEMON_GRAPH_TO_EPS_H
19
20#include <sys/time.h>
21
22#include<iostream>
23#include<fstream>
24#include<sstream>
25#include<algorithm>
26#include<vector>
27
28#include <ctime>
29#include <cmath>
30
31#include<lemon/invalid.h>
32#include<lemon/xy.h>
33#include<lemon/maps.h>
34#include<lemon/bezier.h>
35
36
37///\ingroup io_group
38///\file
39///\brief Simple graph drawer
40///
41///\author Alpar Juttner
42
43namespace lemon {
44
45///Data structure representing RGB colors.
46
47///Data structure representing RGB colors.
48///\ingroup misc
49class Color
50{
51  double _r,_g,_b;
52public:
53  ///Default constructor
54  Color() {}
55  ///Constructor
56  Color(double r,double g,double b) :_r(r),_g(g),_b(b) {};
57  ///Returns the red component
58  double & red() {return _r;}
59  ///Returns the red component
60  const double & red() const {return _r;}
61  ///Returns the green component
62  double & green() {return _g;}
63  ///Returns the green component
64  const double & green() const {return _g;}
65  ///Returns the blue component
66  double & blue() {return _b;}
67  ///Returns the blue component
68  const double & blue() const {return _b;}
69  ///Set the color components
70  void set(double r,double g,double b) { _r=r;_g=g;_b=b; };
71};
72
73///Maps <tt>int</tt>s to different \ref Color "Color"s
74
75///This map assigns one of the predefined \ref Color "Color"s
76///to each <tt>int</tt>. It is possible to change the colors as well as their
77///number. The integer range is cyclically mapped to the provided set of colors.
78///
79///This is a true \ref concept::ReferenceMap "reference map", so you can also
80///change the actual colors.
81
82class ColorSet : public MapBase<int,Color>
83{
84  std::vector<Color> colors;
85public:
86  ///Constructor
87
88  ///Constructor
89  ///\param have_white indicates whether white is
90  ///amongst the provided color (\c true) or not (\c false). If it is true,
91  ///white will be assigned to \c 0.
92  ///\param num the number of the allocated colors. If it is \c 0
93  ///the default color configuration is set up (26 color plus the while).
94  ///If \c num is less then 26/27 then the default color list is cut. Otherwise
95  ///the color list is filled repeatedly with the default color list.
96  ///(The colors can be changed later on.)
97  ColorSet(bool have_white=false,int num=0)
98  {
99    do {
100      if(have_white) colors.push_back(Color(1,1,1));
101
102      colors.push_back(Color(0,0,0));
103      colors.push_back(Color(1,0,0));
104      colors.push_back(Color(0,1,0));
105      colors.push_back(Color(0,0,1));
106      colors.push_back(Color(1,1,0));
107      colors.push_back(Color(1,0,1));
108      colors.push_back(Color(0,1,1));
109     
110      colors.push_back(Color(.5,0,0));
111      colors.push_back(Color(0,.5,0));
112      colors.push_back(Color(0,0,.5));
113      colors.push_back(Color(.5,.5,0));
114      colors.push_back(Color(.5,0,.5));
115      colors.push_back(Color(0,.5,.5));
116     
117      colors.push_back(Color(.5,.5,.5));
118      colors.push_back(Color(1,.5,.5));
119      colors.push_back(Color(.5,1,.5));
120      colors.push_back(Color(.5,.5,1));
121      colors.push_back(Color(1,1,.5));
122      colors.push_back(Color(1,.5,1));
123      colors.push_back(Color(.5,1,1));
124     
125      colors.push_back(Color(1,.5,0));
126      colors.push_back(Color(.5,1,0));
127      colors.push_back(Color(1,0,.5));
128      colors.push_back(Color(0,1,.5));
129      colors.push_back(Color(0,.5,1));
130      colors.push_back(Color(.5,0,1));
131    } while(int(colors.size())<num);
132    //    colors.push_back(Color(1,1,1));
133    if(num>0) colors.resize(num);
134  }
135  ///\e
136  Color &operator[](int i)
137  {
138    return colors[i%colors.size()];
139  }
140  ///\e
141  const Color &operator[](int i) const
142  {
143    return colors[i%colors.size()];
144  }
145  ///\e
146  void set(int i,const Color &c)
147  {
148    colors[i%colors.size()]=c;
149  }
150  ///Sets the number of the exiting colors.
151  void resize(int s) { colors.resize(s);}
152  ///Returns the number of the existing colors.
153  std::size_t size() const { return colors.size();}
154};
155
156///Returns a visible distinct \ref Color
157
158///Returns a \ref Color which is as different from the given parameter
159///as it is possible.
160inline Color distantColor(const Color &c)
161{
162  return Color(c.red()<.5?1:0,c.green()<.5?1:0,c.blue()<.5?1:0);
163}
164///Returns black for light colors and white for the dark ones.
165
166///Returns black for light colors and white for the dark ones.
167inline Color distantBW(const Color &c){
168  double v=(.2125*c.red()+.7154*c.green()+.0721*c.blue())<.5?1:0;
169  return Color(v,v,v);
170}
171
172template<class MT>
173class _NegY {
174public:
175  typedef typename MT::Key Key;
176  typedef typename MT::Value Value;
177  const MT &map;
178  int yscale;
179  _NegY(const MT &m,bool b) : map(m), yscale(1-b*2) {}
180  Value operator[](Key n) { return Value(map[n].x,map[n].y*yscale);}
181};
182
183///Default traits class of \ref GraphToEps
184
185///Default traits class of \ref GraphToEps
186///
187///\c G is the type of the underlying graph.
188template<class G>
189struct DefaultGraphToEpsTraits
190{
191  typedef G Graph;
192  typedef typename Graph::Node Node;
193  typedef typename Graph::NodeIt NodeIt;
194  typedef typename Graph::Edge Edge;
195  typedef typename Graph::EdgeIt EdgeIt;
196  typedef typename Graph::InEdgeIt InEdgeIt;
197  typedef typename Graph::OutEdgeIt OutEdgeIt;
198 
199
200  const Graph &g;
201
202  std::ostream& os;
203 
204  typedef ConstMap<typename Graph::Node,xy<double> > CoordsMapType;
205  CoordsMapType _coords;
206  ConstMap<typename Graph::Node,double > _nodeSizes;
207  ConstMap<typename Graph::Node,int > _nodeShapes;
208
209  ConstMap<typename Graph::Node,Color > _nodeColors;
210  ConstMap<typename Graph::Edge,Color > _edgeColors;
211
212  ConstMap<typename Graph::Edge,double > _edgeWidths;
213
214  double _edgeWidthScale;
215 
216  double _nodeScale;
217  double _xBorder, _yBorder;
218  double _scale;
219  double _nodeBorderQuotient;
220 
221  bool _drawArrows;
222  double _arrowLength, _arrowWidth;
223 
224  bool _showNodes, _showEdges;
225
226  bool _enableParallel;
227  double _parEdgeDist;
228
229  bool _showNodeText;
230  ConstMap<typename Graph::Node,bool > _nodeTexts; 
231  double _nodeTextSize;
232
233  bool _showNodePsText;
234  ConstMap<typename Graph::Node,bool > _nodePsTexts; 
235  char *_nodePsTextsPreamble;
236 
237  bool _undir;
238  bool _pleaseRemoveOsStream;
239
240  bool _scaleToA4;
241
242  std::string _title;
243  std::string _copyright;
244
245  enum NodeTextColorType
246    { DIST_COL=0, DIST_BW=1, CUST_COL=2, SAME_COL=3 } _nodeTextColorType;
247  ConstMap<typename Graph::Node,Color > _nodeTextColors;
248
249  bool _autoNodeScale;
250  bool _autoEdgeWidthScale;
251
252  bool _negY;
253  ///Constructor
254
255  ///Constructor
256  ///\param _g is a reference to the graph to be printed
257  ///\param _os is a reference to the output stream.
258  ///\param _os is a reference to the output stream.
259  ///\param _pros If it is \c true, then the \c ostream referenced by \c _os
260  ///will be explicitly deallocated by the destructor.
261  ///By default it is <tt>std::cout</tt>
262  DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout,
263                          bool _pros=false) :
264    g(_g), os(_os),
265    _coords(xy<double>(1,1)), _nodeSizes(1.0), _nodeShapes(0),
266    _nodeColors(Color(1,1,1)), _edgeColors(Color(0,0,0)),
267    _edgeWidths(1), _edgeWidthScale(0.3),
268    _nodeScale(1.0), _xBorder(10), _yBorder(10), _scale(1.0),
269    _nodeBorderQuotient(.1),
270    _drawArrows(false), _arrowLength(1), _arrowWidth(0.3),
271    _showNodes(true), _showEdges(true),
272    _enableParallel(false), _parEdgeDist(1),
273    _showNodeText(false), _nodeTexts(false), _nodeTextSize(1),
274    _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0),
275    _undir(false),
276    _pleaseRemoveOsStream(_pros), _scaleToA4(false),
277    _nodeTextColorType(SAME_COL), _nodeTextColors(Color(0,0,0)),
278    _autoNodeScale(false),
279    _autoEdgeWidthScale(false),
280    _negY(false)
281  {}
282};
283
284///Helper class to implement the named parameters of \ref graphToEps()
285
286///Helper class to implement the named parameters of \ref graphToEps()
287///\todo Is 'helper class' a good name for this?
288///
289///\todo Follow PostScript's DSC.
290/// Use own dictionary.
291///\todo Useful new features.
292/// - Linestyles: dotted, dashed etc.
293/// - A second color and percent value for the lines.
294template<class T> class GraphToEps : public T
295{
296  // Can't believe it is required by the C++ standard
297  using T::g;
298  using T::os;
299
300  using T::_coords;
301  using T::_nodeSizes;
302  using T::_nodeShapes;
303  using T::_nodeColors;
304  using T::_edgeColors;
305  using T::_edgeWidths;
306
307  using T::_edgeWidthScale;
308  using T::_nodeScale;
309  using T::_xBorder;
310  using T::_yBorder;
311  using T::_scale;
312  using T::_nodeBorderQuotient;
313 
314  using T::_drawArrows;
315  using T::_arrowLength;
316  using T::_arrowWidth;
317 
318  using T::_showNodes;
319  using T::_showEdges;
320
321  using T::_enableParallel;
322  using T::_parEdgeDist;
323
324  using T::_showNodeText;
325  using T::_nodeTexts; 
326  using T::_nodeTextSize;
327
328  using T::_showNodePsText;
329  using T::_nodePsTexts; 
330  using T::_nodePsTextsPreamble;
331 
332  using T::_undir;
333  using T::_pleaseRemoveOsStream;
334
335  using T::_scaleToA4;
336
337  using T::_title;
338  using T::_copyright;
339
340  using T::NodeTextColorType;
341  using T::CUST_COL;
342  using T::DIST_COL;
343  using T::DIST_BW;
344  using T::_nodeTextColorType;
345  using T::_nodeTextColors;
346
347  using T::_autoNodeScale;
348  using T::_autoEdgeWidthScale;
349
350  using T::_negY;
351
352  // dradnats ++C eht yb deriuqer si ti eveileb t'naC
353
354  typedef typename T::Graph Graph;
355  typedef typename Graph::Node Node;
356  typedef typename Graph::NodeIt NodeIt;
357  typedef typename Graph::Edge Edge;
358  typedef typename Graph::EdgeIt EdgeIt;
359  typedef typename Graph::InEdgeIt InEdgeIt;
360  typedef typename Graph::OutEdgeIt OutEdgeIt;
361
362  static const int INTERPOL_PREC;
363  static const double A4HEIGHT;
364  static const double A4WIDTH;
365  static const double A4BORDER;
366
367  bool dontPrint;
368
369public:
370  ///Node shapes
371
372  ///Node shapes
373  ///
374  enum NodeShapes {
375    /// = 0
376    ///\image html nodeshape_0.png
377    ///\image latex nodeshape_0.eps "CIRCLE shape (0)" width=2cm
378    CIRCLE=0,
379    /// = 1
380    ///\image html nodeshape_1.png
381    ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm
382    ///
383    SQUARE=1,
384    /// = 2
385    ///\image html nodeshape_2.png
386    ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm
387    ///
388    DIAMOND=2,
389    /// = 3
390    ///\image html nodeshape_3.png
391    ///\image latex nodeshape_2.eps "MALE shape (4)" width=2cm
392    ///
393    MALE=3,
394    /// = 4
395    ///\image html nodeshape_4.png
396    ///\image latex nodeshape_2.eps "FEMALE shape (4)" width=2cm
397    ///
398    FEMALE=4
399  };
400
401private:
402  class edgeLess {
403    const Graph &g;
404  public:
405    edgeLess(const Graph &_g) : g(_g) {}
406    bool operator()(Edge a,Edge b) const
407    {
408      Node ai=std::min(g.source(a),g.target(a));
409      Node aa=std::max(g.source(a),g.target(a));
410      Node bi=std::min(g.source(b),g.target(b));
411      Node ba=std::max(g.source(b),g.target(b));
412      return ai<bi ||
413        (ai==bi && (aa < ba ||
414                    (aa==ba && ai==g.source(a) && bi==g.target(b))));
415    }
416  };
417  bool isParallel(Edge e,Edge f) const
418  {
419    return (g.source(e)==g.source(f)&&
420            g.target(e)==g.target(f)) ||
421      (g.source(e)==g.target(f)&&
422       g.target(e)==g.source(f));
423  }
424  template<class TT>
425  static std::string psOut(const xy<TT> &p)
426    {
427      std::ostringstream os;   
428      os << p.x << ' ' << p.y;
429      return os.str();
430    }
431  static std::string psOut(const Color &c)
432    {
433      std::ostringstream os;   
434      os << c.red() << ' ' << c.green() << ' ' << c.blue();
435      return os.str();
436    }
437 
438public:
439  GraphToEps(const T &t) : T(t), dontPrint(false) {};
440 
441  template<class X> struct CoordsTraits : public T {
442  typedef X CoordsMapType;
443    const X &_coords;
444    CoordsTraits(const T &t,const X &x) : T(t), _coords(x) {}
445  };
446  ///Sets the map of the node coordinates
447
448  ///Sets the map of the node coordinates.
449  ///\param x must be a node map with xy<double> or \ref xy "xy<int>" values.
450  template<class X> GraphToEps<CoordsTraits<X> > coords(const X &x) {
451    dontPrint=true;
452    return GraphToEps<CoordsTraits<X> >(CoordsTraits<X>(*this,x));
453  }
454  template<class X> struct NodeSizesTraits : public T {
455    const X &_nodeSizes;
456    NodeSizesTraits(const T &t,const X &x) : T(t), _nodeSizes(x) {}
457  };
458  ///Sets the map of the node sizes
459
460  ///Sets the map of the node sizes
461  ///\param x must be a node map with \c double (or convertible) values.
462  template<class X> GraphToEps<NodeSizesTraits<X> > nodeSizes(const X &x)
463  {
464    dontPrint=true;
465    return GraphToEps<NodeSizesTraits<X> >(NodeSizesTraits<X>(*this,x));
466  }
467  template<class X> struct NodeShapesTraits : public T {
468    const X &_nodeShapes;
469    NodeShapesTraits(const T &t,const X &x) : T(t), _nodeShapes(x) {}
470  };
471  ///Sets the map of the node shapes
472
473  ///Sets the map of the node shapes.
474  ///The availabe shape values
475  ///can be found in \ref NodeShapes "enum NodeShapes".
476  ///\param x must be a node map with \c int (or convertible) values.
477  ///\sa NodeShapes
478  template<class X> GraphToEps<NodeShapesTraits<X> > nodeShapes(const X &x)
479  {
480    dontPrint=true;
481    return GraphToEps<NodeShapesTraits<X> >(NodeShapesTraits<X>(*this,x));
482  }
483  template<class X> struct NodeTextsTraits : public T {
484    const X &_nodeTexts;
485    NodeTextsTraits(const T &t,const X &x) : T(t), _nodeTexts(x) {}
486  };
487  ///Sets the text printed on the nodes
488
489  ///Sets the text printed on the nodes
490  ///\param x must be a node map with type that can be pushed to a standard
491  ///ostream.
492  template<class X> GraphToEps<NodeTextsTraits<X> > nodeTexts(const X &x)
493  {
494    dontPrint=true;
495    _showNodeText=true;
496    return GraphToEps<NodeTextsTraits<X> >(NodeTextsTraits<X>(*this,x));
497  }
498  template<class X> struct NodePsTextsTraits : public T {
499    const X &_nodePsTexts;
500    NodePsTextsTraits(const T &t,const X &x) : T(t), _nodePsTexts(x) {}
501  };
502  ///Inserts a PostScript block to the nodes
503
504  ///With this command it is possible to insert a verbatim PostScript
505  ///block to the nodes.
506  ///The PS current point will be moved to the centre of the node before
507  ///the PostScript block inserted.
508  ///
509  ///Before and after the block a newline character is inserted so you
510  ///don't have to bother with the separators.
511  ///
512  ///\param x must be a node map with type that can be pushed to a standard
513  ///ostream.
514  ///
515  ///\sa nodePsTextsPreamble()
516  ///\todo Offer the choise not to move to the centre but pass the coordinates
517  ///to the Postscript block inserted.
518  template<class X> GraphToEps<NodePsTextsTraits<X> > nodePsTexts(const X &x)
519  {
520    dontPrint=true;
521    _showNodePsText=true;
522    return GraphToEps<NodePsTextsTraits<X> >(NodePsTextsTraits<X>(*this,x));
523  }
524  template<class X> struct EdgeWidthsTraits : public T {
525    const X &_edgeWidths;
526    EdgeWidthsTraits(const T &t,const X &x) : T(t), _edgeWidths(x) {}
527  };
528  ///Sets the map of the edge widths
529
530  ///Sets the map of the edge widths
531  ///\param x must be a edge map with \c double (or convertible) values.
532  template<class X> GraphToEps<EdgeWidthsTraits<X> > edgeWidths(const X &x)
533  {
534    dontPrint=true;
535    return GraphToEps<EdgeWidthsTraits<X> >(EdgeWidthsTraits<X>(*this,x));
536  }
537
538  template<class X> struct NodeColorsTraits : public T {
539    const X &_nodeColors;
540    NodeColorsTraits(const T &t,const X &x) : T(t), _nodeColors(x) {}
541  };
542  ///Sets the map of the node colors
543
544  ///Sets the map of the node colors
545  ///\param x must be a node map with \ref Color values.
546  ///
547  ///\sa ColorSet
548  template<class X> GraphToEps<NodeColorsTraits<X> >
549  nodeColors(const X &x)
550  {
551    dontPrint=true;
552    return GraphToEps<NodeColorsTraits<X> >(NodeColorsTraits<X>(*this,x));
553  }
554  template<class X> struct NodeTextColorsTraits : public T {
555    const X &_nodeTextColors;
556    NodeTextColorsTraits(const T &t,const X &x) : T(t), _nodeTextColors(x) {}
557  };
558  ///Sets the map of the node text colors
559
560  ///Sets the map of the node text colors
561  ///\param x must be a node map with \ref Color values.
562  ///
563  ///\sa ColorSet
564  template<class X> GraphToEps<NodeTextColorsTraits<X> >
565  nodeTextColors(const X &x)
566  {
567    dontPrint=true;
568    _nodeTextColorType=CUST_COL;
569    return GraphToEps<NodeTextColorsTraits<X> >
570      (NodeTextColorsTraits<X>(*this,x));
571  }
572  template<class X> struct EdgeColorsTraits : public T {
573    const X &_edgeColors;
574    EdgeColorsTraits(const T &t,const X &x) : T(t), _edgeColors(x) {}
575  };
576  ///Sets the map of the edge colors
577
578  ///Sets the map of the edge colors
579  ///\param x must be a edge map with \ref Color values.
580  ///
581  ///\sa ColorSet
582  template<class X> GraphToEps<EdgeColorsTraits<X> >
583  edgeColors(const X &x)
584  {
585    dontPrint=true;
586    return GraphToEps<EdgeColorsTraits<X> >(EdgeColorsTraits<X>(*this,x));
587  }
588  ///Sets a global scale factor for node sizes
589
590  ///Sets a global scale factor for node sizes.
591  ///
592  /// If nodeSizes() is not given, this function simply sets the node
593  /// sizes to \c d.  If nodeSizes() is given, but
594  /// autoNodeScale() is not, then the node size given by
595  /// nodeSizes() will be multiplied by the value \c d.
596  /// If both nodeSizes() and autoNodeScale() are used, then the
597  /// node sizes will be scaled in such a way that the greatest size will be
598  /// equal to \c d.
599  GraphToEps<T> &nodeScale(double d) {_nodeScale=d;return *this;}
600  ///Turns on/off the automatic node width scaling.
601
602  ///Turns on/off the automatic node width scaling.
603  ///
604  ///\sa nodeScale()
605  ///
606  GraphToEps<T> &autoNodeScale(bool b=true) {
607    _autoNodeScale=b;return *this;
608  }
609
610  ///Negates the Y coordinates.
611
612  ///Negates the Y coordinates.
613  ///
614  ///\todo More docs.
615  ///
616  GraphToEps<T> &negateY(bool b=true) {
617    _negY=b;return *this;
618  }
619
620  ///Sets a global scale factor for edge widths
621
622  /// Sets a global scale factor for edge widths.
623  ///
624  /// If edgeWidths() is not given, this function simply sets the edge
625  /// widths to \c d.  If edgeWidths() is given, but
626  /// autoEdgeWidthScale() is not, then the edge withs given by
627  /// edgeWidths() will be multiplied by the value \c d.
628  /// If both edgeWidths() and autoEdgeWidthScale() are used, then the
629  /// edge withs will be scaled in such a way that the greatest width will be
630  /// equal to \c d.
631  GraphToEps<T> &edgeWidthScale(double d) {_edgeWidthScale=d;return *this;}
632  ///Turns on/off the automatic edge width scaling.
633
634  ///Turns on/off the automatic edge width scaling.
635  ///
636  ///\sa edgeWidthScale()
637  ///
638  GraphToEps<T> &autoEdgeWidthScale(bool b=true) {
639    _autoEdgeWidthScale=b;return *this;
640  }
641  ///Sets a global scale factor for the whole picture
642
643  ///Sets a global scale factor for the whole picture
644  ///
645
646  GraphToEps<T> &scale(double d) {_scale=d;return *this;}
647  ///Sets the width of the border around the picture
648
649  ///Sets the width of the border around the picture
650  ///
651  GraphToEps<T> &border(double b) {_xBorder=_yBorder=b;return *this;}
652  ///Sets the width of the border around the picture
653
654  ///Sets the width of the border around the picture
655  ///
656  GraphToEps<T> &border(double x, double y) {
657    _xBorder=x;_yBorder=y;return *this;
658  }
659  ///Sets whether to draw arrows
660
661  ///Sets whether to draw arrows
662  ///
663  GraphToEps<T> &drawArrows(bool b=true) {_drawArrows=b;return *this;}
664  ///Sets the length of the arrowheads
665
666  ///Sets the length of the arrowheads
667  ///
668  GraphToEps<T> &arrowLength(double d) {_arrowLength*=d;return *this;}
669  ///Sets the width of the arrowheads
670
671  ///Sets the width of the arrowheads
672  ///
673  GraphToEps<T> &arrowWidth(double d) {_arrowWidth*=d;return *this;}
674 
675  ///Scales the drawing to fit to A4 page
676
677  ///Scales the drawing to fit to A4 page
678  ///
679  GraphToEps<T> &scaleToA4() {_scaleToA4=true;return *this;}
680 
681  ///Enables parallel edges
682
683  ///Enables parallel edges
684  GraphToEps<T> &enableParallel(bool b=true) {_enableParallel=b;return *this;}
685 
686  ///Sets the distance
687 
688  ///Sets the distance
689  ///
690  GraphToEps<T> &parEdgeDist(double d) {_parEdgeDist*=d;return *this;}
691 
692  ///Hides the edges
693 
694  ///Hides the edges
695  ///
696  GraphToEps<T> &hideEdges(bool b=true) {_showEdges=!b;return *this;}
697  ///Hides the nodes
698 
699  ///Hides the nodes
700  ///
701  GraphToEps<T> &hideNodes(bool b=true) {_showNodes=!b;return *this;}
702 
703  ///Sets the size of the node texts
704 
705  ///Sets the size of the node texts
706  ///
707  GraphToEps<T> &nodeTextSize(double d) {_nodeTextSize=d;return *this;}
708
709  ///Sets the color of the node texts to be different from the node color
710
711  ///Sets the color of the node texts to be as different from the node color
712  ///as it is possible
713  ///
714  GraphToEps<T> &distantColorNodeTexts()
715  {_nodeTextColorType=DIST_COL;return *this;}
716  ///Sets the color of the node texts to be black or white and always visible.
717
718  ///Sets the color of the node texts to be black or white according to
719  ///which is more
720  ///different from the node color
721  ///
722  GraphToEps<T> &distantBWNodeTexts()
723  {_nodeTextColorType=DIST_BW;return *this;}
724
725  ///Gives a preamble block for node Postscript block.
726 
727  ///Gives a preamble block for node Postscript block.
728  ///
729  ///\sa nodePsTexts()
730  GraphToEps<T> & nodePsTextsPreamble(const char *str) {
731    _nodePsTextsPreamble=str ;return *this;
732  }
733  ///Sets whether the the graph is undirected
734
735  ///Sets whether the the graph is undirected
736  ///
737  GraphToEps<T> &undir(bool b=true) {_undir=b;return *this;}
738  ///Sets whether the the graph is directed
739
740  ///Sets whether the the graph is directed.
741  ///Use it to show the undirected edges as a pair of directed ones.
742  GraphToEps<T> &bidir(bool b=true) {_undir=!b;return *this;}
743
744  ///Sets the title.
745
746  ///Sets the title of the generated image,
747  ///namely it inserts a <tt>%%Title:</tt> DSC field to the header of
748  ///the EPS file.
749  GraphToEps<T> &title(const std::string &t) {_title=t;return *this;}
750  ///Sets the copyright statement.
751
752  ///Sets the copyright statement of the generated image,
753  ///namely it inserts a <tt>%%Copyright:</tt> DSC field to the header of
754  ///the EPS file.
755  ///\todo Multiline copyright notice could be supported.
756  GraphToEps<T> &copyright(const std::string &t) {_copyright=t;return *this;}
757
758protected:
759  bool isInsideNode(xy<double> p, double r,int t)
760  {
761    switch(t) {
762    case CIRCLE:
763    case MALE:
764    case FEMALE:
765      return p.normSquare()<=r*r;
766    case SQUARE:
767      return p.x<=r&&p.x>=-r&&p.y<=r&&p.y>=-r;
768    case DIAMOND:
769      return p.x+p.y<=r && p.x-p.y<=r && -p.x+p.y<=r && -p.x-p.y<=r;
770    }
771    return false;
772  }
773
774public:
775  ~GraphToEps() { }
776 
777  ///Draws the graph.
778
779  ///Like other functions using
780  ///\ref named-templ-func-param "named template parameters",
781  ///this function calles the algorithm itself, i.e. in this case
782  ///it draws the graph.
783  void run() {
784    if(dontPrint) return;
785   
786    _NegY<typename T::CoordsMapType> mycoords(_coords,_negY);
787
788    os << "%!PS-Adobe-2.0 EPSF-2.0\n";
789    if(_title.size()>0) os << "%%Title: " << _title << '\n';
790     if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n';
791//        << "%%Copyright: XXXX\n"
792    os << "%%Creator: LEMON, graphToEps()\n";
793   
794    {
795      char cbuf[50];
796      timeval tv;
797      gettimeofday(&tv, 0);
798      ctime_r(&tv.tv_sec,cbuf);
799      os << "%%CreationDate: " << cbuf;
800    }
801
802    if (_autoEdgeWidthScale) {
803      double max_w=0;
804      for(EdgeIt e(g);e!=INVALID;++e)
805        max_w=std::max(double(_edgeWidths[e]),max_w);
806      ///\todo better 'epsilon' would be nice here.
807      if(max_w>1e-9) {
808        _edgeWidthScale/=max_w;
809      }
810    }
811
812    if (_autoNodeScale) {
813      double max_s=0;
814      for(NodeIt n(g);n!=INVALID;++n)
815        max_s=std::max(double(_nodeSizes[n]),max_s);
816      ///\todo better 'epsilon' would be nice here.
817      if(max_s>1e-9) {
818        _nodeScale/=max_s;
819      }
820    }
821
822
823    BoundingBox<double> bb;
824    ///\bug: Chech whether the graph is empty.
825    for(NodeIt n(g);n!=INVALID;++n) {
826      double ns=_nodeSizes[n]*_nodeScale;
827      xy<double> p(ns,ns);
828      switch(_nodeShapes[n]) {
829      case CIRCLE:
830      case SQUARE:
831      case DIAMOND:
832        bb.add(p+mycoords[n]);
833        bb.add(-p+mycoords[n]);
834        break;
835      case MALE:
836        bb.add(-p+mycoords[n]);
837        bb.add(xy<double>(1.5*ns,1.5*sqrt(3)*ns)+mycoords[n]);
838        break;
839      case FEMALE:
840        bb.add(p+mycoords[n]);
841        bb.add(xy<double>(-ns,-3.01*ns)+mycoords[n]);
842        break;
843      }
844    }
845    if (bb.empty()) {
846      bb = BoundingBox<double>(xy<double>(0,0));
847    }
848   
849    if(_scaleToA4)
850      os <<"%%BoundingBox: 0 0 596 842\n%%DocumentPaperSizes: a4\n";
851    else os << "%%BoundingBox: "
852            << bb.left()   * _scale - _xBorder << ' '
853            << bb.bottom() * _scale - _yBorder << ' '
854            << bb.right()  * _scale + _xBorder << ' '
855            << bb.top()    * _scale + _yBorder << '\n';
856   
857    os << "%%EndComments\n";
858   
859    //x1 y1 x2 y2 x3 y3 cr cg cb w
860    os << "/lb { setlinewidth setrgbcolor newpath moveto\n"
861       << "      4 2 roll 1 index 1 index curveto stroke } bind def\n";
862    os << "/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def\n";
863    //x y r
864    os << "/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def\n";
865    //x y r
866    os << "/sq { newpath 2 index 1 index add 2 index 2 index add moveto\n"
867       << "      2 index 1 index sub 2 index 2 index add lineto\n"
868       << "      2 index 1 index sub 2 index 2 index sub lineto\n"
869       << "      2 index 1 index add 2 index 2 index sub lineto\n"
870       << "      closepath pop pop pop} bind def\n";
871    //x y r
872    os << "/di { newpath 2 index 1 index add 2 index moveto\n"
873       << "      2 index             2 index 2 index add lineto\n"
874       << "      2 index 1 index sub 2 index             lineto\n"
875       << "      2 index             2 index 2 index sub lineto\n"
876       << "      closepath pop pop pop} bind def\n";
877    // x y r cr cg cb
878    os << "/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill\n"
879       << "     setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n"
880       << "   } bind def\n";
881    os << "/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill\n"
882       << "     setrgbcolor " << 1+_nodeBorderQuotient << " div sq fill\n"
883       << "   } bind def\n";
884    os << "/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill\n"
885       << "     setrgbcolor " << 1+_nodeBorderQuotient << " div di fill\n"
886       << "   } bind def\n";
887    os << "/nfemale { 0 0 0 setrgbcolor 3 index "
888       << _nodeBorderQuotient/(1+_nodeBorderQuotient)
889       << " 1.5 mul mul setlinewidth\n"
890       << "  newpath 5 index 5 index moveto "
891       << "5 index 5 index 5 index 3.01 mul sub\n"
892       << "  lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto\n"
893       << "  5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke\n"
894       << "  5 index 5 index 5 index c fill\n"
895       << "  setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n"
896       << "  } bind def\n";
897    os << "/nmale {\n"
898       << "  0 0 0 setrgbcolor 3 index "
899       << _nodeBorderQuotient/(1+_nodeBorderQuotient)
900       <<" 1.5 mul mul setlinewidth\n"
901       << "  newpath 5 index 5 index moveto\n"
902       << "  5 index 4 index 1 mul 1.5 mul add\n"
903       << "  5 index 5 index 3 sqrt 1.5 mul mul add\n"
904       << "  1 index 1 index lineto\n"
905       << "  1 index 1 index 7 index sub moveto\n"
906       << "  1 index 1 index lineto\n"
907       << "  exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto\n"
908       << "  stroke\n"
909       << "  5 index 5 index 5 index c fill\n"
910       << "  setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n"
911       << "  } bind def\n";
912   
913
914    os << "/arrl " << _arrowLength << " def\n";
915    os << "/arrw " << _arrowWidth << " def\n";
916    // l dx_norm dy_norm
917    os << "/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def\n";
918    //len w dx_norm dy_norm x1 y1 cr cg cb
919    os << "/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def\n"
920       << "       /w exch def /len exch def\n"
921      //         << "       0.1 setlinewidth x1 y1 moveto dx len mul dy len mul rlineto stroke"
922       << "       newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto\n"
923       << "       len w sub arrl sub dx dy lrl\n"
924       << "       arrw dy dx neg lrl\n"
925       << "       dx arrl w add mul dy w 2 div arrw add mul sub\n"
926       << "       dy arrl w add mul dx w 2 div arrw add mul add rlineto\n"
927       << "       dx arrl w add mul neg dy w 2 div arrw add mul sub\n"
928       << "       dy arrl w add mul neg dx w 2 div arrw add mul add rlineto\n"
929       << "       arrw dy dx neg lrl\n"
930       << "       len w sub arrl sub neg dx dy lrl\n"
931       << "       closepath fill } bind def\n";
932    os << "/cshow { 2 index 2 index moveto dup stringwidth pop\n"
933       << "         neg 2 div fosi .35 mul neg rmoveto show pop pop} def\n";
934
935    os << "\ngsave\n";
936    if(_scaleToA4)
937      if(bb.height()>bb.width()) {
938        double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.height(),
939                  (A4WIDTH-2*A4BORDER)/bb.width());
940        os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' '
941           << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER << " translate\n"
942           << sc << " dup scale\n"
943           << -bb.left() << ' ' << -bb.bottom() << " translate\n";
944      }
945      else {
946        //\todo Verify centering
947        double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(),
948                  (A4WIDTH-2*A4BORDER)/bb.height());
949        os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' '
950           << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER  << " translate\n"
951           << sc << " dup scale\n90 rotate\n"
952           << -bb.left() << ' ' << -bb.top() << " translate\n";
953        }
954    else if(_scale!=1.0) os << _scale << " dup scale\n";
955   
956    if(_showEdges) {
957      os << "%Edges:\ngsave\n";     
958      if(_enableParallel) {
959        std::vector<Edge> el;
960        for(EdgeIt e(g);e!=INVALID;++e)
961          if((!_undir||g.source(e)<g.target(e))&&_edgeWidths[e]>0)
962            el.push_back(e);
963        std::sort(el.begin(),el.end(),edgeLess(g));
964       
965        typename std::vector<Edge>::iterator j;
966        for(typename std::vector<Edge>::iterator i=el.begin();i!=el.end();i=j) {
967          for(j=i+1;j!=el.end()&&isParallel(*i,*j);++j) ;
968
969          double sw=0;
970          for(typename std::vector<Edge>::iterator e=i;e!=j;++e)
971            sw+=_edgeWidths[*e]*_edgeWidthScale+_parEdgeDist;
972          sw-=_parEdgeDist;
973          sw/=-2.0;
974          xy<double> dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
975          double l=std::sqrt(dvec.normSquare());
976          ///\todo better 'epsilon' would be nice here.
977          xy<double> d(dvec/std::max(l,1e-9));
978          xy<double> m;
979//        m=xy<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
980
981//        m=xy<double>(mycoords[g.source(*i)])+
982//          dvec*(double(_nodeSizes[g.source(*i)])/
983//             (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)]));
984
985          m=xy<double>(mycoords[g.source(*i)])+
986            d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0;
987
988          for(typename std::vector<Edge>::iterator e=i;e!=j;++e) {
989            sw+=_edgeWidths[*e]*_edgeWidthScale/2.0;
990            xy<double> mm=m+rot90(d)*sw/.75;
991            if(_drawArrows) {
992              int node_shape;
993              xy<double> s=mycoords[g.source(*e)];
994              xy<double> t=mycoords[g.target(*e)];
995              double rn=_nodeSizes[g.target(*e)]*_nodeScale;
996              node_shape=_nodeShapes[g.target(*e)];
997              Bezier3 bez(s,mm,mm,t);
998              double t1=0,t2=1;
999              for(int i=0;i<INTERPOL_PREC;++i)
1000                if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t2=(t1+t2)/2;
1001                else t1=(t1+t2)/2;
1002              xy<double> apoint=bez((t1+t2)/2);
1003              rn = _arrowLength+_edgeWidths[*e]*_edgeWidthScale;
1004              rn*=rn;
1005              t2=(t1+t2)/2;t1=0;
1006              for(int i=0;i<INTERPOL_PREC;++i)
1007                if((bez((t1+t2)/2)-apoint).normSquare()>rn) t1=(t1+t2)/2;
1008                else t2=(t1+t2)/2;
1009              xy<double> linend=bez((t1+t2)/2);       
1010              bez=bez.before((t1+t2)/2);
1011//            rn=_nodeSizes[g.source(*e)]*_nodeScale;
1012//            node_shape=_nodeShapes[g.source(*e)];
1013//            t1=0;t2=1;
1014//            for(int i=0;i<INTERPOL_PREC;++i)
1015//              if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t1=(t1+t2)/2;
1016//              else t2=(t1+t2)/2;
1017//            bez=bez.after((t1+t2)/2);
1018              os << _edgeWidths[*e]*_edgeWidthScale << " setlinewidth "
1019                 << _edgeColors[*e].red() << ' '
1020                 << _edgeColors[*e].green() << ' '
1021                 << _edgeColors[*e].blue() << " setrgbcolor newpath\n"
1022                 << bez.p1.x << ' ' <<  bez.p1.y << " moveto\n"
1023                 << bez.p2.x << ' ' << bez.p2.y << ' '
1024                 << bez.p3.x << ' ' << bez.p3.y << ' '
1025                 << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n";
1026              xy<double> dd(rot90(linend-apoint));
1027              dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/
1028                std::sqrt(dd.normSquare());
1029              os << "newpath " << psOut(apoint) << " moveto "
1030                 << psOut(linend+dd) << " lineto "
1031                 << psOut(linend-dd) << " lineto closepath fill\n";
1032            }
1033            else {
1034              os << mycoords[g.source(*e)].x << ' '
1035                 << mycoords[g.source(*e)].y << ' '
1036                 << mm.x << ' ' << mm.y << ' '
1037                 << mycoords[g.target(*e)].x << ' '
1038                 << mycoords[g.target(*e)].y << ' '
1039                 << _edgeColors[*e].red() << ' '
1040                 << _edgeColors[*e].green() << ' '
1041                 << _edgeColors[*e].blue() << ' '
1042                 << _edgeWidths[*e]*_edgeWidthScale << " lb\n";
1043            }
1044            sw+=_edgeWidths[*e]*_edgeWidthScale/2.0+_parEdgeDist;
1045          }
1046        }
1047      }
1048      else for(EdgeIt e(g);e!=INVALID;++e)
1049        if((!_undir||g.source(e)<g.target(e))&&_edgeWidths[e]>0)
1050          if(_drawArrows) {
1051            xy<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);
1052            double rn=_nodeSizes[g.target(e)]*_nodeScale;
1053            int node_shape=_nodeShapes[g.target(e)];
1054            double t1=0,t2=1;
1055            for(int i=0;i<INTERPOL_PREC;++i)
1056              if(isInsideNode((-(t1+t2)/2)*d,rn,node_shape)) t1=(t1+t2)/2;
1057              else t2=(t1+t2)/2;
1058            double l=sqrt(d.normSquare());
1059            d/=l;
1060           
1061            os << l*(1-(t1+t2)/2) << ' '
1062               << _edgeWidths[e]*_edgeWidthScale << ' '
1063               << d.x << ' ' << d.y << ' '
1064               << mycoords[g.source(e)].x << ' '
1065               << mycoords[g.source(e)].y << ' '
1066               << _edgeColors[e].red() << ' '
1067               << _edgeColors[e].green() << ' '
1068               << _edgeColors[e].blue() << " arr\n";
1069          }
1070          else os << mycoords[g.source(e)].x << ' '
1071                  << mycoords[g.source(e)].y << ' '
1072                  << mycoords[g.target(e)].x << ' '
1073                  << mycoords[g.target(e)].y << ' '
1074                  << _edgeColors[e].red() << ' '
1075                  << _edgeColors[e].green() << ' '
1076                  << _edgeColors[e].blue() << ' '
1077                  << _edgeWidths[e]*_edgeWidthScale << " l\n";
1078      os << "grestore\n";
1079    }
1080    if(_showNodes) {
1081      os << "%Nodes:\ngsave\n";
1082      for(NodeIt n(g);n!=INVALID;++n) {
1083        os << mycoords[n].x << ' ' << mycoords[n].y << ' '
1084           << _nodeSizes[n]*_nodeScale << ' '
1085           << _nodeColors[n].red() << ' '
1086           << _nodeColors[n].green() << ' '
1087           << _nodeColors[n].blue() << ' ';
1088        switch(_nodeShapes[n]) {
1089        case CIRCLE:
1090          os<< "nc";break;
1091        case SQUARE:
1092          os<< "nsq";break;
1093        case DIAMOND:
1094          os<< "ndi";break;
1095        case MALE:
1096          os<< "nmale";break;
1097        case FEMALE:
1098          os<< "nfemale";break;
1099        }
1100        os<<'\n';
1101      }
1102      os << "grestore\n";
1103    }
1104    if(_showNodeText) {
1105      os << "%Node texts:\ngsave\n";
1106      os << "/fosi " << _nodeTextSize << " def\n";
1107      os << "(Helvetica) findfont fosi scalefont setfont\n";
1108      for(NodeIt n(g);n!=INVALID;++n) {
1109        switch(_nodeTextColorType) {
1110        case DIST_COL:
1111          os << psOut(distantColor(_nodeColors[n])) << " setrgbcolor\n";
1112          break;
1113        case DIST_BW:
1114          os << psOut(distantBW(_nodeColors[n])) << " setrgbcolor\n";
1115          break;
1116        case CUST_COL:
1117          os << psOut(distantColor(_nodeTextColors[n])) << " setrgbcolor\n";
1118          break;
1119        default:
1120          os << "0 0 0 setrgbcolor\n";
1121        }
1122        os << mycoords[n].x << ' ' << mycoords[n].y
1123           << " (" << _nodeTexts[n] << ") cshow\n";
1124      }
1125      os << "grestore\n";
1126    }
1127    if(_showNodePsText) {
1128      os << "%Node PS blocks:\ngsave\n";
1129      for(NodeIt n(g);n!=INVALID;++n)
1130        os << mycoords[n].x << ' ' << mycoords[n].y
1131           << " moveto\n" << _nodePsTexts[n] << "\n";
1132      os << "grestore\n";
1133    }
1134   
1135    os << "grestore\nshowpage\n";
1136
1137    //CleanUp:
1138    if(_pleaseRemoveOsStream) {delete &os;}
1139  }
1140};
1141
1142template<class T>
1143const int GraphToEps<T>::INTERPOL_PREC = 20;
1144template<class T>
1145const double GraphToEps<T>::A4HEIGHT = 841.8897637795276;
1146template<class T>
1147const double GraphToEps<T>::A4WIDTH  = 595.275590551181;
1148template<class T>
1149const double GraphToEps<T>::A4BORDER = 15;
1150
1151
1152///Generates an EPS file from a graph
1153
1154///\ingroup io_group
1155///Generates an EPS file from a graph.
1156///\param g is a reference to the graph to be printed
1157///\param os is a reference to the output stream.
1158///By default it is <tt>std::cout</tt>
1159///
1160///This function also has a lot of
1161///\ref named-templ-func-param "named parameters",
1162///they are declared as the members of class \ref GraphToEps. The following
1163///example shows how to use these parameters.
1164///\code
1165/// graphToEps(g,os).scale(10).coords(coords)
1166///              .nodeScale(2).nodeSizes(sizes)
1167///              .edgeWidthScale(.4).run();
1168///\endcode
1169///\warning Don't forget to put the \ref GraphToEps::run() "run()"
1170///to the end of the parameter list.
1171///\sa GraphToEps
1172///\sa graphToEps(G &g, const char *file_name)
1173template<class G>
1174GraphToEps<DefaultGraphToEpsTraits<G> >
1175graphToEps(G &g, std::ostream& os=std::cout)
1176{
1177  return
1178    GraphToEps<DefaultGraphToEpsTraits<G> >(DefaultGraphToEpsTraits<G>(g,os));
1179}
1180 
1181///Generates an EPS file from a graph
1182
1183///\ingroup io_group
1184///This function does the same as
1185///\ref graphToEps(G &g,std::ostream& os)
1186///but it writes its output into the file \c file_name
1187///instead of a stream.
1188///\sa graphToEps(G &g, std::ostream& os)
1189template<class G>
1190GraphToEps<DefaultGraphToEpsTraits<G> >
1191graphToEps(G &g,const char *file_name)
1192{
1193  return GraphToEps<DefaultGraphToEpsTraits<G> >
1194    (DefaultGraphToEpsTraits<G>(g,*new std::ofstream(file_name),true));
1195}
1196
1197///Generates an EPS file from a graph
1198
1199///\ingroup io_group
1200///This function does the same as
1201///\ref graphToEps(G &g,std::ostream& os)
1202///but it writes its output into the file \c file_name
1203///instead of a stream.
1204///\sa graphToEps(G &g, std::ostream& os)
1205template<class G>
1206GraphToEps<DefaultGraphToEpsTraits<G> >
1207graphToEps(G &g,const std::string& file_name)
1208{
1209  return GraphToEps<DefaultGraphToEpsTraits<G> >
1210    (DefaultGraphToEpsTraits<G>(g,*new std::ofstream(file_name.c_str()),true));
1211}
1212
1213} //END OF NAMESPACE LEMON
1214
1215#endif // LEMON_GRAPH_TO_EPS_H
Note: See TracBrowser for help on using the repository browser.