Well, it turns out that I made a small mistake:
 
//Class template of a vertex/edge property writer
template < typename Graph >
class property_writer {
public:
  property_writer(Graph _g) : g(_g) {}
                      
  template <typename Vertex_or_Edge>
  void operator()(std::ostream& out, const Vertex_or_Edge& v) {
    out << "[label=\""
        << g[v].toString()
        << "\"]";
  }
private:
  Graph& g;
};
Changing the argument of property_writer from "Graph _g" to be "Graph& _g" solves this.
 
I started the property writer from the example in BGL documenation: boost_1_32_0/libs/graph/doc/write-graphviz.html, so I suggest changing this doc to be more efficient.


From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Welson Sun
Sent: Wednesday, February 16, 2005 1:43 PM
To: boost-users@lists.boost.org
Subject: [Boost-users] Program runs OK in Cygwin,but got "Segment Fault" in Linux

Hi,
 
The program is really simple, it creates a graph and output to a .dot file using the graphviz library in the BGL. It runs well in Cygwin, but in Linux, it got a segment fault when outputing the vertex id.
 
Can you C++ gurus see what is going on? Thanks!
 
 
Welson