alpar@1073: /* -*- C++ -*- alpar@1073: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library alpar@1956: * alpar@1956: * Copyright (C) 2003-2006 alpar@1956: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1359: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@1073: * alpar@1073: * Permission to use, modify and distribute this software is granted alpar@1073: * provided that this copyright notice appears in all copies. For alpar@1073: * precise terms see the accompanying LICENSE file. alpar@1073: * alpar@1073: * This software is provided "AS IS" with no warranty of any kind, alpar@1073: * express or implied, and with no claim as to its suitability for any alpar@1073: * purpose. alpar@1073: * alpar@1073: */ alpar@1073: alpar@1073: #ifndef LEMON_GRAPH_TO_EPS_H alpar@1073: #define LEMON_GRAPH_TO_EPS_H alpar@1073: alpar@1108: #include alpar@1108: deba@2028: #ifdef WIN32 deba@2028: #include deba@2028: #endif deba@2028: alpar@1073: #include alpar@1073: #include alpar@1073: #include alpar@1073: #include alpar@1073: #include alpar@1073: deba@1417: #include deba@1417: #include deba@1417: deba@1993: #include alpar@2207: #include alpar@1073: #include alpar@1971: #include alpar@2178: #include alpar@1073: deba@1417: deba@2084: ///\ingroup eps_io alpar@1073: ///\file alpar@1073: ///\brief Simple graph drawer alpar@1073: /// alpar@1073: ///\author Alpar Juttner alpar@1073: alpar@1073: namespace lemon { alpar@1073: alpar@1673: template alpar@1673: class _NegY { alpar@1673: public: alpar@1673: typedef typename MT::Key Key; alpar@1673: typedef typename MT::Value Value; alpar@1673: const MT ↦ alpar@1673: int yscale; alpar@1673: _NegY(const MT &m,bool b) : map(m), yscale(1-b*2) {} alpar@1673: Value operator[](Key n) { return Value(map[n].x,map[n].y*yscale);} alpar@1673: }; alpar@1673: alpar@1073: ///Default traits class of \ref GraphToEps alpar@1073: alpar@1073: ///Default traits class of \ref GraphToEps alpar@1073: /// alpar@1073: ///\c G is the type of the underlying graph. alpar@1073: template alpar@1073: struct DefaultGraphToEpsTraits alpar@1073: { alpar@1073: typedef G Graph; alpar@1073: typedef typename Graph::Node Node; alpar@1073: typedef typename Graph::NodeIt NodeIt; alpar@1073: typedef typename Graph::Edge Edge; alpar@1073: typedef typename Graph::EdgeIt EdgeIt; alpar@1073: typedef typename Graph::InEdgeIt InEdgeIt; alpar@1073: typedef typename Graph::OutEdgeIt OutEdgeIt; alpar@1073: alpar@1073: alpar@1073: const Graph &g; alpar@1073: alpar@1073: std::ostream& os; alpar@1073: alpar@2207: typedef ConstMap > CoordsMapType; alpar@1673: CoordsMapType _coords; alpar@1073: ConstMap _nodeSizes; alpar@1086: ConstMap _nodeShapes; alpar@1073: alpar@1073: ConstMap _nodeColors; alpar@1073: ConstMap _edgeColors; alpar@1073: alpar@1073: ConstMap _edgeWidths; alpar@1103: alpar@1073: double _edgeWidthScale; alpar@1073: alpar@1073: double _nodeScale; alpar@1073: double _xBorder, _yBorder; alpar@1073: double _scale; alpar@1073: double _nodeBorderQuotient; alpar@1073: alpar@1073: bool _drawArrows; alpar@1073: double _arrowLength, _arrowWidth; alpar@1073: alpar@1073: bool _showNodes, _showEdges; alpar@1073: alpar@1073: bool _enableParallel; alpar@1073: double _parEdgeDist; alpar@1073: alpar@1073: bool _showNodeText; alpar@1073: ConstMap _nodeTexts; alpar@1073: double _nodeTextSize; alpar@1073: alpar@1085: bool _showNodePsText; alpar@1085: ConstMap _nodePsTexts; alpar@1085: char *_nodePsTextsPreamble; alpar@1085: deba@1910: bool _undirected; deba@1910: alpar@1073: bool _pleaseRemoveOsStream; alpar@1103: alpar@1103: bool _scaleToA4; alpar@1108: alpar@1108: std::string _title; alpar@1108: std::string _copyright; alpar@1178: alpar@1178: enum NodeTextColorType alpar@1178: { DIST_COL=0, DIST_BW=1, CUST_COL=2, SAME_COL=3 } _nodeTextColorType; alpar@1178: ConstMap _nodeTextColors; alpar@1178: alpar@1604: bool _autoNodeScale; alpar@1604: bool _autoEdgeWidthScale; alpar@1604: alpar@2178: bool _absoluteNodeSizes; alpar@2178: bool _absoluteEdgeWidths; alpar@2178: alpar@1673: bool _negY; alpar@1073: ///Constructor alpar@1073: alpar@1073: ///Constructor alpar@1073: ///\param _g is a reference to the graph to be printed alpar@1073: ///\param _os is a reference to the output stream. alpar@1073: ///\param _os is a reference to the output stream. alpar@1073: ///\param _pros If it is \c true, then the \c ostream referenced by \c _os alpar@1073: ///will be explicitly deallocated by the destructor. alpar@1073: ///By default it is std::cout alpar@1073: DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout, alpar@1073: bool _pros=false) : alpar@1073: g(_g), os(_os), alpar@2207: _coords(dim2::Point(1,1)), _nodeSizes(.01), _nodeShapes(0), alpar@2174: _nodeColors(WHITE), _edgeColors(BLACK), alpar@2178: _edgeWidths(1.0), _edgeWidthScale(0.003), alpar@1073: _nodeScale(1.0), _xBorder(10), _yBorder(10), _scale(1.0), alpar@1073: _nodeBorderQuotient(.1), alpar@1073: _drawArrows(false), _arrowLength(1), _arrowWidth(0.3), alpar@1073: _showNodes(true), _showEdges(true), alpar@1073: _enableParallel(false), _parEdgeDist(1), alpar@1073: _showNodeText(false), _nodeTexts(false), _nodeTextSize(1), alpar@1085: _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0), deba@1910: _undirected(false), alpar@1178: _pleaseRemoveOsStream(_pros), _scaleToA4(false), alpar@2174: _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK), alpar@1604: _autoNodeScale(false), alpar@1673: _autoEdgeWidthScale(false), alpar@2178: _absoluteNodeSizes(false), alpar@2178: _absoluteEdgeWidths(false), alpar@1673: _negY(false) alpar@1178: {} alpar@1073: }; alpar@1073: alpar@1073: ///Helper class to implement the named parameters of \ref graphToEps() alpar@1073: alpar@1073: ///Helper class to implement the named parameters of \ref graphToEps() alpar@1073: ///\todo Is 'helper class' a good name for this? alpar@1073: /// alpar@1103: ///\todo Follow PostScript's DSC. alpar@1107: /// Use own dictionary. alpar@1107: ///\todo Useful new features. alpar@1107: /// - Linestyles: dotted, dashed etc. alpar@1107: /// - A second color and percent value for the lines. alpar@1073: template class GraphToEps : public T alpar@1073: { alpar@1234: // Can't believe it is required by the C++ standard alpar@1234: using T::g; alpar@1234: using T::os; alpar@1234: alpar@1234: using T::_coords; alpar@1234: using T::_nodeSizes; alpar@1234: using T::_nodeShapes; alpar@1234: using T::_nodeColors; alpar@1234: using T::_edgeColors; alpar@1234: using T::_edgeWidths; alpar@1234: alpar@1234: using T::_edgeWidthScale; alpar@1234: using T::_nodeScale; alpar@1234: using T::_xBorder; alpar@1234: using T::_yBorder; alpar@1234: using T::_scale; alpar@1234: using T::_nodeBorderQuotient; alpar@1234: alpar@1234: using T::_drawArrows; alpar@1234: using T::_arrowLength; alpar@1234: using T::_arrowWidth; alpar@1234: alpar@1234: using T::_showNodes; alpar@1234: using T::_showEdges; alpar@1234: alpar@1234: using T::_enableParallel; alpar@1234: using T::_parEdgeDist; alpar@1234: alpar@1234: using T::_showNodeText; alpar@1234: using T::_nodeTexts; alpar@1234: using T::_nodeTextSize; alpar@1234: alpar@1234: using T::_showNodePsText; alpar@1234: using T::_nodePsTexts; alpar@1234: using T::_nodePsTextsPreamble; alpar@1234: deba@1910: using T::_undirected; deba@1910: alpar@1234: using T::_pleaseRemoveOsStream; alpar@1234: alpar@1234: using T::_scaleToA4; alpar@1234: alpar@1234: using T::_title; alpar@1234: using T::_copyright; alpar@1234: alpar@1234: using T::NodeTextColorType; alpar@1234: using T::CUST_COL; alpar@1234: using T::DIST_COL; alpar@1234: using T::DIST_BW; alpar@1234: using T::_nodeTextColorType; alpar@1234: using T::_nodeTextColors; alpar@1604: alpar@1604: using T::_autoNodeScale; alpar@1604: using T::_autoEdgeWidthScale; alpar@1604: alpar@2178: using T::_absoluteNodeSizes; alpar@2178: using T::_absoluteEdgeWidths; alpar@2178: alpar@2178: deba@1676: using T::_negY; deba@1676: alpar@1234: // dradnats ++C eht yb deriuqer si ti eveileb t'naC alpar@1234: alpar@1073: typedef typename T::Graph Graph; alpar@1073: typedef typename Graph::Node Node; alpar@1073: typedef typename Graph::NodeIt NodeIt; alpar@1073: typedef typename Graph::Edge Edge; alpar@1073: typedef typename Graph::EdgeIt EdgeIt; alpar@1073: typedef typename Graph::InEdgeIt InEdgeIt; alpar@1073: typedef typename Graph::OutEdgeIt OutEdgeIt; alpar@1073: alpar@1494: static const int INTERPOL_PREC; alpar@1494: static const double A4HEIGHT; alpar@1494: static const double A4WIDTH; alpar@1494: static const double A4BORDER; alpar@1087: alpar@1073: bool dontPrint; alpar@1073: alpar@1107: public: alpar@1107: ///Node shapes alpar@1107: alpar@1107: ///Node shapes alpar@1107: /// alpar@1107: enum NodeShapes { alpar@1107: /// = 0 alpar@1107: ///\image html nodeshape_0.png alpar@1107: ///\image latex nodeshape_0.eps "CIRCLE shape (0)" width=2cm alpar@1107: CIRCLE=0, alpar@1107: /// = 1 alpar@1107: ///\image html nodeshape_1.png alpar@1107: ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm alpar@1107: /// alpar@1107: SQUARE=1, alpar@1107: /// = 2 alpar@1107: ///\image html nodeshape_2.png alpar@1107: ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm alpar@1107: /// alpar@1907: DIAMOND=2, alpar@1907: /// = 3 alpar@1907: ///\image html nodeshape_3.png alpar@1907: ///\image latex nodeshape_2.eps "MALE shape (4)" width=2cm alpar@1907: /// alpar@1907: MALE=3, alpar@1907: /// = 4 alpar@1907: ///\image html nodeshape_4.png alpar@1907: ///\image latex nodeshape_2.eps "FEMALE shape (4)" width=2cm alpar@1907: /// alpar@1907: FEMALE=4 alpar@1107: }; alpar@1107: alpar@1107: private: alpar@1073: class edgeLess { alpar@1073: const Graph &g; alpar@1073: public: alpar@1073: edgeLess(const Graph &_g) : g(_g) {} alpar@1073: bool operator()(Edge a,Edge b) const alpar@1073: { alpar@1367: Node ai=std::min(g.source(a),g.target(a)); alpar@1367: Node aa=std::max(g.source(a),g.target(a)); alpar@1367: Node bi=std::min(g.source(b),g.target(b)); alpar@1367: Node ba=std::max(g.source(b),g.target(b)); alpar@1073: return ai alpar@2207: static std::string psOut(const dim2::Point &p) alpar@1073: { alpar@1073: std::ostringstream os; alpar@1073: os << p.x << ' ' << p.y; alpar@1073: return os.str(); alpar@1073: } alpar@1178: static std::string psOut(const Color &c) alpar@1178: { alpar@1178: std::ostringstream os; alpar@1575: os << c.red() << ' ' << c.green() << ' ' << c.blue(); alpar@1178: return os.str(); alpar@1178: } alpar@1073: alpar@1073: public: alpar@1073: GraphToEps(const T &t) : T(t), dontPrint(false) {}; alpar@1073: alpar@1073: template struct CoordsTraits : public T { alpar@1673: typedef X CoordsMapType; alpar@1073: const X &_coords; alpar@1073: CoordsTraits(const T &t,const X &x) : T(t), _coords(x) {} alpar@1073: }; alpar@1073: ///Sets the map of the node coordinates alpar@1073: alpar@1073: ///Sets the map of the node coordinates. alpar@2207: ///\param x must be a node map with dim2::Point or alpar@2207: ///\ref dim2::Point "dim2::Point" values. alpar@1073: template GraphToEps > coords(const X &x) { alpar@1073: dontPrint=true; alpar@1073: return GraphToEps >(CoordsTraits(*this,x)); alpar@1073: } alpar@1073: template struct NodeSizesTraits : public T { alpar@1073: const X &_nodeSizes; alpar@1073: NodeSizesTraits(const T &t,const X &x) : T(t), _nodeSizes(x) {} alpar@1073: }; alpar@1073: ///Sets the map of the node sizes alpar@1073: alpar@1073: ///Sets the map of the node sizes alpar@1073: ///\param x must be a node map with \c double (or convertible) values. alpar@1073: template GraphToEps > nodeSizes(const X &x) alpar@1073: { alpar@1073: dontPrint=true; alpar@1073: return GraphToEps >(NodeSizesTraits(*this,x)); alpar@1073: } alpar@1086: template struct NodeShapesTraits : public T { alpar@1086: const X &_nodeShapes; alpar@1086: NodeShapesTraits(const T &t,const X &x) : T(t), _nodeShapes(x) {} alpar@1086: }; alpar@1086: ///Sets the map of the node shapes alpar@1086: alpar@1107: ///Sets the map of the node shapes. alpar@1107: ///The availabe shape values alpar@1107: ///can be found in \ref NodeShapes "enum NodeShapes". alpar@1086: ///\param x must be a node map with \c int (or convertible) values. alpar@1107: ///\sa NodeShapes alpar@1086: template GraphToEps > nodeShapes(const X &x) alpar@1086: { alpar@1086: dontPrint=true; alpar@1086: return GraphToEps >(NodeShapesTraits(*this,x)); alpar@1086: } alpar@1073: template struct NodeTextsTraits : public T { alpar@1073: const X &_nodeTexts; alpar@1073: NodeTextsTraits(const T &t,const X &x) : T(t), _nodeTexts(x) {} alpar@1073: }; alpar@1073: ///Sets the text printed on the nodes alpar@1073: alpar@1073: ///Sets the text printed on the nodes alpar@1073: ///\param x must be a node map with type that can be pushed to a standard alpar@1073: ///ostream. alpar@1073: template GraphToEps > nodeTexts(const X &x) alpar@1073: { alpar@1073: dontPrint=true; alpar@1073: _showNodeText=true; alpar@1073: return GraphToEps >(NodeTextsTraits(*this,x)); alpar@1073: } alpar@1085: template struct NodePsTextsTraits : public T { alpar@1085: const X &_nodePsTexts; alpar@1085: NodePsTextsTraits(const T &t,const X &x) : T(t), _nodePsTexts(x) {} alpar@1085: }; alpar@1085: ///Inserts a PostScript block to the nodes alpar@1085: alpar@1085: ///With this command it is possible to insert a verbatim PostScript alpar@1085: ///block to the nodes. alpar@1085: ///The PS current point will be moved to the centre of the node before alpar@1085: ///the PostScript block inserted. alpar@1085: /// alpar@1573: ///Before and after the block a newline character is inserted so you alpar@1085: ///don't have to bother with the separators. alpar@1085: /// alpar@1085: ///\param x must be a node map with type that can be pushed to a standard alpar@1085: ///ostream. alpar@1085: /// alpar@1085: ///\sa nodePsTextsPreamble() alpar@1085: ///\todo Offer the choise not to move to the centre but pass the coordinates alpar@1085: ///to the Postscript block inserted. alpar@1085: template GraphToEps > nodePsTexts(const X &x) alpar@1085: { alpar@1085: dontPrint=true; alpar@1085: _showNodePsText=true; alpar@1085: return GraphToEps >(NodePsTextsTraits(*this,x)); alpar@1085: } alpar@1085: template struct EdgeWidthsTraits : public T { alpar@1073: const X &_edgeWidths; alpar@1073: EdgeWidthsTraits(const T &t,const X &x) : T(t), _edgeWidths(x) {} alpar@1073: }; alpar@1073: ///Sets the map of the edge widths alpar@1073: alpar@1073: ///Sets the map of the edge widths alpar@1073: ///\param x must be a edge map with \c double (or convertible) values. alpar@1073: template GraphToEps > edgeWidths(const X &x) alpar@1073: { alpar@1073: dontPrint=true; alpar@1073: return GraphToEps >(EdgeWidthsTraits(*this,x)); alpar@1073: } alpar@1073: alpar@1073: template struct NodeColorsTraits : public T { alpar@1073: const X &_nodeColors; alpar@1073: NodeColorsTraits(const T &t,const X &x) : T(t), _nodeColors(x) {} alpar@1073: }; alpar@1073: ///Sets the map of the node colors alpar@1073: alpar@1073: ///Sets the map of the node colors alpar@1573: ///\param x must be a node map with \ref Color values. alpar@1573: /// alpar@2172: ///\sa Palette alpar@1073: template GraphToEps > alpar@1073: nodeColors(const X &x) alpar@1073: { alpar@1073: dontPrint=true; alpar@1073: return GraphToEps >(NodeColorsTraits(*this,x)); alpar@1073: } alpar@1178: template struct NodeTextColorsTraits : public T { alpar@1178: const X &_nodeTextColors; alpar@1178: NodeTextColorsTraits(const T &t,const X &x) : T(t), _nodeTextColors(x) {} alpar@1178: }; alpar@1178: ///Sets the map of the node text colors alpar@1178: alpar@1178: ///Sets the map of the node text colors alpar@1178: ///\param x must be a node map with \ref Color values. alpar@1573: /// alpar@2172: ///\sa Palette alpar@1178: template GraphToEps > alpar@1178: nodeTextColors(const X &x) alpar@1178: { alpar@1178: dontPrint=true; alpar@1178: _nodeTextColorType=CUST_COL; alpar@1178: return GraphToEps > alpar@1178: (NodeTextColorsTraits(*this,x)); alpar@1178: } alpar@1073: template struct EdgeColorsTraits : public T { alpar@1073: const X &_edgeColors; alpar@1073: EdgeColorsTraits(const T &t,const X &x) : T(t), _edgeColors(x) {} alpar@1073: }; alpar@1073: ///Sets the map of the edge colors alpar@1073: alpar@1073: ///Sets the map of the edge colors alpar@1073: ///\param x must be a edge map with \ref Color values. alpar@1573: /// alpar@2172: ///\sa Palette alpar@1073: template GraphToEps > alpar@1073: edgeColors(const X &x) alpar@1073: { alpar@1073: dontPrint=true; alpar@1073: return GraphToEps >(EdgeColorsTraits(*this,x)); alpar@1073: } alpar@1073: ///Sets a global scale factor for node sizes alpar@1073: alpar@1604: ///Sets a global scale factor for node sizes. alpar@1604: /// alpar@1604: /// If nodeSizes() is not given, this function simply sets the node alpar@1604: /// sizes to \c d. If nodeSizes() is given, but alpar@1604: /// autoNodeScale() is not, then the node size given by alpar@1604: /// nodeSizes() will be multiplied by the value \c d. alpar@1604: /// If both nodeSizes() and autoNodeScale() are used, then the alpar@1604: /// node sizes will be scaled in such a way that the greatest size will be alpar@1604: /// equal to \c d. alpar@2178: /// \sa nodeSizes() alpar@2178: /// \sa autoNodeScale() alpar@1604: GraphToEps &nodeScale(double d) {_nodeScale=d;return *this;} alpar@1604: ///Turns on/off the automatic node width scaling. alpar@1604: alpar@1604: ///Turns on/off the automatic node width scaling. alpar@1073: /// alpar@1604: ///\sa nodeScale() alpar@1604: /// alpar@1604: GraphToEps &autoNodeScale(bool b=true) { alpar@1604: _autoNodeScale=b;return *this; alpar@1604: } alpar@1673: alpar@2178: ///Turns on/off the absolutematic node width scaling. alpar@2178: alpar@2178: ///Turns on/off the absolutematic node width scaling. alpar@2178: /// alpar@2178: ///\sa nodeScale() alpar@2178: /// alpar@2178: GraphToEps &absoluteNodeSizes(bool b=true) { alpar@2178: _absoluteNodeSizes=b;return *this; alpar@2178: } alpar@2178: alpar@1673: ///Negates the Y coordinates. alpar@1673: alpar@1673: ///Negates the Y coordinates. alpar@1673: /// alpar@1673: ///\todo More docs. alpar@1673: /// alpar@1673: GraphToEps &negateY(bool b=true) { alpar@1673: _negY=b;return *this; alpar@1673: } alpar@1673: alpar@1073: ///Sets a global scale factor for edge widths alpar@1073: alpar@1604: /// Sets a global scale factor for edge widths. alpar@1073: /// alpar@1604: /// If edgeWidths() is not given, this function simply sets the edge alpar@1604: /// widths to \c d. If edgeWidths() is given, but alpar@1604: /// autoEdgeWidthScale() is not, then the edge withs given by alpar@1604: /// edgeWidths() will be multiplied by the value \c d. alpar@1604: /// If both edgeWidths() and autoEdgeWidthScale() are used, then the alpar@1604: /// edge withs will be scaled in such a way that the greatest width will be alpar@1604: /// equal to \c d. alpar@1073: GraphToEps &edgeWidthScale(double d) {_edgeWidthScale=d;return *this;} alpar@1604: ///Turns on/off the automatic edge width scaling. alpar@1604: alpar@1604: ///Turns on/off the automatic edge width scaling. alpar@1604: /// alpar@1604: ///\sa edgeWidthScale() alpar@1604: /// alpar@1604: GraphToEps &autoEdgeWidthScale(bool b=true) { alpar@1604: _autoEdgeWidthScale=b;return *this; alpar@1604: } alpar@2178: ///Turns on/off the absolutematic edge width scaling. alpar@2178: alpar@2178: ///Turns on/off the absolutematic edge width scaling. alpar@2178: /// alpar@2178: ///\sa edgeWidthScale() alpar@2178: /// alpar@2178: GraphToEps &absoluteEdgeWidths(bool b=true) { alpar@2178: _absoluteEdgeWidths=b;return *this; alpar@2178: } alpar@1073: ///Sets a global scale factor for the whole picture alpar@1073: alpar@1073: ///Sets a global scale factor for the whole picture alpar@1073: /// alpar@1604: alpar@1073: GraphToEps &scale(double d) {_scale=d;return *this;} alpar@1073: ///Sets the width of the border around the picture alpar@1073: alpar@1073: ///Sets the width of the border around the picture alpar@1073: /// alpar@1073: GraphToEps &border(double b) {_xBorder=_yBorder=b;return *this;} alpar@1073: ///Sets the width of the border around the picture alpar@1073: alpar@1073: ///Sets the width of the border around the picture alpar@1073: /// alpar@1073: GraphToEps &border(double x, double y) { alpar@1073: _xBorder=x;_yBorder=y;return *this; alpar@1073: } alpar@1073: ///Sets whether to draw arrows alpar@1073: alpar@1073: ///Sets whether to draw arrows alpar@1073: /// alpar@1073: GraphToEps &drawArrows(bool b=true) {_drawArrows=b;return *this;} alpar@1073: ///Sets the length of the arrowheads alpar@1073: alpar@1073: ///Sets the length of the arrowheads alpar@1073: /// alpar@1073: GraphToEps &arrowLength(double d) {_arrowLength*=d;return *this;} alpar@1073: ///Sets the width of the arrowheads alpar@1073: alpar@1073: ///Sets the width of the arrowheads alpar@1073: /// alpar@1073: GraphToEps &arrowWidth(double d) {_arrowWidth*=d;return *this;} alpar@1073: alpar@1103: ///Scales the drawing to fit to A4 page alpar@1103: alpar@1103: ///Scales the drawing to fit to A4 page alpar@1103: /// alpar@1103: GraphToEps &scaleToA4() {_scaleToA4=true;return *this;} alpar@1103: alpar@1073: ///Enables parallel edges alpar@1073: alpar@1073: ///Enables parallel edges alpar@1073: GraphToEps &enableParallel(bool b=true) {_enableParallel=b;return *this;} alpar@1073: alpar@1073: ///Sets the distance alpar@1073: alpar@1073: ///Sets the distance alpar@1073: /// alpar@1073: GraphToEps &parEdgeDist(double d) {_parEdgeDist*=d;return *this;} alpar@1073: alpar@1073: ///Hides the edges alpar@1073: alpar@1073: ///Hides the edges alpar@1073: /// alpar@1073: GraphToEps &hideEdges(bool b=true) {_showEdges=!b;return *this;} alpar@1073: ///Hides the nodes alpar@1073: alpar@1073: ///Hides the nodes alpar@1073: /// alpar@1073: GraphToEps &hideNodes(bool b=true) {_showNodes=!b;return *this;} alpar@1073: alpar@1073: ///Sets the size of the node texts alpar@1073: alpar@1073: ///Sets the size of the node texts alpar@1073: /// alpar@1073: GraphToEps &nodeTextSize(double d) {_nodeTextSize=d;return *this;} alpar@1178: alpar@1178: ///Sets the color of the node texts to be different from the node color alpar@1178: alpar@1178: ///Sets the color of the node texts to be as different from the node color alpar@1178: ///as it is possible alpar@1573: /// alpar@1178: GraphToEps &distantColorNodeTexts() alpar@1178: {_nodeTextColorType=DIST_COL;return *this;} alpar@1178: ///Sets the color of the node texts to be black or white and always visible. alpar@1178: alpar@1178: ///Sets the color of the node texts to be black or white according to alpar@1178: ///which is more alpar@1178: ///different from the node color alpar@1178: /// alpar@1178: GraphToEps &distantBWNodeTexts() alpar@1178: {_nodeTextColorType=DIST_BW;return *this;} alpar@1178: alpar@1085: ///Gives a preamble block for node Postscript block. alpar@1085: alpar@1085: ///Gives a preamble block for node Postscript block. alpar@1085: /// alpar@1085: ///\sa nodePsTexts() alpar@1085: GraphToEps & nodePsTextsPreamble(const char *str) { alpar@1234: _nodePsTextsPreamble=str ;return *this; alpar@1085: } alpar@1073: ///Sets whether the the graph is undirected alpar@1073: alpar@1073: ///Sets whether the the graph is undirected alpar@1073: /// deba@1910: GraphToEps &undirected(bool b=true) {_undirected=b;return *this;} deba@1910: alpar@1073: ///Sets whether the the graph is directed alpar@1073: alpar@1073: ///Sets whether the the graph is directed. alpar@1073: ///Use it to show the undirected edges as a pair of directed ones. deba@1910: GraphToEps &bidir(bool b=true) {_undirected=!b;return *this;} alpar@1086: alpar@1108: ///Sets the title. alpar@1108: alpar@1108: ///Sets the title of the generated image, alpar@1108: ///namely it inserts a %%Title: DSC field to the header of alpar@1108: ///the EPS file. alpar@1108: GraphToEps &title(const std::string &t) {_title=t;return *this;} alpar@1108: ///Sets the copyright statement. alpar@1108: alpar@1108: ///Sets the copyright statement of the generated image, alpar@1108: ///namely it inserts a %%Copyright: DSC field to the header of alpar@1108: ///the EPS file. alpar@1108: ///\todo Multiline copyright notice could be supported. alpar@1108: GraphToEps ©right(const std::string &t) {_copyright=t;return *this;} alpar@1108: alpar@1086: protected: alpar@2207: bool isInsideNode(dim2::Point p, double r,int t) alpar@1086: { alpar@1086: switch(t) { alpar@1086: case CIRCLE: alpar@1907: case MALE: alpar@1907: case FEMALE: alpar@1086: return p.normSquare()<=r*r; alpar@1086: case SQUARE: alpar@1086: return p.x<=r&&p.x>=-r&&p.y<=r&&p.y>=-r; alpar@1088: case DIAMOND: alpar@1088: return p.x+p.y<=r && p.x-p.y<=r && -p.x+p.y<=r && -p.x-p.y<=r; alpar@1086: } alpar@1086: return false; alpar@1086: } alpar@1086: alpar@1086: public: alpar@1091: ~GraphToEps() { } alpar@1091: alpar@1091: ///Draws the graph. alpar@1091: alpar@1091: ///Like other functions using alpar@1091: ///\ref named-templ-func-param "named template parameters", alpar@1091: ///this function calles the algorithm itself, i.e. in this case alpar@1091: ///it draws the graph. alpar@1091: void run() { alpar@2178: ///\todo better 'epsilon' would be nice here. alpar@2178: const double EPSILON=1e-9; alpar@1073: if(dontPrint) return; alpar@1073: alpar@1673: _NegY mycoords(_coords,_negY); alpar@1673: alpar@1073: os << "%!PS-Adobe-2.0 EPSF-2.0\n"; alpar@1108: if(_title.size()>0) os << "%%Title: " << _title << '\n'; alpar@1108: if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n'; alpar@1107: // << "%%Copyright: XXXX\n" alpar@1575: os << "%%Creator: LEMON, graphToEps()\n"; alpar@1108: alpar@1108: { alpar@1108: char cbuf[50]; alpar@1108: timeval tv; alpar@1108: gettimeofday(&tv, 0); alpar@1108: ctime_r(&tv.tv_sec,cbuf); alpar@1108: os << "%%CreationDate: " << cbuf; alpar@1108: } alpar@1604: alpar@1604: if (_autoEdgeWidthScale) { alpar@1604: double max_w=0; alpar@1604: for(EdgeIt e(g);e!=INVALID;++e) alpar@1604: max_w=std::max(double(_edgeWidths[e]),max_w); alpar@1604: ///\todo better 'epsilon' would be nice here. alpar@2178: if(max_w>EPSILON) { alpar@1604: _edgeWidthScale/=max_w; alpar@1604: } alpar@1604: } alpar@1604: alpar@1604: if (_autoNodeScale) { alpar@1604: double max_s=0; alpar@1604: for(NodeIt n(g);n!=INVALID;++n) alpar@1604: max_s=std::max(double(_nodeSizes[n]),max_s); alpar@1604: ///\todo better 'epsilon' would be nice here. alpar@2178: if(max_s>EPSILON) { alpar@1604: _nodeScale/=max_s; alpar@1604: } alpar@1604: } alpar@1604: alpar@2178: double diag_len = 1; alpar@2178: if(!(_absoluteNodeSizes&&_absoluteEdgeWidths)) { alpar@2207: dim2::BoundingBox bb; alpar@2178: for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]); alpar@2178: if (bb.empty()) { alpar@2207: bb = dim2::BoundingBox(dim2::Point(0,0)); alpar@2178: } alpar@2178: diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare()); alpar@2178: if(diag_len bb; alpar@1073: for(NodeIt n(g);n!=INVALID;++n) { alpar@1073: double ns=_nodeSizes[n]*_nodeScale; alpar@2207: dim2::Point p(ns,ns); alpar@1907: switch(_nodeShapes[n]) { alpar@1907: case CIRCLE: alpar@1907: case SQUARE: alpar@1907: case DIAMOND: alpar@1907: bb.add(p+mycoords[n]); alpar@1907: bb.add(-p+mycoords[n]); alpar@1907: break; alpar@1907: case MALE: alpar@1907: bb.add(-p+mycoords[n]); alpar@2207: bb.add(dim2::Point(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]); alpar@1907: break; alpar@1907: case FEMALE: alpar@1907: bb.add(p+mycoords[n]); alpar@2207: bb.add(dim2::Point(-ns,-3.01*ns)+mycoords[n]); alpar@1907: break; alpar@1907: } deba@1539: } deba@1539: if (bb.empty()) { alpar@2207: bb = dim2::BoundingBox(dim2::Point(0,0)); deba@1539: } alpar@1604: alpar@1108: if(_scaleToA4) alpar@1108: os <<"%%BoundingBox: 0 0 596 842\n%%DocumentPaperSizes: a4\n"; alpar@1930: else { alpar@1930: //Rescale so that BoundingBox won't be neither to big nor too small. alpar@1930: while(bb.height()*_scale>1000||bb.width()*_scale>1000) _scale/=10; alpar@1930: while(bb.height()*_scale<100||bb.width()*_scale<100) _scale*=10; alpar@1930: alpar@1930: os << "%%BoundingBox: " alpar@1930: << int(floor(bb.left() * _scale - _xBorder)) << ' ' alpar@1930: << int(floor(bb.bottom() * _scale - _yBorder)) << ' ' alpar@1930: << int(ceil(bb.right() * _scale + _xBorder)) << ' ' alpar@1930: << int(ceil(bb.top() * _scale + _yBorder)) << '\n'; alpar@1930: } alpar@1108: alpar@1107: os << "%%EndComments\n"; alpar@1107: alpar@1073: //x1 y1 x2 y2 x3 y3 cr cg cb w alpar@1073: os << "/lb { setlinewidth setrgbcolor newpath moveto\n" alpar@1073: << " 4 2 roll 1 index 1 index curveto stroke } bind def\n"; alpar@1073: os << "/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def\n"; alpar@1086: //x y r alpar@1073: os << "/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def\n"; alpar@1086: //x y r alpar@1086: os << "/sq { newpath 2 index 1 index add 2 index 2 index add moveto\n" alpar@1086: << " 2 index 1 index sub 2 index 2 index add lineto\n" alpar@1086: << " 2 index 1 index sub 2 index 2 index sub lineto\n" alpar@1086: << " 2 index 1 index add 2 index 2 index sub lineto\n" alpar@1086: << " closepath pop pop pop} bind def\n"; alpar@1088: //x y r alpar@1088: os << "/di { newpath 2 index 1 index add 2 index moveto\n" alpar@1088: << " 2 index 2 index 2 index add lineto\n" alpar@1088: << " 2 index 1 index sub 2 index lineto\n" alpar@1088: << " 2 index 2 index 2 index sub lineto\n" alpar@1088: << " closepath pop pop pop} bind def\n"; alpar@1073: // x y r cr cg cb alpar@1089: os << "/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill\n" alpar@1089: << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" alpar@1073: << " } bind def\n"; alpar@1089: os << "/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill\n" alpar@1089: << " setrgbcolor " << 1+_nodeBorderQuotient << " div sq fill\n" alpar@1086: << " } bind def\n"; alpar@1089: os << "/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill\n" alpar@1089: << " setrgbcolor " << 1+_nodeBorderQuotient << " div di fill\n" alpar@1088: << " } bind def\n"; alpar@1907: os << "/nfemale { 0 0 0 setrgbcolor 3 index " alpar@1907: << _nodeBorderQuotient/(1+_nodeBorderQuotient) alpar@1907: << " 1.5 mul mul setlinewidth\n" alpar@1907: << " newpath 5 index 5 index moveto " alpar@1907: << "5 index 5 index 5 index 3.01 mul sub\n" alpar@1907: << " lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto\n" alpar@1907: << " 5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke\n" alpar@1907: << " 5 index 5 index 5 index c fill\n" alpar@1907: << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" alpar@1907: << " } bind def\n"; alpar@1907: os << "/nmale {\n" alpar@1907: << " 0 0 0 setrgbcolor 3 index " alpar@1907: << _nodeBorderQuotient/(1+_nodeBorderQuotient) alpar@1907: <<" 1.5 mul mul setlinewidth\n" alpar@1907: << " newpath 5 index 5 index moveto\n" alpar@1907: << " 5 index 4 index 1 mul 1.5 mul add\n" alpar@1907: << " 5 index 5 index 3 sqrt 1.5 mul mul add\n" alpar@1907: << " 1 index 1 index lineto\n" alpar@1907: << " 1 index 1 index 7 index sub moveto\n" alpar@1907: << " 1 index 1 index lineto\n" alpar@1907: << " exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto\n" alpar@1907: << " stroke\n" alpar@1907: << " 5 index 5 index 5 index c fill\n" alpar@1907: << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" alpar@1907: << " } bind def\n"; alpar@1907: alpar@1907: alpar@1073: os << "/arrl " << _arrowLength << " def\n"; alpar@1073: os << "/arrw " << _arrowWidth << " def\n"; alpar@1073: // l dx_norm dy_norm alpar@1073: os << "/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def\n"; alpar@1073: //len w dx_norm dy_norm x1 y1 cr cg cb alpar@1073: os << "/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def\n" alpar@1073: << " /w exch def /len exch def\n" alpar@1073: // << " 0.1 setlinewidth x1 y1 moveto dx len mul dy len mul rlineto stroke" alpar@1073: << " newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto\n" alpar@1073: << " len w sub arrl sub dx dy lrl\n" alpar@1073: << " arrw dy dx neg lrl\n" alpar@1073: << " dx arrl w add mul dy w 2 div arrw add mul sub\n" alpar@1073: << " dy arrl w add mul dx w 2 div arrw add mul add rlineto\n" alpar@1073: << " dx arrl w add mul neg dy w 2 div arrw add mul sub\n" alpar@1073: << " dy arrl w add mul neg dx w 2 div arrw add mul add rlineto\n" alpar@1073: << " arrw dy dx neg lrl\n" alpar@1073: << " len w sub arrl sub neg dx dy lrl\n" alpar@1073: << " closepath fill } bind def\n"; alpar@1073: os << "/cshow { 2 index 2 index moveto dup stringwidth pop\n" alpar@1073: << " neg 2 div fosi .35 mul neg rmoveto show pop pop} def\n"; alpar@1073: alpar@1073: os << "\ngsave\n"; alpar@1103: if(_scaleToA4) alpar@1103: if(bb.height()>bb.width()) { deba@1470: double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.height(), alpar@1103: (A4WIDTH-2*A4BORDER)/bb.width()); alpar@1103: os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' ' alpar@2207: << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER alpar@2207: << " translate\n" alpar@1103: << sc << " dup scale\n" alpar@1103: << -bb.left() << ' ' << -bb.bottom() << " translate\n"; alpar@1103: } alpar@1103: else { alpar@1103: //\todo Verify centering deba@1470: double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(), alpar@1103: (A4WIDTH-2*A4BORDER)/bb.height()); alpar@1103: os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' ' alpar@2207: << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER alpar@2207: << " translate\n" alpar@1103: << sc << " dup scale\n90 rotate\n" alpar@1103: << -bb.left() << ' ' << -bb.top() << " translate\n"; alpar@1103: } alpar@1103: else if(_scale!=1.0) os << _scale << " dup scale\n"; alpar@1073: alpar@1085: if(_showEdges) { alpar@1085: os << "%Edges:\ngsave\n"; alpar@1073: if(_enableParallel) { alpar@1073: std::vector el; alpar@1073: for(EdgeIt e(g);e!=INVALID;++e) alpar@1976: if((!_undirected||g.source(e)0 alpar@1976: &&g.source(e)!=g.target(e)) alpar@1178: el.push_back(e); alpar@1642: std::sort(el.begin(),el.end(),edgeLess(g)); alpar@1073: alpar@1073: typename std::vector::iterator j; alpar@1073: for(typename std::vector::iterator i=el.begin();i!=el.end();i=j) { alpar@1073: for(j=i+1;j!=el.end()&&isParallel(*i,*j);++j) ; alpar@1073: alpar@1073: double sw=0; alpar@1073: for(typename std::vector::iterator e=i;e!=j;++e) alpar@1073: sw+=_edgeWidths[*e]*_edgeWidthScale+_parEdgeDist; alpar@1073: sw-=_parEdgeDist; alpar@1073: sw/=-2.0; alpar@2207: dim2::Point alpar@2207: dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]); deba@1417: double l=std::sqrt(dvec.normSquare()); alpar@1360: ///\todo better 'epsilon' would be nice here. alpar@2207: dim2::Point d(dvec/std::max(l,EPSILON)); alpar@2207: dim2::Point m; alpar@2207: // m=dim2::Point(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0; alpar@1085: alpar@2207: // m=dim2::Point(mycoords[g.source(*i)])+ alpar@1085: // dvec*(double(_nodeSizes[g.source(*i)])/ alpar@1085: // (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)])); alpar@1085: alpar@2207: m=dim2::Point(mycoords[g.source(*i)])+ alpar@1085: d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0; alpar@1085: alpar@1073: for(typename std::vector::iterator e=i;e!=j;++e) { alpar@1073: sw+=_edgeWidths[*e]*_edgeWidthScale/2.0; alpar@2207: dim2::Point mm=m+rot90(d)*sw/.75; alpar@1073: if(_drawArrows) { alpar@1086: int node_shape; alpar@2207: dim2::Point s=mycoords[g.source(*e)]; alpar@2207: dim2::Point t=mycoords[g.target(*e)]; alpar@1073: double rn=_nodeSizes[g.target(*e)]*_nodeScale; alpar@1086: node_shape=_nodeShapes[g.target(*e)]; alpar@2207: dim2::Bezier3 bez(s,mm,mm,t); alpar@1073: double t1=0,t2=1; alpar@1087: for(int i=0;i apoint=bez((t1+t2)/2); alpar@1086: rn = _arrowLength+_edgeWidths[*e]*_edgeWidthScale; alpar@1073: rn*=rn; alpar@1086: t2=(t1+t2)/2;t1=0; alpar@1087: for(int i=0;irn) t1=(t1+t2)/2; alpar@1073: else t2=(t1+t2)/2; alpar@2207: dim2::Point linend=bez((t1+t2)/2); alpar@1073: bez=bez.before((t1+t2)/2); alpar@1086: // rn=_nodeSizes[g.source(*e)]*_nodeScale; alpar@1086: // node_shape=_nodeShapes[g.source(*e)]; alpar@1086: // t1=0;t2=1; alpar@1087: // for(int i=0;i dd(rot90(linend-apoint)); alpar@1089: dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/ deba@1417: std::sqrt(dd.normSquare()); alpar@1073: os << "newpath " << psOut(apoint) << " moveto " alpar@1073: << psOut(linend+dd) << " lineto " alpar@1073: << psOut(linend-dd) << " lineto closepath fill\n"; alpar@1073: } alpar@1073: else { alpar@1673: os << mycoords[g.source(*e)].x << ' ' alpar@1673: << mycoords[g.source(*e)].y << ' ' alpar@1085: << mm.x << ' ' << mm.y << ' ' alpar@1673: << mycoords[g.target(*e)].x << ' ' alpar@1673: << mycoords[g.target(*e)].y << ' ' alpar@1575: << _edgeColors[*e].red() << ' ' alpar@1575: << _edgeColors[*e].green() << ' ' alpar@1575: << _edgeColors[*e].blue() << ' ' alpar@1073: << _edgeWidths[*e]*_edgeWidthScale << " lb\n"; alpar@1073: } alpar@1073: sw+=_edgeWidths[*e]*_edgeWidthScale/2.0+_parEdgeDist; alpar@1073: } alpar@1073: } alpar@1073: } alpar@1073: else for(EdgeIt e(g);e!=INVALID;++e) alpar@1976: if((!_undirected||g.source(e)0 alpar@1976: &&g.source(e)!=g.target(e)) alpar@1073: if(_drawArrows) { alpar@2207: dim2::Point d(mycoords[g.target(e)]-mycoords[g.source(e)]); alpar@1087: double rn=_nodeSizes[g.target(e)]*_nodeScale; alpar@1087: int node_shape=_nodeShapes[g.target(e)]; alpar@1087: double t1=0,t2=1; alpar@1087: for(int i=0;i alpar@1494: const int GraphToEps::INTERPOL_PREC = 20; alpar@1494: template alpar@1494: const double GraphToEps::A4HEIGHT = 841.8897637795276; alpar@1494: template alpar@1494: const double GraphToEps::A4WIDTH = 595.275590551181; alpar@1494: template alpar@1494: const double GraphToEps::A4BORDER = 15; alpar@1494: alpar@1073: alpar@1073: ///Generates an EPS file from a graph alpar@1073: deba@2084: ///\ingroup eps_io alpar@1073: ///Generates an EPS file from a graph. alpar@1073: ///\param g is a reference to the graph to be printed alpar@1073: ///\param os is a reference to the output stream. alpar@1073: ///By default it is std::cout alpar@1073: /// alpar@1091: ///This function also has a lot of alpar@1091: ///\ref named-templ-func-param "named parameters", alpar@1073: ///they are declared as the members of class \ref GraphToEps. The following alpar@1073: ///example shows how to use these parameters. alpar@1073: ///\code alpar@1178: /// graphToEps(g,os).scale(10).coords(coords) alpar@1073: /// .nodeScale(2).nodeSizes(sizes) alpar@1091: /// .edgeWidthScale(.4).run(); alpar@1073: ///\endcode alpar@1091: ///\warning Don't forget to put the \ref GraphToEps::run() "run()" alpar@1091: ///to the end of the parameter list. alpar@1073: ///\sa GraphToEps alpar@1573: ///\sa graphToEps(G &g, const char *file_name) alpar@1073: template alpar@1073: GraphToEps > alpar@1073: graphToEps(G &g, std::ostream& os=std::cout) alpar@1073: { alpar@1073: return alpar@1073: GraphToEps >(DefaultGraphToEpsTraits(g,os)); alpar@1073: } alpar@1073: alpar@1073: ///Generates an EPS file from a graph alpar@1073: deba@2084: ///\ingroup eps_io alpar@1073: ///This function does the same as alpar@1073: ///\ref graphToEps(G &g,std::ostream& os) alpar@1073: ///but it writes its output into the file \c file_name alpar@1073: ///instead of a stream. alpar@1073: ///\sa graphToEps(G &g, std::ostream& os) alpar@1073: template alpar@1073: GraphToEps > alpar@1107: graphToEps(G &g,const char *file_name) alpar@1073: { alpar@1073: return GraphToEps > alpar@1073: (DefaultGraphToEpsTraits(g,*new std::ofstream(file_name),true)); alpar@1073: } alpar@1073: deba@1743: ///Generates an EPS file from a graph deba@1743: deba@2084: ///\ingroup eps_io deba@1743: ///This function does the same as deba@1743: ///\ref graphToEps(G &g,std::ostream& os) deba@1743: ///but it writes its output into the file \c file_name deba@1743: ///instead of a stream. deba@1743: ///\sa graphToEps(G &g, std::ostream& os) deba@1743: template deba@1743: GraphToEps > deba@1743: graphToEps(G &g,const std::string& file_name) deba@1743: { deba@1743: return GraphToEps > deba@1743: (DefaultGraphToEpsTraits(g,*new std::ofstream(file_name.c_str()),true)); deba@1743: } deba@1743: alpar@1073: } //END OF NAMESPACE LEMON alpar@1073: alpar@1073: #endif // LEMON_GRAPH_TO_EPS_H