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;
24 
25     igraph_rng_seed(igraph_rng_default(), 42);
26 
27     printf("No vertices:\n");
28     IGRAPH_ASSERT(igraph_forest_fire_game(&g, /*number of vertices*/0, /*fw_prob*/ 0.0,
29                   /*bw_factor*/ 0.0, /*pambs*/1, /*directed*/ 0) == IGRAPH_SUCCESS);
30     print_graph_canon(&g);
31     igraph_destroy(&g);
32 
33     printf("No ambassadors:\n");
34     IGRAPH_ASSERT(igraph_forest_fire_game(&g, /*number of vertices*/10, /*fw_prob*/ 0.0,
35                   /*bw_factor*/ 0.0, /*pambs*/0, /*directed*/ 0) == IGRAPH_SUCCESS);
36     print_graph_canon(&g);
37     igraph_destroy(&g);
38 
39     printf("More ambassadors than nodes:\n");
40     IGRAPH_ASSERT(igraph_forest_fire_game(&g, /*number of vertices*/5, /*fw_prob*/ 0.0,
41                   /*bw_factor*/ 0.0, /*pambs*/100, /*directed*/ 1) == IGRAPH_SUCCESS);
42     print_graph_canon(&g);
43     igraph_destroy(&g);
44 
45     printf("Some normal inputs, just to check for memory problems, no output checking.\n");
46     IGRAPH_ASSERT(igraph_forest_fire_game(&g, /*number of vertices*/50, /*fw_prob*/ 0.5,
47                   /*bw_factor*/ 0.5, /*pambs*/3, /*directed*/ 1) == IGRAPH_SUCCESS);
48     igraph_destroy(&g);
49 
50     VERIFY_FINALLY_STACK();
51     igraph_set_error_handler(igraph_error_handler_ignore);
52 
53     printf("Negative fw_prob.\n");
54     IGRAPH_ASSERT(igraph_forest_fire_game(&g, /*number of vertices*/5, /*fw_prob*/ -0.5,
55                   /*bw_factor*/ 0.0, /*pambs*/100, /*directed*/ 1) == IGRAPH_EINVAL);
56 
57     printf("Negative bw_factor.\n");
58     IGRAPH_ASSERT(igraph_forest_fire_game(&g, /*number of vertices*/5, /*fw_prob*/ 0.5,
59                   /*bw_factor*/ -0.5, /*pambs*/100, /*directed*/ 0) == IGRAPH_EINVAL);
60 
61     printf("Negative number of ambassadors.\n");
62     IGRAPH_ASSERT(igraph_forest_fire_game(&g, /*number of vertices*/5, /*fw_prob*/ 0.5,
63                   /*bw_factor*/ 0.5, /*pambs*/-100, /*directed*/ 1) == IGRAPH_EINVAL);
64 
65     VERIFY_FINALLY_STACK();
66     return 0;
67 }
68