38#include <gtest/gtest.h>
56 template <
class G,
class D,
class A>
64static bool should_run_stress()
66 return std::getenv(
"ALEPH_RUN_GRAPH_STRESS") !=
nullptr;
69static size_t stress_nodes()
71 const char *env = std::getenv(
"ALEPH_GRAPH_STRESS_NODES");
76 const unsigned long long v = std::strtoull(env, &end, 10);
77 if (end == env || *end !=
'\0')
80 return static_cast<size_t>(v);
84TEST(GraphStress, MillionNodeChain_DijkstraPaintOnly)
86 if (!should_run_stress())
87 GTEST_SKIP() <<
"Set ALEPH_RUN_GRAPH_STRESS=1 (and optionally ALEPH_GRAPH_STRESS_NODES=N) to enable.";
89 const size_t N = stress_nodes();
93 std::vector<Node *>
nodes;
96 for (
size_t i = 0; i <
N; ++i)
99 for (
size_t i = 0; i + 1 <
N; ++i)
103 const bool found = dij.paint_partial_min_paths_tree(g,
nodes.front(),
nodes.back());
106 const int dist = dij.get_distance(
nodes.back());
107 ASSERT_EQ(dist,
static_cast<int>(
N - 1));
Dijkstra's shortest path algorithm.
WeightedDigraph::Node Node
Generic directed graph (digraph) wrapper template.
Spanning tree calculation of all shortest paths from a given node according to Dijkstra's algorithm.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Number Theoretic Transform over Z / MOD Z.
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
Default filter for filtered iterators on arcs.
Arc of graph implemented with double-linked adjacency lists.
Filtered iterator of adjacent arcs of a node.
Generic graph and digraph implementations.