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_vector_int_t result;
24 igraph_matrix_t m_pdc, m_0, m_m34, m_m43;
25 int pdc[] = {9, 2, 7, 8,
26 6, 4, 3, 7,
27 5, 8, 1, 8,
28 7, 6, 9, 4};
29 int m34[] = {3, 3, 2, 3,
30 2, 3, 3, 3,
31 3, 2, 3, 3};
32 int m43[] = {3, 3, 2,
33 2, 3, 3,
34 3, 2, 3,
35 2, 3, 3};
36 igraph_vector_int_init(&result, 0);
37 matrix_init_int_row_major(&m_pdc, 4, 4, pdc);
38 matrix_init_int_row_major(&m_m34, 3, 4, m34);
39 matrix_init_int_row_major(&m_m43, 4, 3, m43);
40 igraph_matrix_init(&m_0, 0, 0);
41
42 printf("4 tasks, 4 agents:\n");
43 igraph_solve_lsap(&m_pdc, 4, &result);
44 print_vector_int(&result);
45
46 printf("\n0 tasks, 0 agents:\n");
47 igraph_solve_lsap(&m_0, 0, &result);
48 print_vector_int(&result);
49
50 VERIFY_FINALLY_STACK();
51 igraph_set_error_handler(igraph_error_handler_ignore);
52
53 printf("\n4 tasks, 3 agents, n = 4.\n");
54 IGRAPH_ASSERT(igraph_solve_lsap(&m_m34, 4, &result) == IGRAPH_EINVAL);
55
56 printf("\n3 tasks, 4 agents, n = 4.\n");
57 IGRAPH_ASSERT(igraph_solve_lsap(&m_m43, 4, &result) == IGRAPH_EINVAL);
58
59 igraph_vector_int_destroy(&result);
60 igraph_matrix_destroy(&m_pdc);
61 igraph_matrix_destroy(&m_0);
62 igraph_matrix_destroy(&m_m34);
63 igraph_matrix_destroy(&m_m43);
64
65 VERIFY_FINALLY_STACK();
66 return 0;
67 }
68