Problem:
I want to make a weighted undirected graph from adjacency matrix stored in a .csv
file using igraph and then do the minimum spanning tree and some other algorithms on it.
I started with making a directed graph with 10 vertices and 5 edges. By default igraph does not allow weights for edges and you have to use some attributes which does not make sense to me (something like igraph_i_set_attribute_table
) in the documentation.
Can someone please help me regarding this.
void print_vector(igraph_vector_t *v, FILE *f) {
long int i;
for (i=0; i<igraph_vector_size(v); i++) {
fprintf(f, " %li", (long int) VECTOR(*v)[i]);
}
fprintf(f, "\n");
}
int main(int argc, char* argv[])
{
igraph_t g;
igraph_vector_t v;
int ret;
igraph_es_t es;
/* Initialize the vector for edges */
igraph_vector_init(&v,10);
VECTOR(v)[0]=0;VECTOR(v)[1]=1;
VECTOR(v)[2]=1;VECTOR(v)[3]=3;
VECTOR(v)[4]=1;VECTOR(v)[5]=5;
VECTOR(v)[6]=2;VECTOR(v)[7]=3;
VECTOR(v)[8]=2;VECTOR(v)[9]=5;
igraph_create(&g,&v,0,IGRAPH_DIRECTED);
print_vector(&v,stdout);
/* igraph_i_set_attribute_table(&igraph_cattribute_table); */
igraph_vector_destroy(&v);
igraph_destroy(&g);
return 0;
}