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,igraph_es_t es)22 void call_and_print(igraph_t *graph, igraph_es_t es) {
23     igraph_vector_bool_t result;
24     igraph_vector_bool_init(&result, 0);
25     IGRAPH_ASSERT(igraph_is_mutual(graph, &result, es) == IGRAPH_SUCCESS);
26     igraph_vector_bool_print(&result);
27     printf("\n");
28     igraph_vector_bool_destroy(&result);
29 }
30 
31 
main()32 int main() {
33     igraph_t g_0, g_lm, g_lmu;
34     igraph_vector_bool_t result;
35 
36     igraph_vector_bool_init(&result, 0);
37 
38     igraph_small(&g_0, 0, 0, -1);
39     igraph_small(&g_lm, 6, 1, 0,1, 0,2, 1,1, 1,3, 2,0, 2,0, 2,3, 3,4, 3,4, -1);
40     igraph_small(&g_lmu, 6, 0, 0,1, 0,2, 1,1, 1,3, 2,0, 2,0, 2,3, 3,4, 3,4, -1);
41 
42     printf("No vertices:\n");
43     call_and_print(&g_0, igraph_ess_all(IGRAPH_EDGEORDER_ID));
44 
45     printf("Graph with loops and multiple edges:\n");
46     call_and_print(&g_lm, igraph_ess_all(IGRAPH_EDGEORDER_ID));
47 
48     printf("Same graph, selecting edge 4:\n");
49     call_and_print(&g_lm, igraph_ess_1(4));
50 
51     printf("Same graph, but undirected:\n");
52     call_and_print(&g_lmu, igraph_ess_all(IGRAPH_EDGEORDER_ID));
53 
54     VERIFY_FINALLY_STACK();
55     igraph_set_error_handler(igraph_error_handler_ignore);
56 
57     printf("Edge out of range.\n");
58     IGRAPH_ASSERT(igraph_is_mutual(&g_lm, &result, igraph_ess_1(100)) == IGRAPH_EINVAL);
59 
60     igraph_destroy(&g_0);
61     igraph_destroy(&g_lm);
62     igraph_destroy(&g_lmu);
63     igraph_vector_bool_destroy(&result);
64 
65     VERIFY_FINALLY_STACK();
66     return 0;
67 }
68