This compiles and runs, but I cannot get the expected results:
#include <igraph/igraph.h>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
igraph_vector_int_t gtypes, vtypes, etypes;
igraph_strvector_t gnames, vnames, enames;
igraph_vector_int_init(>ypes, 0);
igraph_vector_int_init(&vtypes, 0);
igraph_vector_int_init(&etypes, 0);
igraph_strvector_init(&gnames, 0);
igraph_strvector_init(&vnames, 0);
igraph_strvector_init(&enames, 0);
igraph_set_attribute_table(&igraph_cattribute_table);
igraph_t g;
igraph_vector_int_t v;
igraph_vector_int_init( &v, 10 );
VECTOR(v)[0] = 0;
VECTOR(v)[1] = 1;
VECTOR(v)[2] = 0;
VECTOR(v)[3] = 2;
VECTOR(v)[4] = 0;
VECTOR(v)[5] = 3;
VECTOR(v)[6] = 1;
VECTOR(v)[7] = 3;
VECTOR(v)[8] = 2;
VECTOR(v)[9] = 4;
igraph_create(&g,&v,0,IGRAPH_UNDIRECTED);
/* Add names */
igraph_vector_t names;
igraph_vector_init_range(&names, 0, igraph_vcount(&g));
for ( int i=0; i<igraph_vcount(&g); i++ ) {
VECTOR(names)[i] = i;
}
printf( "%s\n", VECTOR(names)[0] );
SETVANV( &g, "name", &names );
/* Can you plot it? */
igraph_matrix_t coords;
igraph_matrix_init(&coords, 0, 0);
igraph_layout_reingold_tilford(&g, &coords, IGRAPH_ALL, 0, 0);
int n=igraph_vcount(&g);
for (long i=0; i<n; i++) {
printf("%s %6.3f %6.3f\n", VAN(&g, "name", i), MATRIX(coords, i, 0), MATRIX(coords, i, 1));
}
igraph_vector_int_destroy( &v );
igraph_destroy( &g );
}
This gives the following results:
$ ./MRE_graphNamedVertices
name 0.000 0.000
name 1.000 -1.000
name 2.000 0.000
name 3.000 1.000
name 4.000 0.000
$
Any help would be appreciated.