igraph-help
[Top][All Lists]
Advanced

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

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"

Please help me. The code is the following:

#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;

igraph_read_graph_ncol(&graph,fp,NULL,0,1,0);

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;
}}

Thanks in advance

_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help


reply via email to

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