Hi, triangles has to be initialized before calling igraph_list_triangles with igraph_vector_int_init(). Just initialize it to a size of zero and igraph_list_triangles() will resize it as needed.
T. On Tue, Feb 21, 2017 at 5:32 PM, Perrone, Alexander G. < [email protected]> wrote: > How can one list all the triangles in igraph C? I could not find an > example in documentation. I'd like the same output as triangles(g) in R. I > tried the following as an example but I cannot get it to work. Error > is Segmentation fault (core dumped). Any help would be much appreciated. > > > #include <igraph.h> > > int main(void) { > igraph_vector_t v; > igraph_vector_int_t triangles; > igraph_t graph; > > igraph_real_t edges[] = { 0, 1, 0, 2, 1, 2, 2, 3, 2, 4, 3, 4 }; > igraph_vector_view(&v, edges, sizeof(edges)/sizeof(double)); > igraph_create(&graph, &v, 0, IGRAPH_UNDIRECTED); > > igraph_list_triangles(&graph, &triangles); > igraph_vector_int_destroy(&triangles); > } > > > Alex > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help > >
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
