[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] help need for the fast community detection algorithm
From: |
Csardi Gabor |
Subject: |
Re: [igraph] help need for the fast community detection algorithm |
Date: |
Thu, 26 Jul 2007 11:57:32 +0200 |
User-agent: |
Mutt/1.5.9i |
Jiang,
(hope this is your first name), so it is not clear for me what you
want to do with the code you've sent.
Some points:
1) 'igraph_modularity' does not do any community detection, it just
calculates the modularity scores for a given community structure.
You supply the community structure in the 'type' argument, but in your
case that is all zero, so every vertex is in the same community. The
modularity of this configuration is zero i guess, although i haven't
check the definition lately.
2) you need to call 'igraph_community_fastgreedy' to do actual community
detection.
3) it seems that indeed there are some problems with
igraph_community_fastgreedy, this was found shortly before your email.
We will write to the mailing list as soon as we've found out what the
problem is.
Other, not closely related tips:
4) instead of giving the 'edges' vector you can use 'igraph_small',
that is a more compact notation to give small graphs.
5) Please consider joining the mailing list. Otherwise i need to
acknowledge your emails by hand and that requires a day or two, maybe
even more if i'm offline.
Best,
Gabor
On Thu, Jul 26, 2007 at 04:06:58PM +0800, Xing Jiang wrote:
> Hi All,
>
> I am now using igraph for community structure detection. I write a very
> simple program to call the igraph library. I want to see what the result is
> on the club graph shown in the example. However, I see this algorithm does
> not work and no partition performed.
>
> the graph I want to test have 8 edges.Its structure is like
>
> 1 5
> 0 3 ------4 7
> 2 6
>
>
> node {0, 1, 2,3} & {4,5,6,7} are two cliques.
>
> It is supposed to have two sub structures detected. However, I do not obtain
> such results. I test on NewMan's code. it works. But igraph does not work.
>
>
> thank you for your help!
>
>
>
> the following code is the one i use:
>
> int main(void){
> igraph_real_t modularity;
> igraph_integer_t vertexNumber = 8;
> igraph_integer_t edgeNumber = 13;
>
> igraph_vector_t edges;
> igraph_vector_t type;
>
> igraph_t graph;
>
> igraph_empty(&graph, vertexNumber, IGRAPH_UNDIRECTED);
>
> igraph_vector_init(&edges, edgeNumber*2);
>
> VECTOR(edges)[0]=0;
> VECTOR(edges)[1]=1;
> VECTOR(edges)[2]=0;
> VECTOR(edges)[3]=2;
> VECTOR(edges)[4]=0;
> VECTOR(edges)[5]=3;
> VECTOR(edges)[6]=1;
> VECTOR(edges)[7]=2;
> VECTOR(edges)[8]=1;
> VECTOR(edges)[9]=3;
> VECTOR(edges)[10]=2;
> VECTOR(edges)[11]=3;
> VECTOR(edges)[12]=2;
> VECTOR(edges)[13]=4;
> VECTOR(edges)[14]=4;
> VECTOR(edges)[15]=5;
> VECTOR(edges)[16]=4;
> VECTOR(edges)[17]=6;
> VECTOR(edges)[18]=4;
> VECTOR(edges)[19]=7;
> VECTOR(edges)[20]=5;
> VECTOR(edges)[21]=6;
> VECTOR(edges)[22]=5;
> VECTOR(edges)[23]=7;
> VECTOR(edges)[24]=6;
> VECTOR(edges)[25]=7;
>
> igraph_add_edges(&graph, &edges,0);
>
> igraph_vector_init(&type,vertexNumber);
>
> igraph_modularity(&graph,&type, &modularity);
>
> igraph_integer_t zz = igraph_ecount(&graph);
>
> printf("edge: %d\n",(int)zz);
>
> printf("Modularity: %f\n",(double)modularity);
>
> igraph_vector_destroy(&edges);
> igraph_vector_destroy(&type);
> igraph_destroy(&graph);
>
> return 0;
>
> }
>
> --
> regards
> Jiang Xing
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
--
Csardi Gabor <address@hidden> MTA RMKI, ELTE TTK