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 
main()22 int main() {
23     igraph_t g_0, g_1, g_simple, g_ml;
24     igraph_real_t result;
25 
26     igraph_rng_seed(igraph_rng_default(), 42);
27 
28     igraph_small(&g_0, 0, 0, -1);
29     igraph_small(&g_1, 1, 0, -1);
30     igraph_small(&g_simple, 6, 1, 0,1, 0,2, 1,2, 1,3, 2,3, 3,4, -1);
31     igraph_small(&g_ml, 6, 0, 0,1, 0,2, 1,1, 1,2, 1,3, 2,1, 2,3, 3,4, 3,4, -1);
32 
33     igraph_set_error_handler(igraph_error_handler_ignore);
34 
35     printf("No vertices, transitivity zero:\n");
36     IGRAPH_ASSERT(igraph_transitivity_avglocal_undirected(&g_0, &result, IGRAPH_TRANSITIVITY_ZERO) == IGRAPH_SUCCESS);
37     print_real(stdout, result, "%g");
38     printf("\n");
39 
40     printf("No vertices, transitivity NaN:\n");
41     IGRAPH_ASSERT(igraph_transitivity_avglocal_undirected(&g_0, &result, IGRAPH_TRANSITIVITY_NAN) == IGRAPH_SUCCESS);
42     print_real(stdout, result, "%g");
43     printf("\n");
44 
45     printf("One vertex, transitivity zero:\n");
46     IGRAPH_ASSERT(igraph_transitivity_avglocal_undirected(&g_1, &result, IGRAPH_TRANSITIVITY_ZERO) == IGRAPH_SUCCESS);
47     print_real(stdout, result, "%g");
48     printf("\n");
49 
50     printf("One vertex, transitivity NaN:\n");
51     IGRAPH_ASSERT(igraph_transitivity_avglocal_undirected(&g_1, &result, IGRAPH_TRANSITIVITY_NAN) == IGRAPH_SUCCESS);
52     print_real(stdout, result, "%g");
53     printf("\n");
54 
55     printf("Simple graph:\n");
56     IGRAPH_ASSERT(igraph_transitivity_avglocal_undirected(&g_simple, &result, IGRAPH_TRANSITIVITY_ZERO) == IGRAPH_SUCCESS);
57     print_real(stdout, result, "%g");
58     printf("\n");
59 
60     printf("Multigraph:\n");
61     IGRAPH_ASSERT(igraph_transitivity_avglocal_undirected(&g_ml, &result, IGRAPH_TRANSITIVITY_ZERO) == IGRAPH_SUCCESS);
62     print_real(stdout, result, "%g");
63     printf("\n");
64 
65     printf("Multigraph, TRANSITIVITY_NAN:\n");
66     IGRAPH_ASSERT(igraph_transitivity_avglocal_undirected(&g_ml, &result, IGRAPH_TRANSITIVITY_NAN) == IGRAPH_SUCCESS);
67     print_real(stdout, result, "%g");
68     printf("\n");
69 
70     igraph_destroy(&g_0);
71     igraph_destroy(&g_1);
72     igraph_destroy(&g_simple);
73     igraph_destroy(&g_ml);
74 
75     VERIFY_FINALLY_STACK();
76     return 0;
77 }
78