1
2 #include <igraph.h>
3
4 #include "test_utilities.inc"
5
main()6 int main() {
7
8 igraph_t g;
9 igraph_real_t global, global2, global3;
10
11 /* Small graphs */
12
13 printf("Null graph: ");
14 igraph_empty(&g, 0, IGRAPH_UNDIRECTED);
15 igraph_transitivity_undirected(&g, &global, IGRAPH_TRANSITIVITY_NAN);
16 print_real(stdout, global, "%g");
17 printf("\n");
18 igraph_destroy(&g);
19
20 printf("\nSingleton graph: ");
21 igraph_empty(&g, 1, IGRAPH_UNDIRECTED);
22 igraph_transitivity_undirected(&g, &global, IGRAPH_TRANSITIVITY_NAN);
23 print_real(stdout, global, "%g");
24 printf("\n");
25 igraph_destroy(&g);
26
27 printf("\nTwo connected vertices: ");
28 igraph_small(&g, 2, IGRAPH_UNDIRECTED, 0,1, -1);
29 igraph_transitivity_undirected(&g, &global, IGRAPH_TRANSITIVITY_NAN);
30 print_real(stdout, global, "%g");
31 printf("\n");
32 igraph_destroy(&g);
33
34 printf("\nTriangle: ");
35 igraph_full(&g, 3, IGRAPH_UNDIRECTED, IGRAPH_NO_LOOPS);
36 igraph_transitivity_undirected(&g, &global, IGRAPH_TRANSITIVITY_NAN);
37 print_real(stdout, global, "%g");
38 printf("\n");
39 igraph_destroy(&g);
40
41 printf("\nTwo-star: ");
42 igraph_small(&g, 3, IGRAPH_UNDIRECTED, 0,2, 0,1, -1);
43 igraph_transitivity_undirected(&g, &global, IGRAPH_TRANSITIVITY_NAN);
44 print_real(stdout, global, "%g");
45 printf("\n");
46 igraph_destroy(&g);
47
48 printf("\nZachary karate club: ");
49 igraph_famous(&g, "Zachary");
50 igraph_transitivity_undirected(&g, &global, IGRAPH_TRANSITIVITY_NAN);
51 print_real(stdout, global, "%g");
52 printf("\n");
53 igraph_destroy(&g);
54
55 printf("\nDirected and multigraphs:\n");
56
57 igraph_small(&g, 20, IGRAPH_DIRECTED,
58 15, 12, 12, 10, 15, 0, 11, 10, 2, 8, 8, 6, 13, 17, 10, 10, 17, 2, 14,
59 0, 16, 13, 14, 14, 0, 5, 6, 4, 0, 9, 0, 6, 10, 9, 16, 4, 14, 5, 17,
60 15, 14, 9, 17, 17, 1, 4, 10, 16, 7, 0, 11, 12, 6, 13, 2, 17, 4, 0, 0,
61 14, 4, 0, 6, 16, 16, 14, 13, 13, 12, 11, 3, 11, 11, 3, 6, 7, 4, 14,
62 10, 8, 13, 7, 14, 2, 5, 2, 0, 14, 3, 15, 5, 5, 7, 2, 14, 15, 5, 10,
63 10, 16, 7, 9, 14, 0, 15, 7, 13, 1, 15, 1, 4, 5, 4, 6, 16, 13, 6, 17,
64 8, 6, 9, 3, 8, 6, 6, 14, 11, 14, 6, 10, 10, 5, 1, 0, 16, 17, 9, 1, 5,
65 0, 5, 15, 8, 0, 0, 8, 5, 3, 9, 4, 13, 12, 11, 0, 11, 0, 10, 6, 4, 13,
66 8, 9, 11, 11, 3, 16, 1, 2, 16, 0, 9, 8, 3, 8, 8, 7, 12, 10, 9, 3, 13,
67 5, 3, 9, 6, 2, 11, 10, 1, 16, 0, 2, 10, 17, 16, 8, 11, 5, 13, 0, 19, 19,
68 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
69 -1);
70
71 printf("\nDirected multi: ");
72 igraph_transitivity_undirected(&g, &global, IGRAPH_TRANSITIVITY_NAN);
73 print_real(stdout, global, "%.10g");
74 printf("\n");
75
76 printf("Undirected multi: ");
77 igraph_to_undirected(&g, IGRAPH_TO_UNDIRECTED_COLLAPSE, NULL);
78 igraph_transitivity_undirected(&g, &global2, IGRAPH_TRANSITIVITY_NAN);
79 print_real(stdout, global2, "%.10g");
80 printf("\n");
81
82 printf("Simple: ");
83 igraph_simplify(&g, 1, 1, NULL);
84 igraph_transitivity_undirected(&g, &global3, IGRAPH_TRANSITIVITY_NAN);
85 print_real(stdout, global3, "%.10g");
86 printf("\n");
87
88 IGRAPH_ASSERT(global == global2);
89 IGRAPH_ASSERT(global == global3);
90
91 igraph_destroy(&g);
92
93 VERIFY_FINALLY_STACK();
94
95 return 0;
96 }
97