File: Mongoose_UnitTest_EdgeSep_exe.cpp

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (146 lines) | stat: -rw-r--r-- 3,885 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//------------------------------------------------------------------------------
// Mongoose/Tests/Mongoose_UnitTest_EdgeSep_exe.cpp
//------------------------------------------------------------------------------

// Mongoose Graph Partitioning Library, Copyright (C) 2017-2018,
// Scott P. Kolodziej, Nuri S. Yeralan, Timothy A. Davis, William W. Hager
// Mongoose is licensed under Version 3 of the GNU General Public License.
// Mongoose is also available under other licenses; contact authors for details.
// SPDX-License-Identifier: GPL-3.0-only

//------------------------------------------------------------------------------


#define LOG_ERROR 1
#define LOG_WARN 1
#define LOG_INFO 0
#define LOG_TEST 1

#include "Mongoose_Test.hpp"
#include "Mongoose_Internal.hpp"
#include "Mongoose_IO.hpp"
#include "Mongoose_EdgeCut.hpp"

using namespace Mongoose;

int main(int argn, char** argv)
{
    (void)argn; // Unused variable
    (void)argv; // Unused variable

    SuiteSparse_start();

    // Set Logger to report all messages and turn off timing info
    Logger::setDebugLevel(All);
    Logger::setTimingFlag(false);

    // Test with NULL graph
    EdgeCut *result = edge_cut(NULL);
    assert(result == NULL);

    Graph *G = read_graph("../Matrix/bcspwr02.mtx");

    // Test with no options struct
    result = edge_cut(G);
    result->~EdgeCut();

    // Test with NULL options struct
    EdgeCut_Options *O = NULL;
    result = edge_cut(G, O);
    assert(result == NULL);

    O = EdgeCut_Options::create();

    // Test with invalid coarsen_limit
    O->coarsen_limit = 0;
    result = edge_cut(G, O);
    assert(result == NULL);
    O->coarsen_limit = 50;

    // Test with invalid high_degree_threshold
    O->high_degree_threshold = -1;
    result = edge_cut(G, O);
    assert(result == NULL);
    O->high_degree_threshold = 2.0;

    // Test with invalid num_dances
    O->num_dances = -1;
    result = edge_cut(G, O);
    assert(result == NULL);
    O->num_dances = 1;

    // Test with invalid FM_search_depth
    O->FM_search_depth = -1;
    result = edge_cut(G, O);
    assert(result == NULL);
    O->FM_search_depth = 50;

    // Test with invalid FM_consider_count
    O->FM_consider_count = -1;
    result = edge_cut(G, O);
    assert(result == NULL);
    O->FM_consider_count = 3;

    // Test with invalid FM_max_num_refinements
    O->FM_max_num_refinements = -1;
    result = edge_cut(G, O);
    assert(result == NULL);
    O->FM_max_num_refinements = 20;

    // Test with invalid gradproj_tolerance
    O->gradproj_tolerance = -1;
    edge_cut(G, O);
    O->gradproj_tolerance = 0.001;

    // Test with invalid gradproj_iteration_limit
    O->gradproj_iteration_limit = -1;
    result = edge_cut(G, O);
    assert(result == NULL);
    O->gradproj_iteration_limit = 50;

    // Test with invalid target_split
    O->target_split = 1.2;
    result = edge_cut(G, O);
    assert(result == NULL);
    O->target_split = 0.4;

    // Test with invalid tolerance
    O->soft_split_tolerance = -1;
    result = edge_cut(G, O);
    assert(result == NULL);
    O->soft_split_tolerance = 0.01;

    // Test with no QP
    O->use_QP_gradproj = false;
    result = edge_cut(G, O);
    assert(result->partition != NULL);
    result->~EdgeCut();
    O->use_QP_gradproj = true;

    // Test with no FM
    O->use_FM = false;
    result = edge_cut(G, O);
    assert(result->partition != NULL);
    result->~EdgeCut();
    O->use_FM = true;

    // Test with no coarsening
    O->coarsen_limit = 1E15;
    result = edge_cut(G, O);
    assert(result->partition != NULL);
    result->~EdgeCut();

    // Test with x = NULL (assume pattern matrix)
    G->x = NULL;
    result = edge_cut(G, O);
    assert(result->partition != NULL);
    result->~EdgeCut();
    O->coarsen_limit = 50;

    O->~EdgeCut_Options();
    G->~Graph();

    SuiteSparse_finish();

    return 0;
}