igraph-help
[Top][All Lists]
Advanced

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

[igraph] igraph_get_shortest_paths_dijkstra memory problem?


From: Daniel Schreiber
Subject: [igraph] igraph_get_shortest_paths_dijkstra memory problem?
Date: Mon, 2 Mar 2009 16:16:56 -0600

Hi
I have a problem with the dijkstra function under C. Does anyone know
why the attached code gives the attached output/error?
I can run the included example from the package, but I cannot see what
I do wrong. Hope this is not too stupid.
My system is Ubuntu and I have igraph 5.1.
thx, Daniel

CODE:
int main(void) {
        //construct graph:
        igraph_t g;
        igraph_vector_t dimvector;
        igraph_vector_init(&dimvector, 2);
        VECTOR(dimvector)[0]=10;
        VECTOR(dimvector)[1]=20;
        igraph_lattice(&g,&dimvector,0,IGRAPH_UNDIRECTED,0,0);
        igraph_vector_destroy(&dimvector);

        //initialize weights:
        igraph_vector_t weights;
        int i;
        igraph_vector_init(&weights,igraph_ecount(&g)); //every edge gets a 
weight
        for(i=0; i<igraph_ecount(&g); i++)
                VECTOR(weights)[i] = i;

        //construct the vertice selector of the destinations of the search:
        igraph_vector_t lastrow;
        igraph_vector_init(&lastrow,10);
        for(i=0; i<10; i++) {
                VECTOR(lastrow)[i] = 10*20-1-i;
        }
        //igraph_vs_t to = igraph_vss_vector(&lastrow);
        igraph_vs_t to;
        igraph_vs_vector(&to,&lastrow);

        //inititalize result:
        igraph_vector_ptr_t shortestPaths;
        igraph_vector_ptr_init(&shortestPaths,10);
        for(i=0; i<igraph_vcount(&g); i++) {
            VECTOR(shortestPaths)[i] = calloc(1, sizeof(igraph_vector_t));
            igraph_vector_init(VECTOR(shortestPaths)[i], 0);
        }

        
igraph_get_shortest_paths_dijkstra(&g,&shortestPaths,0,to,&weights,IGRAPH_ALL);


        puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
        return EXIT_SUCCESS;
}

OUTPUT:
*** glibc detected ***
/home/daniel/workspace/testdijkstra2/Debug/testdijkstra2: realloc():
invalid old size: 0x0804fb18 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7cf4803]
/lib/tls/i686/cmov/libc.so.6(realloc+0x10b)[0xb7cf675b]
/usr/local/lib/libigraph.so.0(igraph_vector_reserve+0x71)[0xb7e6fc01]
/usr/local/lib/libigraph.so.0(igraph_vector_resize+0x36)[0xb7e6fcd6]
/usr/local/lib/libigraph.so.0(igraph_get_shortest_paths_dijkstra+0x866)[0xb7e191d6]
/home/daniel/workspace/testdijkstra2/Debug/testdijkstra2[0x8049211]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7c9d450]
/home/daniel/workspace/testdijkstra2/Debug/testdijkstra2[0x8048981]
======= Memory map: ========
08048000-0804a000 r-xp 00000000 08:01 657379
/home/daniel/workspace/testdijkstra2/Debug/testdijkstra2
0804a000-0804b000 rw-p 00001000 08:01 657379
/home/daniel/workspace/testdijkstra2/Debug/testdijkstra2
0804b000-0806c000 rw-p 0804b000 00:00 0          [heap]
b7900000-b7921000 rw-p b7900000 00:00 0
b7921000-b7a00000 ---p b7921000 00:00 0
b7a28000-b7a2a000 rw-p b7a28000 00:00 0
b7a2a000-b7a3e000 r-xp 00000000 08:01 290385     /usr/lib/libz.so.1.2.3.3
b7a3e000-b7a3f000 rw-p 00013000 08:01 290385     /usr/lib/libz.so.1.2.3.3
b7a3f000-b7a41000 r-xp 00000000 08:01 64702      /lib/tls/i686/cmov/libdl-2.7.so
b7a41000-b7a43000 rw-p 00001000 08:01 64702      /lib/tls/i686/cmov/libdl-2.7.so
b7a43000-b7a4d000 r-xp 00000000 08:01 64196      /lib/libgcc_s.so.1
b7a4d000-b7a4e000 rw-p 0000a000 08:01 64196      /lib/libgcc_s.so.1
b7a4e000-b7a71000 r-xp 00000000 08:01 64703      /lib/tls/i686/cmov/libm-2.7.so
b7a71000-b7a73000 rw-p 00023000 08:01 64703      /lib/tls/i686/cmov/libm-2.7.so
b7a73000-b7b5b000 r-xp 00000000 08:01 561174     /usr/lib/libstdc++.so.6.0.9
b7b5b000-b7b5e000 r--p 000e8000 08:01 561174     /usr/lib/libstdc++.so.6.0.9
b7b5e000-b7b60000 rw-p 000eb000 08:01 561174     /usr/lib/libstdc++.so.6.0.9
b7b60000-b7b66000 rw-p b7b60000 00:00 0
b7b66000-b7c80000 r-xp 00000000 08:01 754723     /usr/lib/libxml2.so.2.6.31
b7c80000-b7c85000 rw-p 00119000 08:01 754723     /usr/lib/libxml2.so.2.6.31
b7c85000-b7c87000 rw-p b7c85000 00:00 0
b7c87000-b7dd0000 r-xp 00000000 08:01 64699      /lib/tls/i686/cmov/libc-2.7.so
b7dd0000-b7dd1000 r--p 00149000 08:01 64699      /lib/tls/i686/cmov/libc-2.7.so
b7dd1000-b7dd3000 rw-p 0014a000 08:01 64699      /lib/tls/i686/cmov/libc-2.7.so
b7dd3000-b7dd6000 rw-p b7dd3000 00:00 0
b7dd6000-b7f4d000 r-xp 00000000 08:01 416974
/usr/local/lib/libigraph.so.0.0.0
b7f4d000-b7f93000 rw-p 00176000 08:01 416974
/usr/local/lib/libigraph.so.0.0.0
b7f93000-b7f97000 rw-p b7f93000 00:00 0
b7faa000-b7fac000 rw-p b7faa000 00:00 0
b7fac000-b7fad000 r-xp b7fac000 00:00 0          [vdso]
b7fad000-b7fc7000 r-xp 00000000 08:01 64185      /lib/ld-2.7.so
b7fc7000-b7fc9000 rw-p 00019000 08:01 64185      /lib/ld-2.7.so
bfe5e000-bfe73000 rw-p bffeb000 00:00 0          [stack]




reply via email to

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