Boost logo

Boost Users :

From: Fred Labrosse (ffl_at_[hidden])
Date: 2006-04-19 12:26:07


On Wednesday 19 Apr 2006 16:46, Johan Oudinet wrote:
> On 4/19/06, Fred Labrosse <ffl_at_[hidden]> wrote:
> > All,
> >
> > First, I'm very new to boost and BGL, so please forgive me if this is
> > trivial.
> >
> > I've created a graph (adjacency_list) using bundled properties and am now
> > trying to write it as a dot file. I've written my property writer, but
> > when I compile, I get several of:
> >
> > /usr/include/boost/graph/graphviz.hpp: In function `void
> > [snip]
> > Not being very good at deciphering all that, I'm not sure what is
> > happening. I do understand that it's missing an extraction operator but
> > I'm not sure on what. The actual line in graphviz.hpp is:
> >
> > out << get(vertex_id, *i);
> >
> > Two questions:
> >
> > - Could somebody tell me exactly what that get returns?
>
> get returns the value from vertex_descriptor *i in the property map
> vertex_id
>
> In your code, your adjacency_list uses listS so this vertex_id
> property is not define! That's the problem.
>
> When you call write_graphviz, specify a property map to get an index
> from a vertex_descriptor (follow the example with write_graphviz and
> dynamic properties)

Many thanks for replying. However, I'm not sure how to do that. Here are the
relevant bits of my code (sorry for the length):

class place
{
public:
   place(const imalib::imageD3* anAppearance, const std::string& aName,
         unsigned short aNumber)
      : appearance(anAppearance),
      name(aName),
      number(aNumber)
   {
   }
   ~place();
   const imalib::imageD3* getAppearance() const
   {
      return(appearance);
   }
   const std::string& getName() const
   {
      return(name);
   }
   unsigned short getNumber() const
   {
      return(number);
   }
private:
   const imalib::imageD3* appearance;
   std::string name;
   unsigned short number;
};

class placeWriter
{
public:
   placeWriter(const mapType& g)
      : g(g)
   {}
   void operator()(std::ostream& out,
                   const mapType::vertex_descriptor& v) const
   {
      static imalib::imageRGB anImage;

      out << "[label=\"" << g[v].getNumber() << "\",shapefile=\""
         << g[v].getName() << "\"];\n";

      g[v].getAppearance()->toRGB(&anImage);
      anImage.write(g[v].getName());
   }
private:
   const mapType& g;
};

typedef boost::adjacency_list<boost::listS, boost::listS,
   boost::undirectedS, place, link> mapType;

mapType theMap;

std::ofstream of(filename.c_str());
placeWriter pw(theMap);
write_graphviz(of, theMap, pw);

Should that be something like:

default_writer dw;
default_writer gw;
write_graphviz(of, theMap, pw, dw, gw, get(&place.getNumber(), theMap));

???
This was actually taken from an example on bundled properties.

Cheers,

Fred


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net