diff --git a/alib2graph_algo/src/generate/RandomGraphFactory.hpp b/alib2graph_algo/src/generate/RandomGraphFactory.hpp index c98981e0c89041524ae31652fc4fa2741b211367..9c3cc6d54bcd9c2005dc2587f33cbf6fc309d6c6 100644 --- a/alib2graph_algo/src/generate/RandomGraphFactory.hpp +++ b/alib2graph_algo/src/generate/RandomGraphFactory.hpp @@ -5,7 +5,7 @@ #include <alib/pair> #include <alib/vector> #include <alib/tuple> -#include <random> +#include <ext/random> namespace graph { @@ -40,9 +40,8 @@ RandomGraphFactory::randomGraph(unsigned long max_nodes, unsigned long branching_factor) { using node_type = typename TGraph::node_type; - // Seed with a real random value, if available - std::random_device r; - std::default_random_engine e1(r()); + // Seed with a random value, if available + std::default_random_engine e1(ext::random_devices::semirandom()); // Create distribution std::uniform_int_distribution<unsigned long> number_of_nodes(1, max_nodes); // Generate number of nodes @@ -97,9 +96,8 @@ RandomGraphFactory::randomWeightedGraph( using node_type = typename TGraph::node_type; using weight_type = typename TGraph::edge_type::weight_type; - // Seed with a real random value, if available - std::random_device r; - std::default_random_engine e1(r()); + // Seed with a random value, if available + std::default_random_engine e1(ext::random_devices::semirandom()); // Create distribution std::uniform_int_distribution<unsigned long> number_of_nodes(1, max_nodes); // Generate number of nodes diff --git a/alib2graph_algo/src/generate/RandomGridFactory.hpp b/alib2graph_algo/src/generate/RandomGridFactory.hpp index afc2f599f38348c258cab199a306bc10eff328e1..a2c68d4ae612c1d804f37875387c384bc5352808 100644 --- a/alib2graph_algo/src/generate/RandomGridFactory.hpp +++ b/alib2graph_algo/src/generate/RandomGridFactory.hpp @@ -5,7 +5,7 @@ #include <alib/pair> #include <alib/tuple> #include <alib/vector> -#include <random> +#include <ext/random> namespace graph { @@ -34,9 +34,8 @@ RandomGridFactory::randomGrid(unsigned long height, using coordinate_type = typename TGrid::coordinate_type; using node_type = typename TGrid::node_type; - // Seed with a real random value, if available - std::random_device r; - std::default_random_engine e1(r()); + // Seed with a random value, if available + std::default_random_engine e1(ext::random_devices::semirandom()); // Create distribution std::uniform_int_distribution<unsigned long> number_of_obstacles(0, max_obstacles); // Generate number of nodes diff --git a/alib2graph_algo/test-src/shortest_path/ShortestPathTest.cpp b/alib2graph_algo/test-src/shortest_path/ShortestPathTest.cpp index c07f6be76e76c2a456ee72f6aae2150d5497d261..5b542f20e723078fce6fda3f6837fab441c21718 100644 --- a/alib2graph_algo/test-src/shortest_path/ShortestPathTest.cpp +++ b/alib2graph_algo/test-src/shortest_path/ShortestPathTest.cpp @@ -343,6 +343,10 @@ TEST_CASE ( "Shortest Path", "[unit][graph][shortest_path]" ) { // --------------------------------------------------------------------------------------------------------------------- SECTION ( "All Grid Random" ) { + unsigned seed = ext::random_devices::random ( ); + ext::random_devices::semirandom.seed ( seed ); + INFO ( "seed: " << seed ); + auto graph_tuple = generate::RandomGridFactory::randomGrid<grid::WeightedSquareGrid8<long, edge::WeightedEdge<ext::pair<long, long>>>>(50, 50, 100); auto graph = std::get<0>(graph_tuple); auto start = std::get<1>(graph_tuple);