13#include <gtest/gtest.h>
22template <
class GT,
class SA = Dft_Show_Arc<GT>>
47 template <
class G,
class D,
class A>
53 template <
class G,
class D,
class A>
57template <
typename HeapTag,
typename Graph>
63template <
typename HeapTag,
typename Graph>
68template <
typename HeapTag>
71template <
typename HeapTag>
74template <
typename HeapTag>
77template <
typename HeapTag>
80template <
typename HeapTag>
83using HeapTypes = ::testing::Types<BinHeapTag, FibHeapTag>;
109 double d =
dij(g, n0, n3, path);
137 double d =
dij(g, n0, n0, path);
141 EXPECT_EQ(d, std::numeric_limits<double>::max());
155 double d =
dij(g, n0, n1, path);
157 EXPECT_EQ(d, std::numeric_limits<double>::max());
203 double d =
dij(g, n0, n1, path);
239 dij.get_min_path(n3, path);
263 dij.copy_painted_min_paths_tree(g, tree);
296 double d =
dij(g, n0, n3, path);
319 double d =
dij(g, n0, n3, path);
335 double d =
dij(g, n0, n1, path);
343 DNode* n0 = g.insert_node(0);
344 DNode* n1 = g.insert_node(1);
345 DNode* n2 = g.insert_node(2);
347 g.insert_arc(n0, n1, 1.0);
348 g.insert_arc(n1, n2, 1.0);
353 double d =
dij(g, n0, n2, path);
361 DNode* n0 = g.insert_node(0);
362 DNode* n1 = g.insert_node(1);
364 g.insert_arc(n0, n1, 1.0);
374 EXPECT_EQ(d2, std::numeric_limits<double>::max());
408 double d =
dij(g, n0, n3, path);
426 double d =
dij(g, n0, n2, path);
443 double d =
dij(g, n0, n2, path);
460 double d =
dij(g, n0, n2, path);
481 dij(g, center, tree);
502 double d =
dij(g, n0, n3, path);
536 dij.paint_min_paths_tree(g, n0);
560 dij.compute_partial_min_paths_tree(g, n0, n3, tree);
590 double d =
dij(g, n0, n3, path);
604 EXPECT_THROW(
dij.compute_min_paths_tree(g,
nullptr, tree), std::domain_error);
605 EXPECT_THROW(
dij.compute_partial_min_paths_tree(g,
nullptr, n0, tree), std::domain_error);
606 EXPECT_THROW(
dij.compute_partial_min_paths_tree(g, n0,
nullptr, tree), std::domain_error);
608 EXPECT_THROW(
dij.paint_partial_min_paths_tree(g,
nullptr, n0), std::domain_error);
609 EXPECT_THROW(
dij.paint_partial_min_paths_tree(g, n0,
nullptr), std::domain_error);
626 double d =
dij(g, n0, n3, path);
629 EXPECT_EQ(d, std::numeric_limits<double>::max());
647 int d =
dij(g, n0, n2, path);
756 double d =
dij.get_min_path(n2, path);
765 std::vector<Node*>
nodes(
N);
766 for (
int i = 0; i <
N; ++i)
769 for (
int i = 0; i <
N - 1; ++i)
784 std::vector<Node*>
nodes(
N);
785 for (
int i = 0; i <
N; ++i)
789 for (
int i = 0; i <
N; ++i)
790 for (
int j = i + 1; j <
N; ++j)
814 dij.compute_min_paths_tree(g, n0, tree);
839 GTEST_SKIP() <<
"Graph type does not support parallel arcs (multigraph)";
844 double d =
dij(g, n0, n2, path);
863 GTEST_SKIP() <<
"Graph type does not support parallel arcs (multigraph)";
868 double d =
dij(g, n0, n1, path);
895 GTEST_SKIP() <<
"Graph type does not support parallel arcs (multigraph)";
900 double d =
dij(g, n0, n3, path);
968 dij.compute_min_paths_tree(g, n0, tree);
973 double d1 =
dij.get_min_path(tree, n1, p1);
974 double d2 =
dij.get_min_path(tree, n2, p2);
975 double d3 =
dij.get_min_path(tree, n3, p3);
990 ::testing::InitGoogleTest(&
argc,
argv);
Dijkstra's shortest path algorithm.
::testing::Types< BinHeapTag, FibHeapTag > HeapTypes
WeightedDigraph::Node Node
auto get_current_arc() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Generic directed graph (digraph) wrapper template.
typename BaseGraph::Arc Arc
typename BaseGraph::Node Node
Spanning tree calculation of all shortest paths from a given node according to Dijkstra's algorithm.
void paint_min_paths_tree(const GT &g, typename GT::Node *start)
Paints on graph g the spanning tree of all shortest paths starting from start.
bool paint_partial_min_paths_tree(const GT &g, typename GT::Node *start, typename GT::Node *end)
Paints on graph g the partial shortest paths tree starting from start and stopping when the end node ...
bool has_curr() const noexcept
Return true if the iterator has current item.
void next()
Move the iterator one item forward.
Dynamic singly linked list with functional programming support.
T & append(const T &item)
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Graph_Node< int > Node
The graph type.
Graph_Arc< double > Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Filtered iterator for outcoming arcs of a node.
Iterator on nodes and arcs of a path.
Node * get_current_node() const
Return the current node of a path.
size_t size() const noexcept
Return the path length in nodes.
bool is_empty() const noexcept
Return true if the path is empty.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
constexpr size_t get_num_arcs() const noexcept
GT::Arc * get_current_arc_ne() const noexcept
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Default filter for filtered iterators on arcs.
Filtered iterator of adjacent arcs of a node.
TYPED_TEST(DijkstraHeapTest, BasicShortestPath)
TYPED_TEST_SUITE(DijkstraHeapTest, HeapTypes)
Generic graph and digraph implementations.