igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Segfault in weighted edge betweenness community detection


From: Tamás Nepusz
Subject: Re: [igraph] Segfault in weighted edge betweenness community detection
Date: Wed, 25 Apr 2012 22:51:24 +0200

Hello,  

The bug is triggered by the presence of edges with zero weight. As a 
workaround, remove the zero-weight edges from the graph before proceeding with 
the community detection.  

--  
T.


On Wednesday, 25 April 2012 at 20:55, Tamás Nepusz wrote:

> Hello,  
>  
> Seems to be a bug on our side; I have added a bug report and I am looking 
> into this right now. You can follow the issue here:
>  
> https://bugs.launchpad.net/igraph/+bug/988480
>  
> --  
> T.
>  
>  
> On Wednesday, 25 April 2012 at 18:00, R N wrote:
>  
> > Hello,
> >  
> > I'm using igraph-0.6 build 2694-20120421. I'm trying to use the edge
> > betweenness community detection
> > function with weighted graphs. I tried out a couple of graphs that I
> > have, with 1000 vertices and ~2200 edges.
> > The function crashes on both of them if edge weights are used, but
> > works if the edge weights are not used.
> > It seems that it crashes at line 866 of file 'heap.c', in function
> > 'igraph_i_2wheap_switch'.
> > Is there some (hopefully small) error in igraph or my negligence in using 
> > it?
> >  
> > Here are the crashy graphs:
> > http://www.sendspace.com/filegroup/WXCyAHR%2F28xEv21G0LQm8A
> >  
> > And here is the full proggy that I used.
> >  
> > ---8<---
> >  
> > #include <igraph.h>
> > #include <string.h>
> > #include <stdlib.h>
> >  
> > int cd_edge_betweenness (igraph_t *g, igraph_vector_t *weights,
> > igraph_vector_t *cm, double *Q)
> > {
> >  
> > igraph_vector_t modularity_eb;
> > igraph_vector_t eb, edges;
> >  
> > igraph_vector_init (&modularity_eb, 0);
> > igraph_vector_init (&eb, 0);
> > igraph_vector_init (&edges, 0);
> >  
> > igraph_community_edge_betweenness(
> > g,
> > &edges,
> > &eb,
> > 0, // merges
> > 0, // bridges
> > &modularity_eb, // modularity
> > cm, //membership
> > IGRAPH_UNDIRECTED,
> > weights);
> >  
> > long int i_eb_max_mod = igraph_vector_which_max (&modularity_eb);
> > *Q = VECTOR (modularity_eb)[i_eb_max_mod];
> >  
> > igraph_vector_destroy (&modularity_eb);
> > igraph_vector_destroy (&eb);
> > igraph_vector_destroy (&edges);
> >  
> > return 0;
> > }
> >  
> > int main(int argc, char *argv[])
> > {
> >  
> > igraph_t g;
> > FILE *ifile, *ofile;
> > long int i;
> > long int num_vertex, num_edge;
> > double Q;
> >  
> > igraph_vector_t gtypes, vtypes, etypes;
> > igraph_strvector_t gnames, vnames, enames;
> >  
> > if (argc < 3)
> > {
> > printf ("Usage: %s (IN)in.graphml (OUT)comm_membership_file\n", argv[0]);
> > return -1;
> > }
> >  
> > ifile=fopen(argv[1], "r");
> > if (ifile == 0)
> > {
> > printf ("File opening error: %s\n", argv[1]);
> > return -1;
> > }
> >  
> > ofile = fopen (argv[2], "w");
> > if (ofile == 0)
> > {
> > printf ("File opening error: %s\n", argv[2]);
> > return -1;
> > }
> >  
> > igraph_i_set_attribute_table(&igraph_cattribute_table);
> > igraph_read_graph_graphml (&g, ifile, 0);
> > fclose(ifile);
> >  
> > igraph_vector_init(&gtypes, 0);
> > igraph_vector_init(&vtypes, 0);
> > igraph_vector_init(&etypes, 0);
> > igraph_strvector_init(&gnames, 0);
> > igraph_strvector_init(&vnames, 0);
> > igraph_strvector_init(&enames, 0);
> >  
> > igraph_cattribute_list(&g, &gnames, &gtypes, &vnames, &vtypes,
> > &enames, &etypes);
> >  
> > num_vertex = igraph_vcount (&g);
> > num_edge = igraph_ecount (&g);
> >  
> > igraph_vector_t weights;
> > igraph_vector_t cm; // community membership vector
> >  
> > igraph_vector_init (&weights, num_edge);
> > igraph_vector_init (&cm, num_vertex);
> >  
> > for (i=0; i < num_edge; i++)
> > {
> > //printf ("%d: Edge id=%s, weight=%f\n", i, EAS (g, "id", i), EAN
> > (g, "weight", i));
> > VECTOR(weights) [i] = EAN (&g, "weight", i);
> > }
> >  
> > int ires = cd_edge_betweenness (&g, &weights, &cm, &Q);
> >  
> > fprintf (ofile, "# modularity: Q=%g\n", Q);
> > for (i = 0; i < num_vertex; ++i)
> > {
> > fprintf (ofile, "%d\t", (int) VECTOR (cm) [i]);
> > }
> > fprintf (ofile, "\n");
> >  
> > igraph_vector_destroy (&weights);
> > igraph_vector_destroy (&cm);
> >  
> > igraph_vector_destroy (&gtypes);
> > igraph_vector_destroy (&vtypes);
> > igraph_vector_destroy (&etypes);
> > igraph_strvector_destroy (&gnames);
> > igraph_strvector_destroy (&vnames);
> > igraph_strvector_destroy (&enames);
> >  
> > igraph_destroy(&g);
> >  
> > return 0;
> > }
> >  
> > _______________________________________________
> > igraph-help mailing list
> > address@hidden (mailto:address@hidden)
> > https://lists.nongnu.org/mailman/listinfo/igraph-help
>  






reply via email to

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