@@ -19,6 +19,19 @@ const char *filenames[NTESTS] = {"random_weighted_bipartite2.mtx",
19
19
"lp_afiro_structure.mtx" , "sources_7.mtx" };
20
20
const uint64_t spranks [NTESTS ] = {298 , 2009 , 14 , 27 , 1 };
21
21
22
+ #if 0
23
+ #undef OK
24
+ #define OK (method ) \
25
+ { \
26
+ GrB_Info info2 = method ; \
27
+ if (info2 != GrB_SUCCESS) \
28
+ { \
29
+ printf ("info: %d, msg: %s\n", info2, msg) ; \
30
+ TEST_CHECK (false) ; \
31
+ } \
32
+ }
33
+ #endif
34
+
22
35
void test_MCM (void )
23
36
{
24
37
LAGraph_Init (msg );
@@ -32,6 +45,7 @@ void test_MCM(void)
32
45
for (uint64_t test = 0 ; test < NTESTS ; test ++ )
33
46
{
34
47
48
+ printf ("\n%s =======================\n" , filenames [test ]) ;
35
49
GrB_Matrix A = NULL ;
36
50
GrB_Matrix AT = NULL ;
37
51
snprintf (filename , LEN , LG_DATA_DIR "%s" , filenames [test ]);
@@ -71,12 +85,16 @@ void test_MCM(void)
71
85
OK (GrB_Vector_new (& mateC , GrB_UINT64 , ncols ));
72
86
73
87
GrB_Vector mateC_init = NULL ;
88
+ GrB_Vector mateR_init = NULL ;
74
89
75
90
if (!strcmp (filenames [test ], "lp_afiro_structure.mtx" ))
76
91
{
77
92
OK (GrB_Vector_new (& mateC_init , GrB_UINT64 , ncols ));
93
+ OK (GrB_Vector_new (& mateR_init , GrB_UINT64 , nrows ));
78
94
OK (GrB_Vector_setElement_UINT64 (
79
95
mateC_init , 0 , 19 )); // col 20 matched with row 1 (1-based)
96
+ OK (GrB_Vector_setElement_UINT64 (
97
+ mateR_init , 19 , 0 )); // col 20 matched with row 1 (1-based)
80
98
OK (GrB_Matrix_new (& AT , GrB_BOOL , ncols ,
81
99
nrows )); // transpose matrix has the reverse
82
100
// dimensions from the original
@@ -85,7 +103,7 @@ void test_MCM(void)
85
103
86
104
OK (LAGr_MaximumMatching (& mateC , NULL , A , AT , mateC_init , true,
87
105
msg ));
88
- printf ("\nmsg: %s\n" , msg );
106
+ // printf("\nmsg: %s\n", msg);
89
107
90
108
GrB_Index nmatched = 0 ;
91
109
@@ -105,6 +123,7 @@ void test_MCM(void)
105
123
// if nvals of mateC and mateR don't match, then there's at least
106
124
// one row that is used in at least one matching
107
125
TEST_CHECK (nmatched == nmateR );
126
+ printf ("# of matches: %" PRIu64 "\n" , nmatched ) ;
108
127
109
128
// pack matched values in a matrix
110
129
GrB_Matrix M = NULL ;
@@ -128,11 +147,44 @@ void test_MCM(void)
128
147
// sprank must be equal to nvals of mateC (nmatched)
129
148
TEST_CHECK (nmatched == spranks [test ]);
130
149
131
- OK (GrB_Vector_free (& mateC ));
132
- OK (GrB_Vector_free (& mateR ));
133
- OK (GrB_Matrix_free (& M ));
134
- OK (GrB_Matrix_free (& A ));
135
- OK (GrB_Matrix_free (& AT ));
150
+ OK (GrB_free (& mateC ));
151
+ OK (GrB_free (& mateR ));
152
+ OK (GrB_free (& M ));
153
+
154
+ // return both mateR and mateC
155
+ OK (LAGr_MaximumMatching (& mateC , & mateR , A , AT , mateC_init , true,
156
+ msg ));
157
+ GrB_Index nmateC = 0 ;
158
+ nmateR = 0 ;
159
+ OK (GrB_Vector_nvals (& nmateC , mateC ));
160
+ OK (GrB_Vector_nvals (& nmateR , mateR ));
161
+ TEST_CHECK (nmateC == nmateR );
162
+ TEST_CHECK (nmateC == nmatched );
163
+ OK (GrB_free (& mateC ));
164
+ OK (GrB_free (& mateR ));
165
+
166
+ // ensure AT exists, and pass in AT only, and use mateR_init
167
+ if (AT == NULL )
168
+ {
169
+ OK (GrB_Matrix_new (& AT , GrB_BOOL , ncols , nrows ));
170
+ OK (GrB_transpose (AT , NULL , NULL , A , NULL ));
171
+ }
172
+ OK (LAGr_MaximumMatching (& mateC , & mateR , NULL , AT , mateR_init , false,
173
+ msg ));
174
+ nmateC = 0 ;
175
+ nmateR = 0 ;
176
+ OK (GrB_Vector_nvals (& nmateC , mateC ));
177
+ OK (GrB_Vector_nvals (& nmateR , mateR ));
178
+ TEST_CHECK (nmateC == nmateR );
179
+ TEST_CHECK (nmateC == nmatched );
180
+ OK (GrB_free (& mateC ));
181
+ OK (GrB_free (& mateR ));
182
+
183
+ OK (GrB_free (& mateC_init ));
184
+ OK (GrB_free (& mateR_init ));
185
+ OK (GrB_free (& A ));
186
+ OK (GrB_free (& AT ));
187
+
136
188
}
137
189
}
138
190
LAGraph_Finalize (msg );
0 commit comments