Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Below is code I used to attach some properties to vertices, edges, and graphs. Note that vertex name and graph name are predefined properties (see boost/properties.hpp for a complete list) so that <code>vertex_name_t</code> and <code>graph_name_t</code> are already defined. However, <code>vertex_location_t</code>, <code>edge_length_t</code>, and <code>graph_notes_t</code> are my own properties and hence need definition. I cobbled together this code from various examples and documentation, and I'm not sure exactly what <code>BOOST_INSTALL_PROPERTY</code> does, but the code seems to work fine.</p> <pre><code>// Define custom properties enum vertex_location_t { vertex_location }; enum edge_length_t { edge_length }; enum graph_notes_t { graph_notes }; namespace boost { BOOST_INSTALL_PROPERTY(vertex, location); BOOST_INSTALL_PROPERTY(edge, length ); BOOST_INSTALL_PROPERTY(graph, notes ); } // Define vertex properties: vertex name and location typedef property&lt;vertex_name_t, string, property&lt;vertex_location_t, Point3&gt; &gt; VertexProperties; // Define edge properties: length typedef property&lt;edge_length_t, double&gt; EdgeProperties; // Define graph properties: graph name and notes typedef property&lt;graph_name_t, string, property&lt;graph_notes_t, string&gt; &gt; GraphProperties; // Define a graph type typedef adjacency_list &lt; vecS, // edge container type vecS, // vertex container type undirectedS, VertexProperties, EdgeProperties, GraphProperties &gt; Graph; </code></pre>
 

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