Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use `randomize_property` with bundled property graph in boost graph library?
    primarykey
    data
    text
    <p>In the documentation: <a href="http://www.boost.org/doc/libs/1_46_1/libs/graph/doc/random.html#randomize_property" rel="nofollow">http://www.boost.org/doc/libs/1_46_1/libs/graph/doc/random.html#randomize_property</a></p> <p>There is only a function prototype, I cannot find a working example. I tried several things but it just cannot compile. Here's a simple source code:</p> <pre><code>#include &lt;ctime&gt; #include &lt;iostream&gt; #include &lt;boost/graph/random.hpp&gt; #include &lt;boost/graph/adjacency_list.hpp&gt; #include &lt;boost/random/linear_congruential.hpp&gt; #include &lt;boost/graph/erdos_renyi_generator.hpp&gt; #include &lt;boost/graph/graphviz.hpp&gt; using namespace std; using namespace boost; struct EdgeProperty { int cost; }; typedef adjacency_list&lt; setS, // disallow parallel edge vecS, undirectedS, no_property, EdgeProperty &gt; Graph; typedef erdos_renyi_iterator&lt;minstd_rand, Graph&gt; ERGen; int main(int argc, const char *argv[]) { minstd_rand gen(time(0)); assert(argc &gt;= 3); int n = atoi(argv[1]); double p = atof(argv[2]); Graph g(ERGen(gen, n, p), ERGen(), n); // randomize_property&lt; [unknown class] &gt;(g, gen); return 0; } </code></pre> <p>Update: the code provided by @phooji works. I added a default constructor for the <code>EdgeProperty</code> and my code compiles too:</p> <pre><code>struct EdgeProperty { EdgeProperty(int x = 0) : cost(x) { } int cost; }; </code></pre> <p>The original compilation error is posted as a gist <a href="https://gist.github.com/935682" rel="nofollow">here</a>, which I cannot understand. Hope someone tell me how this works.</p>
    singulars
    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.
    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