|
Boost Users : |
From: Vladimir Prus (yg-boost-users_at_[hidden])
Date: 2003-03-28 01:16:28
Jeff Holle wrote:
> I would like to write a "generic" routine that prints the named vertex
> and edges properties.
Eeh... you must mean (name,value) pairs from graphvis graph?
> I can see in this code sibit (from graphviz.cpp) that the info that I
> want is present:
>
>> vertex_label(const Vertex& u, const GraphvizDigraph& g) {
>> boost::property_map<GraphvizDigraph,
>> boost::vertex_attribute_t>::const_type
>> va = boost::get(boost::vertex_attribute, g);
>> return (*(va[u].find("label"))).second;
>> }
>
> It appears that va is a map<Vertex, map<string, "property value"> >
Yep.
> How would I write code that prints the names of the properites of a
> given vertex? (It would involve iterating over the map whose find
> method is used in the above code segment).
In the code above, "va[u]" has the type std::map<std::string, std::string>.
You can just iterate over all elements of that map, printing keys:
boost::property_map<GraphvizDigraph,
boost::vertex_attribute_t>::const_type
va = boost::get(boost::vertex_attribute, g);
const map<string, string>& m = va[u];
for (const map<string, string>::const_iterator i = m.begin();
i != m.end();
++i)
std::cout << i->first << "\n";
Is it what you're after?
- Volodya
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