igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] List triangles


From: Tamas Nepusz
Subject: Re: [igraph] List triangles
Date: Tue, 21 Feb 2017 20:26:01 +0100

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. <address@hidden> 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
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help



reply via email to

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