
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
boost::write_graphviz(std::ostream&, const Graph&, VertexPropertiesWriter,
EdgePropertiesWriter, GraphPropertiesWriter, VertexID) [with Graph =
boost::adjacency_list

On 4/19/06, Fred Labrosse
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)
- From the dot format, this should be the name of the vertex in the dot file. So this seems to relate to the class used as a property. My second question is then: If this is the case, why then do we need the property writer since we apparently also need the operator<< that could do exactly the same thing? (And isn't a ' ' (space) missing between the vertex name and whatever the property writer writes (or should that be included in it, which is not mentioned by the documentation)? That was 3 questions then ;-)
I don't understand your second question, neither question 3... I think it relates to your first question.
Thanks in advance for any replies.
Cheers,
Regards, -- Johan

On Wednesday 19 Apr 2006 16:46, Johan Oudinet wrote:
On 4/19/06, Fred Labrosse
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

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;
On 4/19/06, Fred Labrosse
unsigned short number; };
[snip] Should that be something like:
default_writer dw; default_writer gw; write_graphviz(of, theMap, pw, dw, gw, get(&place.getNumber(), theMap));
No, you're get parameter is wrong, try this : write_graphviz (of, theMap, pw, dw, gw, get (&place::number, theMap));
??? This was actually taken from an example on bundled properties.
Cheers,
-- Johan

On Wednesday 19 Apr 2006 21:26, Johan Oudinet wrote:
Should that be something like:
default_writer dw; default_writer gw; write_graphviz(of, theMap, pw, dw, gw, get(&place.getNumber(), theMap));
No, you're get parameter is wrong, try this : write_graphviz (of, theMap, pw, dw, gw, get (&place::number, theMap));
Yes, I gathered that last night when I tried it. This also means that I need to have public attributes instead of get functions... :-( Thanks anyway. Fred
participants (2)
-
Fred Labrosse
-
Johan Oudinet