[Lemon-user] bad_alloc problem

Oláh Barbara olahb at caesar.elte.hu
Thu Mar 7 13:14:04 CET 2013


Hi,

I'm new to lemon. I'd like to generate a full graph with 10.000 nodes, 
and I've got this error:

terminate called after throwing an instance of 'std::bad_alloc'
   what():  std::bad_alloc

Do you have any idea what was the problem? I was wondering, is there any 
limit for the graph size?

I use 4.7.2. version of g++compiler and Ubuntu 12.10 (32 bit) operating 
system.

My code:

#include <iostream>
#include <lemon/smart_graph.h>
#include <lemon/core.h>

using namespace std;
using namespace lemon;

int main()
{
     SmartDigraph g;

     int NodeNumber = 10000;

     for(int i = 0; i < NodeNumber; i++)
         g.addNode();

     std::cout << "Nodes have been add." << std::endl;

     //Generate full graph
     for (SmartDigraph::NodeIt u(g); u != INVALID; ++u)
         for (SmartDigraph::NodeIt v(g); v != INVALID; ++v)
             if (u != v) g.addArc(u, v);
     std::cout << "Generated full graph." << std::endl;

     return 0;
}


Thank you,
Barbara Oláh



More information about the Lemon-user mailing list