Skip to content

Commit

Permalink
fix % 0 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghwak committed Dec 1, 2023
1 parent c6aa981 commit 0766cfb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpp/tests/structure/mg_select_random_vertices_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Tests_MGSelectRandomVertices
std::iota(
h_given_set.begin(), h_given_set.end(), mg_graph_view.local_vertex_partition_range_first());
std::shuffle(h_given_set.begin(), h_given_set.end(), std::mt19937{std::random_device{}()});
h_given_set.resize(std::rand() % mg_graph_view.local_vertex_partition_range_size() + 1);
h_given_set.resize(std::rand() % (mg_graph_view.local_vertex_partition_range_size() + 1));

// Compute size of the distributed vertex set
int num_of_elements_in_given_set = static_cast<int>(h_given_set.size());
Expand All @@ -105,7 +105,7 @@ class Tests_MGSelectRandomVertices
size_t select_count =
num_of_elements_in_given_set > select_random_vertices_usecase.select_count
? select_random_vertices_usecase.select_count
: std::rand() % num_of_elements_in_given_set + 1;
: std::rand() % (num_of_elements_in_given_set + 1);

for (int idx = 0; idx < with_replacement_flags.size(); idx++) {
bool with_replacement = with_replacement_flags[idx];
Expand Down

0 comments on commit 0766cfb

Please sign in to comment.