Boost C++ Libraries: Ticket #13209: erdos_renyi_iterator hangs when n is 1 https://svn.boost.org/trac10/ticket/13209 <p> Running the following program would result in an infinite loop: </p> <pre class="wiki">#include &lt;boost/graph/erdos_renyi_generator.hpp&gt; #include &lt;boost/graph/adjacency_list.hpp&gt; #include &lt;random&gt; using Graph = boost::adjacency_list&lt;&gt;; using ERGen = boost::erdos_renyi_iterator&lt;std::mt19937, Graph&gt;; int main() { std::mt19937 gen; int n = 1; Graph g(ERGen(gen, n, 0.5), ERGen(), n); } </pre><p> This is caused by the while loop inside erdos_renyi_iterator::next(). If n is 1 and allow_self_loops is false, the loop condition will be true forever. A simple change that makes an early exit for the n=1 case would fix the problem. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13209 Trac 1.4.3