[Boost-bugs] [Boost C++ Libraries] #13209: erdos_renyi_iterator hangs when n is 1

Subject: [Boost-bugs] [Boost C++ Libraries] #13209: erdos_renyi_iterator hangs when n is 1
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-09-13 18:04:15


#13209: erdos_renyi_iterator hangs when n is 1
-------------------------------------+-------------------------------
 Reporter: grievejia@… | Owner: Jeremiah Willcock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: graph
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
-------------------------------------+-------------------------------
 Running the following program would result in an infinite loop:
 {{{
 #include <boost/graph/erdos_renyi_generator.hpp>
 #include <boost/graph/adjacency_list.hpp>
 #include <random>

 using Graph = boost::adjacency_list<>;
 using ERGen = boost::erdos_renyi_iterator<std::mt19937, Graph>;

 int main() {
   std::mt19937 gen;
   int n = 1;
   Graph g(ERGen(gen, n, 0.5), ERGen(), n);
 }
 }}}

 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.

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13209>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-09-13 18:10:29 UTC