[Lemon-user] bad_alloc problem

Balázs Dezső deba.mf at gmail.com
Thu Mar 7 14:00:10 CET 2013


The graph size can be a problem:
A smart graph arc occupies 16 bytes. If you count the arcs in the graph,
they require ~1.6G space, but because of we are using vector, it will be 2G.

If you want to use full graph of this size, please consider to use
FullGraph or FullDigraph (or of course, you can buy some additional RAM).

Balazs


On Thu, Mar 7, 2013 at 1:14 PM, Oláh Barbara <olahb at caesar.elte.hu> wrote:

> 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
> _______________________________________________
> Lemon-user mailing list
> Lemon-user at lemon.cs.elte.hu
> http://lemon.cs.elte.hu/mailman/listinfo/lemon-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20130307/ed505e9b/attachment.html>


More information about the Lemon-user mailing list