igraph-help
[Top][All Lists]
Advanced

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

[igraph] On ncol use and vertex labeling


From: Anselmo Garcia Cantu Ros
Subject: [igraph] On ncol use and vertex labeling
Date: Wed, 06 Jul 2011 18:05:24 +0200


A big thank Tamasz for your quick reply!. The problem with the weights is fixed. Now, if I got it right, read_graph_ncol() does not keep the labeling of the vertices, such as being specified in the input ncol-list. Could you please indicate me what would be the best way to reassign the original ID's to the graph vertices. Moreover, if i decided to use "ncol" edge-lists, it is because the sizes of the weighted networks that am analyzing seem to be too large for creating matrices. May be you can suggest me a better approach to get around with the size difficulty right from the start. Thanks again, Anselmo. Tamás Nepusz writes:
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]