File tree Expand file tree Collapse file tree
mt-kahypar/datastructures Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828
2929#include " dynamic_graph_factory.h"
3030
31+ #include < limits>
32+
3133#include < tbb/parallel_for.h>
3234#include < tbb/parallel_invoke.h>
3335
@@ -68,6 +70,13 @@ DynamicGraph DynamicGraphFactory::construct_from_graph_edges(
6870 const mt_kahypar_hyperedge_weight_t * edge_weight,
6971 const mt_kahypar_hypernode_weight_t * node_weight,
7072 const bool stable_construction_of_incident_edges) {
73+ if (num_edges > std::numeric_limits<HyperedgeID>::max () / 2 ) {
74+ std::string msg = std::string (" number of edges overflows ID range (note: graph edges are duplicated, require +1 bit)" );
75+ if constexpr (sizeof (HyperedgeID) < 8 ) {
76+ msg += " ; build with -DKAHYPAR_USE_64_BIT_IDS=ON to support larger ID ranges" ;
77+ }
78+ throw InvalidInputException (msg);
79+ }
7180 if (edge_vector.size () != num_edges) {
7281 throw InvalidInputException (" Number of edges does not match length of input data!" );
7382 }
Original file line number Diff line number Diff line change 2828
2929#include " static_graph_factory.h"
3030
31+ #include < limits>
32+
3133#include < tbb/parallel_for.h>
3234#include < tbb/parallel_invoke.h>
3335
@@ -95,6 +97,13 @@ namespace mt_kahypar::ds {
9597 const mt_kahypar_hyperedge_weight_t * edge_weight,
9698 const mt_kahypar_hypernode_weight_t * node_weight,
9799 const bool stable_construction_of_incident_edges) {
100+ if (num_edges > std::numeric_limits<HyperedgeID>::max () / 2 ) {
101+ std::string msg = std::string (" number of edges overflows ID range (note: graph edges are duplicated, require +1 bit)" );
102+ if constexpr (sizeof (HyperedgeID) < 8 ) {
103+ msg += " ; build with -DKAHYPAR_USE_64_BIT_IDS=ON to support larger ID ranges" ;
104+ }
105+ throw InvalidInputException (msg);
106+ }
98107 if (edge_vector.size () != num_edges) {
99108 throw InvalidInputException (" Number of edges does not match length of input data!" );
100109 }
You can’t perform that action at this time.
0 commit comments