Note that there are some explanatory texts on larger screens.

plurals
  1. POBoost Graph Library: Bundled Properties and iterating across edges
    primarykey
    data
    text
    <p>Just trying to get my head around the Boost Graph Library and I have a few questions. I'm writing some code which is a wrapper class around a BGL graph. The idea is that I can manipulate the graph however I want, then call a wrapper method to output the graph in GEXF (XML) format.</p> <p>My code is something like this:</p> <pre><code>struct Vertex { std::string label; ... }; struct Edge { std::string label; double weight; ... }; typedef boost::adjacency_list&lt;boost::vecS, boost::vecS, boost::directedS, Vertex, Edge&gt; GraphType; template &lt;typename Graph&gt; class GEXF { private: Graph graph; ... }; template &lt;typename Graph&gt; void GEXF&lt;Graph&gt;::buildXML() { ... // output the edges property_map&lt;adjacency_list&lt;&gt;, edge_index_t&gt;::type edge_id = get(edge_index, graph); GraphType::edge_iterator e, e_end; for(tie(e, e_end) = edges(graph); e != e_end; ++e) { xmlpp::Element *edge = ePtr-&gt;add_child("edge"); // next line gives an error, property not found edge-&gt;set_attribute("id", tostring&lt;size_t&gt;(get(edge_id, *e))); edge-&gt;set_attribute("source", tostring&lt;size_t&gt;(source(*e, graph))); edge-&gt;set_attribute("target", tostring&lt;size_t&gt;(target(*e, graph))); } } ... // instantiate in main(): GEXF&lt;GraphType&gt; gexf; </code></pre> <p>Here are my questions:</p> <ol> <li><p>When I use bundled properties, I can access vertex_index, but I can't access edge_index. How do I get access to edge indices?</p></li> <li><p>In the code above, I wanted to keep the GEXF class generic, but I ran into a problem when I tried to declare <code>Graph::edge_iterator e, e_end;</code> The above code works, but it's using a concrete type. How should I declare the edge_iterator generically?</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload