igraph-help
[Top][All Lists]

Re: [igraph] (no subject)

 From: Tamás Nepusz Subject: Re: [igraph] (no subject) Date: Tue, 5 Jul 2011 20:51:51 +0200

Hello,

You have to specify the name of the edge attribute you want to read the weights from. The easiest way to do it is as follows:

const char *weight = "weight";

Then simply proceed with igraph_cattribute_EANV as above. Note that EANV in macro for is a shorthand for igraph_cattribute_EANV, see:

http://igraph.sourceforge.net/doc/html/ch09s02s01.html#EANV

--
T.

On Tuesday, 5 July 2011 at 19:14, Anselmo Garcia Cantu Ros wrote:

Hi,

I am debuting in igraph and am using c igraph 0.6.
I need to calculate distances within weighted graphs. Thus I've built the
graph from a weighted adjacency matrix, and then used
igraph_shortest_paths_dijkstra(). Everything was fine until working with
graph sizes of the order 10^4: Out of memory (apparently, the size was too
big for matrix). To overcome this situation I decided to build up the
graphs from a 3-column adjacency list (in format .ncol), that was fed into
"igraph_read_graph_ncol()". The edge query was done again using
igraph_cattribute_EANV(). When executing I get:

"Error at cattributes.c:1915 :Unknown attribute, Invalid value"

#include <igraph/igraph.h>
#include <stdio.h>
int main(void) {
FILE *fp;
fp=fopen("Matrixoutweight.ncol","r");

igraph_i_set_attribute_table(&igraph_cattribute_table);

igraph_t graph;

int i,j,nedges,nertex;
float test;
const char weight;

nedges=igraph_ecount(&graph);
nertex=igraph_vcount(&graph);

igraph_vector_t weightatt;
igraph_vector_init(&weightatt,nedges);
igraph_matrix_t SP;
igraph__matrix_init(&SP,nertex,nertex);

igraph_cattribute_EANV(&graph,&weight,igraph_ess_all(IGRAPH_EDGEORDER_FROM)
, &weightatt);

igraph_shortest_paths_dijkstra(&graph,&SP,igraph_vss_all(),igraph_vss_all()
,&weightatt,IGRAPH_OUT);

for (i = 0; i < nertex ; i++)
{
for (j = 0; j < nertex; j++)
{{
test=igraph_matrix_e(&SP,i,j);
printf("%d %d %f\n",i,j,test);
}
}

igraph_destroy(&graph);
igraph_vector_destroy(&weightatt);
igraph_matrix_destroy(&SP);

fclose(fp);

return 0;
}}