igraph-help
[Top][All Lists]
Advanced

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

Re: AW: [igraph] iGraph Layout questions


From: Tamas Nepusz
Subject: Re: AW: [igraph] iGraph Layout questions
Date: Tue, 18 May 2010 01:01:50 +0100

Hi Mathias,

> The next question I have is: What would be the easiest way to export the
> graph, including the coordinates, into a GraphML file?
Store the coordinates as two vertex attributes and then save the graph:

igraph_t graph;
igraph_matrix_t coords;
long int vcount, i;
FILE* out;

/* Turn on the C attribute handler */
igraph_i_set_attribute_table(&igraph_cattribute_table);

/* Generate the layout somehow */
[...]

/* Write the coordinates as vertex attributes */
vcount = igraph_vcount(&graph);
for (i = 0; i < vcount; i++) {
  igraph_cattribute_VAN_set(&graph, "x", i, MATRIX(coords, i, 0));
  igraph_cattribute_VAN_set(&graph, "y", i, MATRIX(coords, i, 1));
}

/* Store the graph */
out = fopen("graph.graphml", "w");
igraph_write_graph_graphml(&graph, out);
fclose(out);

For more details on attribute handling in C, see this page:

http://igraph.sourceforge.net/doc/html/ch09s02.html

-- 
Tamas




reply via email to

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