1 /*
2 IGraph library.
3 Copyright (C) 2021 The igraph development team <igraph@igraph.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19 #include <igraph.h>
20 #include "test_utilities.inc"
21
call_and_print(igraph_t * graph)22 void call_and_print(igraph_t *graph) {
23 igraph_vector_int_t result;
24 igraph_vector_int_init(&result, 0);
25 IGRAPH_ASSERT(igraph_list_triangles(graph, &result) == IGRAPH_SUCCESS);
26 print_vector_int(&result);
27 IGRAPH_ASSERT(igraph_vector_int_size(&result) % 3 == 0);
28 igraph_vector_int_destroy(&result);
29 printf("\n");
30 }
31
32
main()33 int main() {
34 igraph_t g_0, g_1, g_5_full, g_lm;
35
36 igraph_small(&g_0, 0, 0, -1);
37 igraph_small(&g_1, 1, 0, -1);
38 igraph_full(&g_5_full, 5, 0, IGRAPH_NO_LOOPS);
39 igraph_small(&g_lm, 6, 1, 0,1, 0,1, 0,2, 0,2, 1,1, 1,2, 1,2, 1,3, 2,0, 2,3, 3,4, 3,4, -1);
40
41
42 printf("No vertices:\n");
43 call_and_print(&g_0);
44
45 printf("One vertex:\n");
46 call_and_print(&g_1);
47
48 printf("Full graph of 5 vertices:\n");
49 call_and_print(&g_5_full);
50
51 printf("Graph with loops and multiple edges:\n");
52 call_and_print(&g_lm);
53
54 igraph_destroy(&g_0);
55 igraph_destroy(&g_1);
56 igraph_destroy(&g_5_full);
57 igraph_destroy(&g_lm);
58
59 VERIFY_FINALLY_STACK();
60 return 0;
61 }
62