[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] about the igraph_clusters( )
From: |
Yi Cao |
Subject: |
[igraph] about the igraph_clusters( ) |
Date: |
Wed, 30 Mar 2011 14:48:26 -0700 |
Hello everyone,
I was trying to use the igraph_clusters( ) in the following code:
#include <igraph.h>
#include <stdlib.h>
#include<stdio.h>
#include<iostream>
using namespace std;
int main(int argc, char *argv[ ])
{
igraph_t g;
igraph_vector_t membership;
igraph_vector_t csize;
igraph_integer_t no;
long int i,s;
if (argc!=2)
{printf("You must suppy edge file name!\n"); exit(0);}
//first,read an edgelist in order to reate a graph.
FILE *input;
input=fopen(argv[1], "r");
if (!input) {
printf("error");
}
igraph_read_graph_edgelist(&g, input, 0, IGRAPH_UNDIRECTED);
fclose(input);
printf("Vertices count: %d\n", (int)igraph_vcount(&g));
printf("Edge count : %d\n", (int)igraph_ecount(&g));
igraph_vector_init(&membership, 100);
igraph_vector_init(&csize, 100);
igraph_clusters(&g, &membership, &csize, &no,IGRAPH_WEAK);
igraph_vector_destroy(&membership);
igraph_vector_destroy(&csize);
s=igraph_vector_size(&csize);
for (i=0;i<s;i++)
{
cout<<i<<" "<<VECTOR(csize)[i]<<"\n"<<endl;
}
return 0;
}
But I met with some problems:
the first was : what should the last argument for igraph_clusters( ) for a undirected bipartite graph?
the second was : when I tried to cout the content in vector csize, it returned segmentation fault(core dumped). I was't sure about why this happened. Any one has some ideas? Thanks a lot.
:) Yi
- [igraph] about the igraph_clusters( ),
Yi Cao <=