igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] c stack problem


From: roberto pagliari
Subject: Re: [igraph] c stack problem
Date: Fri, 15 Apr 2011 12:18:03 -0700

Thank you!

On Fri, Apr 15, 2011 at 2:08 AM, Tamas Nepusz <address@hidden> wrote:
Hi Roberto,

The short answer is that igraph is not thread-safe, so you can only use
igraph from one thread at the same time.

The long answer was discussed last year in a discussion thread that starts
here (follow the thread for the answers):

http://lists.nongnu.org/archive/html/igraph-help/2010-10/msg00150.html

However, you could probably speed up your code a bit by constructing the
edge list first and then adding the edges in one batch using igraph_add_edges.

--
T.

On 04/15/2011 01:25 AM, roberto pagliari wrote:
> I am trying to use igraph within a c++ program. At some point I have a class
> method that looks like this
>
> /**** code  ****/
> int Graph::gen_links() {
>     igraph_t graph;
>     igraph_empty(&graph, xy.size(), 0);
>     if( save == true )
>         links.clear();
>
>     double h_sq, d;
>     // generate links
>     for(luint i = 0; i < xy.size(); i++)
>         for(luint j = i+1; j < xy.size(); j++) {
>             // generate |h|^2
>             d = distance(i, j);
>             if( d < d_crit )
>                 d = 1.0;
>             h_sq = pow(mrand.randNorm(0, 1), 2.0) + pow(mrand.randNorm(0,
> 1), 2.0);
>             if( h_sq * snr_lin / gamma_0_lin * pow(d, -alpha) >= 1 ) {
>                 igraph_add_edge(&graph, i, j);
>                 if( save == true )
>                     links.push_back( make_pair(i, j) );
>             }
>         }
>     igraph_is_connected(&graph, &connected,  IGRAPH_STRONG);
>     igraph_destroy(&graph);
>     return 1;
> }
> /*********************/
>
> The weird thing is that if I run a single-threaded simulation everything
> seems to be fine. If, instead, I use multithreading (where each thread has
> its own instance of Graph from which Graph::gen_links() is called) I get the
> following run-time errors.
>
> corrupt finally stack, popping 1 elements when only 0 left
> corrupt finally stack, popping 1 elements when only 0 left
> corrupt finally stack, popping 1 elements when only 0 left
> corrupt finally stack, popping 1 elements when only 0 left
> corrupt finally stack, popping 1 elements when only 0 left
> corrupt finally stack, popping 1 elements when only 0 left
> Assertion failed: (no>=0), function IGRAPH_FINALLY_REAL, file error.c, line 126.
> /Applications/NetBeans/NetBeans
> 6.9.1.app/Contents/Resources/NetBeans/ide/bin/nativeexecution/dorun.sh: line
> 33: 61152 Abort trap              sh "${SHFILE}"
> Press [Enter] to close the terminal ...
>
> the problem appears to be related to igraph_add_edge. When removed I get no
> errors. Do you guys know what the problem could be?
>
> Thank you
>
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help

_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help


reply via email to

[Prev in Thread] Current Thread [Next in Thread]