@@ -167,8 +167,8 @@ namespace mt_kahypar {
167167 TEST (MtKaHyPar, StaticHypergraphConstructionHandlesErrors) {
168168 mt_kahypar_error_t error;
169169 mt_kahypar_context_t * context = mt_kahypar_context_from_preset (DEFAULT );
170- const mt_kahypar_hypernode_id_t num_vertices = 7 ;
171- const mt_kahypar_hyperedge_id_t num_hyperedges = 4 ;
170+ mt_kahypar_hypernode_id_t num_vertices = 7 ;
171+ mt_kahypar_hyperedge_id_t num_hyperedges = 4 ;
172172
173173 std::unique_ptr<size_t []> hyperedge_indices = std::make_unique<size_t []>(5 );
174174 hyperedge_indices[0 ] = 0 ; hyperedge_indices[1 ] = 2 ; hyperedge_indices[2 ] = 6 ;
@@ -210,6 +210,23 @@ namespace mt_kahypar {
210210 attempt_construction (" giant HE" );
211211 hyperedge_indices[4 ] = 12 ;
212212
213+ if constexpr (sizeof (HypernodeID) < 8 ) {
214+ hyperedges[3 ] = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 1 ;
215+ attempt_construction (" overflow pin" );
216+ hyperedges[3 ] = 1 ;
217+
218+ hyperedge_indices[4 ] = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 13 ;
219+ attempt_construction (" overflow HE index" );
220+ hyperedge_indices[4 ] = 12 ;
221+
222+ num_vertices = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 8 ;
223+ attempt_construction (" overflow num vertices" );
224+ num_vertices = 7 ;
225+
226+ num_hyperedges = static_cast <mt_kahypar_hyperedge_id_t >(std::numeric_limits<HyperedgeID>::max ()) + 5 ;
227+ attempt_construction (" overflow num hyperedges" );
228+ }
229+
213230 mt_kahypar_free_hypergraph (hypergraph);
214231 }
215232
@@ -245,8 +262,8 @@ namespace mt_kahypar {
245262 TEST (MtKaHyPar, DynamicHypergraphConstructionHandlesErrors) {
246263 mt_kahypar_error_t error;
247264 mt_kahypar_context_t * context = mt_kahypar_context_from_preset (HIGHEST_QUALITY );
248- const mt_kahypar_hypernode_id_t num_vertices = 7 ;
249- const mt_kahypar_hyperedge_id_t num_hyperedges = 4 ;
265+ mt_kahypar_hypernode_id_t num_vertices = 7 ;
266+ mt_kahypar_hyperedge_id_t num_hyperedges = 4 ;
250267
251268 std::unique_ptr<size_t []> hyperedge_indices = std::make_unique<size_t []>(5 );
252269 hyperedge_indices[0 ] = 0 ; hyperedge_indices[1 ] = 2 ; hyperedge_indices[2 ] = 6 ;
@@ -288,6 +305,23 @@ namespace mt_kahypar {
288305 attempt_construction (" giant HE" );
289306 hyperedge_indices[4 ] = 12 ;
290307
308+ if constexpr (sizeof (HypernodeID) < 8 ) {
309+ hyperedges[3 ] = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 1 ;
310+ attempt_construction (" overflow pin" );
311+ hyperedges[3 ] = 1 ;
312+
313+ hyperedge_indices[4 ] = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 13 ;
314+ attempt_construction (" overflow HE index" );
315+ hyperedge_indices[4 ] = 12 ;
316+
317+ num_vertices = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 8 ;
318+ attempt_construction (" overflow num vertices" );
319+ num_vertices = 7 ;
320+
321+ num_hyperedges = static_cast <mt_kahypar_hyperedge_id_t >(std::numeric_limits<HyperedgeID>::max ()) + 5 ;
322+ attempt_construction (" overflow num hyperedges" );
323+ }
324+
291325 mt_kahypar_free_hypergraph (hypergraph);
292326 }
293327
@@ -320,8 +354,8 @@ namespace mt_kahypar {
320354 TEST (MtKaHyPar, StaticGraphConstructionHandlesErrors) {
321355 mt_kahypar_error_t error;
322356 mt_kahypar_context_t * context = mt_kahypar_context_from_preset (DEFAULT );
323- const mt_kahypar_hypernode_id_t num_vertices = 5 ;
324- const mt_kahypar_hyperedge_id_t num_hyperedges = 6 ;
357+ mt_kahypar_hypernode_id_t num_vertices = 5 ;
358+ mt_kahypar_hyperedge_id_t num_hyperedges = 6 ;
325359
326360 std::unique_ptr<mt_kahypar_hypernode_id_t []> edges =
327361 std::make_unique<mt_kahypar_hypernode_id_t []>(12 );
@@ -347,6 +381,15 @@ namespace mt_kahypar {
347381 edges[2 ] = 2 ;
348382 attempt_construction (" self loop" );
349383
384+ if constexpr (sizeof (HypernodeID) < 8 ) {
385+ edges[2 ] = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 1 ;
386+ attempt_construction (" overflow node ID" );
387+ edges[2 ] = 0 ;
388+
389+ num_vertices = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 6 ;
390+ attempt_construction (" overflow num nodes" );
391+ }
392+
350393 mt_kahypar_free_hypergraph (graph);
351394 }
352395
@@ -379,8 +422,8 @@ namespace mt_kahypar {
379422 TEST (MtKaHyPar, DynamicGraphConstructionHandlesErrors) {
380423 mt_kahypar_error_t error;
381424 mt_kahypar_context_t * context = mt_kahypar_context_from_preset (HIGHEST_QUALITY );
382- const mt_kahypar_hypernode_id_t num_vertices = 5 ;
383- const mt_kahypar_hyperedge_id_t num_hyperedges = 6 ;
425+ mt_kahypar_hypernode_id_t num_vertices = 5 ;
426+ mt_kahypar_hyperedge_id_t num_hyperedges = 6 ;
384427
385428 std::unique_ptr<mt_kahypar_hypernode_id_t []> edges =
386429 std::make_unique<mt_kahypar_hypernode_id_t []>(12 );
@@ -406,6 +449,15 @@ namespace mt_kahypar {
406449 edges[2 ] = 2 ;
407450 attempt_construction (" self loop" );
408451
452+ if constexpr (sizeof (HypernodeID) < 8 ) {
453+ edges[2 ] = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 1 ;
454+ attempt_construction (" overflow node ID" );
455+ edges[2 ] = 0 ;
456+
457+ num_vertices = static_cast <mt_kahypar_hypernode_id_t >(std::numeric_limits<HypernodeID>::max ()) + 6 ;
458+ attempt_construction (" overflow num nodes" );
459+ }
460+
409461 mt_kahypar_free_hypergraph (graph);
410462 }
411463
0 commit comments