Index: src/lemon/graph_to_eps.h
===================================================================
--- src/lemon/graph_to_eps.h	(revision 1073)
+++ src/lemon/graph_to_eps.h	(revision 1085)
@@ -106,4 +106,8 @@
   double _nodeTextSize;
 
+  bool _showNodePsText;
+  ConstMap<typename Graph::Node,bool > _nodePsTexts;  
+  char *_nodePsTextsPreamble;
+  
   bool _undir;
   bool _pleaseRemoveOsStream;
@@ -129,4 +133,5 @@
     _enableParallel(false), _parEdgeDist(1),
     _showNodeText(false), _nodeTexts(false), _nodeTextSize(1),
+    _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0),
     _undir(false),
     _pleaseRemoveOsStream(_pros) {}
@@ -225,5 +230,31 @@
     return GraphToEps<NodeTextsTraits<X> >(NodeTextsTraits<X>(*this,x));
   }
-   template<class X> struct EdgeWidthsTraits : public T {
+  template<class X> struct NodePsTextsTraits : public T {
+    const X &_nodePsTexts;
+    NodePsTextsTraits(const T &t,const X &x) : T(t), _nodePsTexts(x) {}
+  };
+  ///Inserts a PostScript block to the nodes
+
+  ///With this command it is possible to insert a verbatim PostScript
+  ///block to the nodes.
+  ///The PS current point will be moved to the centre of the node before
+  ///the PostScript block inserted.
+  ///
+  ///Before and after the block a newline character is inserted to you
+  ///don't have to bother with the separators.
+  ///
+  ///\param x must be a node map with type that can be pushed to a standard
+  ///ostream.
+  ///
+  ///\sa nodePsTextsPreamble()
+  ///\todo Offer the choise not to move to the centre but pass the coordinates
+  ///to the Postscript block inserted.
+  template<class X> GraphToEps<NodePsTextsTraits<X> > nodePsTexts(const X &x)
+  {
+    dontPrint=true;
+    _showNodePsText=true;
+    return GraphToEps<NodePsTextsTraits<X> >(NodePsTextsTraits<X>(*this,x));
+  }
+  template<class X> struct EdgeWidthsTraits : public T {
     const X &_edgeWidths;
     EdgeWidthsTraits(const T &t,const X &x) : T(t), _edgeWidths(x) {}
@@ -338,4 +369,12 @@
   ///
   GraphToEps<T> &nodeTextSize(double d) {_nodeTextSize=d;return *this;}
+  ///Gives a preamble block for node Postscript block.
+  
+  ///Gives a preamble block for node Postscript block.
+  ///
+  ///\sa nodePsTexts()
+  GraphToEps<T> & nodePsTextsPreamble(const char *str) {
+    _nodePsTextsPreamble=s ;return *this;
+  }
   ///Sets whether the the graph is undirected
 
@@ -402,7 +441,6 @@
     if(_scale!=1.0) os << _scale << " dup scale\n";
     
-    os << "%Edges:\ngsave\n";
-    
-    if(_showEdges)
+    if(_showEdges) {
+      os << "%Edges:\ngsave\n";      
       if(_enableParallel) {
 	std::vector<Edge> el;
@@ -420,12 +458,20 @@
 	  sw-=_parEdgeDist;
 	  sw/=-2.0;
-	  xy<double> d(_coords[g.target(*i)]-_coords[g.source(*i)]);
-	  double l=sqrt(d.normSquare());
-	  d/=l;
-	  
+	  xy<double> dvec(_coords[g.target(*i)]-_coords[g.source(*i)]);
+	  double l=sqrt(dvec.normSquare());
+	  xy<double> d(dvec/l);
+ 	  xy<double> m;
+// 	  m=xy<double>(_coords[g.target(*i)]+_coords[g.source(*i)])/2.0;
+
+//  	  m=xy<double>(_coords[g.source(*i)])+
+// 	    dvec*(double(_nodeSizes[g.source(*i)])/
+// 	       (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)]));
+
+ 	  m=xy<double>(_coords[g.source(*i)])+
+	    d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0;
+
 	  for(typename std::vector<Edge>::iterator e=i;e!=j;++e) {
 	    sw+=_edgeWidths[*e]*_edgeWidthScale/2.0;
-	    xy<double> m(_coords[g.target(*e)]+_coords[g.source(*e)]);
-	    m=m/2.0+rot(d)*sw/.75;
+	    xy<double> mm=m+rot(d)*sw/.75;
 	    if(_drawArrows) {
 	      const int INERPOL_PREC=20;
@@ -434,5 +480,5 @@
 	      double rn=_nodeSizes[g.target(*e)]*_nodeScale;
 	      rn*=rn;
-	      Bezier3 bez(s,m,m,t);
+	      Bezier3 bez(s,mm,mm,t);
 	      double t1=0,t2=1;
 	      for(int i=0;i<INERPOL_PREC;++i)
@@ -473,5 +519,5 @@
 	      os << _coords[g.source(*e)].x << ' '
 		 << _coords[g.source(*e)].y << ' '
-		 << m.x << ' ' << m.y << ' '
+		 << mm.x << ' ' << mm.y << ' '
 		 << _coords[g.target(*e)].x << ' '
 		 << _coords[g.target(*e)].y << ' '
@@ -510,6 +556,8 @@
 		  << _edgeColors[e].getB() << ' '
 		  << _edgeWidths[e]*_edgeWidthScale << " l\n";
-    os << "grestore\n%Nodes:\ngsave\n";
-    if(_showNodes)
+      os << "grestore\n";
+    }
+    if(_showNodes) {
+      os << "%Nodes:\ngsave\n";
       for(NodeIt n(g);n!=INVALID;++n)
 	os << _coords[n].x << ' ' << _coords[n].y << ' '
@@ -517,7 +565,9 @@
 	   << _nodeColors[n].getR() << ' '
 	   << _nodeColors[n].getG() << ' '
-	   << _nodeColors[n].getB() << " n\n"; 
+	   << _nodeColors[n].getB() << " n\n";
+      os << "grestore\n";
+    }
     if(_showNodeText) {
-      os << "grestore\n%Node texts:\ngsave\n";
+      os << "%Node texts:\ngsave\n";
       os << "/fosi " << _nodeTextSize << " def\n";
       os << "(Helvetica) findfont fosi scalefont setfont\n";
@@ -526,6 +576,15 @@
 	os << _coords[n].x << ' ' << _coords[n].y
 	   << " (" << _nodeTexts[n] << ") cshow\n";
+      os << "grestore\n";
     }
-    os << "grestore\ngrestore\n";
+    if(_showNodePsText) {
+      os << "%Node PS blocks:\ngsave\n";
+      for(NodeIt n(g);n!=INVALID;++n)
+	os << _coords[n].x << ' ' << _coords[n].y
+	   << " moveto\n" << _nodePsTexts[n] << "\n";
+      os << "grestore\n";
+    }
+    
+    os << "grestore\n";
 
     //CleanUp:
@@ -577,20 +636,4 @@
 }
 
-//Generates an EPS file from a graph.
-//\param g is a reference to the graph to be printed
-//\param file_name is the output file_name.
-//
-//This function also has a lot of \ref named-templ-param "named parameters",
-//they are declared as the members of class \ref GraphToEps. The following
-//example shows how to use these parameters.
-//\code
-// graphToEps(g).scale(10).coords(coords)
-//              .nodeScale(2).nodeSizes(sizes)
-//              .edgeWidthScale(.4);
-//\endcode
-//\sa GraphToEps
-//\todo Avoid duplicated documentation
-//\bug Exception handling is missing? (Or we can just ignore it?)
-
 } //END OF NAMESPACE LEMON
 
