Boost logo

Boost Users :

Subject: Re: [Boost-users] array of small world graphs
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-02-04 09:45:57


On Thu, 4 Feb 2010, Vasilis Hatzopoulos wrote:

> Hi all, new to boost and experiencing a bit of an issue with generating a collection of small worlds.
> Basically i want for each pass of the loop to generate a small world with a certain pRewire.
>
>
> Here's some code
>
> typedef small_world_iterator<mt19937, Graph> SWGen;
>
> base_generator_type generator(1u);
>
>
> for(int i = 0; i < num_graphs; i++){
>
> Graph g( SWGen( generator, N, k, pRewire, SWGen(), N );
> .
> .
> some operations on g, i.e. path lengths e.t.c.
> }
>
> As it happens all graphs g are the same graph while what i want is a collection
> of different small worlds with the same pRewire. Why does the state of the generator not
> advance after the first Graph is generated?

I believe the generator is taken in by copy. See if either "&generator"
or "boost::ref(generator)" works instead of "generator" in your
construction of the graph.

-- Jeremiah Willcock


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