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);
235 dij.paint_min_paths_tree(g, n0);
239 dij.get_min_path(n3, path);
260 dij.paint_min_paths_tree(g, n0);
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());
638 auto* n0 = g.insert_node(0);
639 auto* n1 = g.insert_node(1);
640 auto* n2 = g.insert_node(2);
642 g.insert_arc(n0, n1, 5);
643 g.insert_arc(n1, n2, 3);
647 int d =
dij(g, n0, n2, path);
665 dij.paint_min_paths_tree(g, n0);
694 dij.paint_min_paths_tree(g, n0);
734 bool found =
dij.paint_partial_min_paths_tree(g, n0, n2);
750 bool found =
dij.paint_partial_min_paths_tree(g, n0, n2);
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.
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)
Append a new item by copy.
constexpr bool is_empty() const noexcept
Return true if list is empty.
size_t size() const noexcept
Count the number of elements of the list.
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
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
GT::Arc * get_current_arc_ne() const noexcept
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
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.