9# include <gtest/gtest.h>
50 int d = bfs(g, n0, n3, path);
74 int d = bfs(g, n0, n3, path);
96 int d = bfs(g, n0, n3, path);
112 int d = bfs(g, n0, n0, path);
133 int d = bfs(g, n0, n2, path);
135 EXPECT_EQ(d, std::numeric_limits<int>::max());
149 int d = bfs(g, n0, n0, path);
173 int d = bfs(g, n0, n4, path);
201 int d = bfs(g, n0, n3, path);
217 EXPECT_THROW(bfs(g,
nullptr, n0, path), std::domain_error);
218 EXPECT_THROW(bfs(g, n0,
nullptr, path), std::domain_error);
343 int d = bfs(g, n0, n3, path);
379 int d = bfs(g, n0, n3, path);
404 int d = bfs(g, n0, n3, path);
416 auto n0 = g.insert_node(0);
417 auto n1 = g.insert_node(1);
418 auto n2 = g.insert_node(2);
420 g.insert_arc(n0, n1, 1);
421 g.insert_arc(n1, n2, 0);
425 int d = bfs(g, n0, n2, path);
436 auto n0 = g.insert_node(0);
437 auto n1 = g.insert_node(1);
439 g.insert_arc(n0, n1, 1);
449 EXPECT_EQ(d2, std::numeric_limits<int>::max());
468 int d1 = bfs(g, n0, n2, p1);
472 int d2 = bfs(g, n2, n0, p2);
485 for (
int i = 0; i <
N; ++i)
489 for (
int i = 0; i <
N - 1; ++i)
586 for (
int r = 0;
r < 3; ++
r)
587 for (
int c = 0; c < 3; ++c)
608 int d = bfs(g,
grid[0][0],
grid[2][2], path);
627 int d = bfs(g, n0, n1, path);
645 int d = bfs(g, n0, n1, path);
725 for (
int i = 0; i <
N; ++i)
729 for (
int i = 0; i <
N - 1; ++i)
770 for (GT::Arc_Iterator it(g); it.has_curr(); it.next())
Dijkstra's shortest path algorithm.
0-1 BFS shortest path algorithm.
WeightedDigraph::Node Node
static Array create(size_t n)
Create an array with n logical elements.
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.
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< int > Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Iterator on nodes and arcs of a path.
bool is_empty() const noexcept
Return true if the path is empty.
0-1 BFS algorithm for shortest paths in graphs with 0/1 weights.
bool is_painted() const noexcept
Check if a computation has been performed.
GT * get_graph() const noexcept
Get the graph of the last computation.
Distance_Type get_min_path(Node *end, Path< GT > &path)
Extracts a shortest path from a previously painted graph.
void paint_min_paths_tree(const GT &g, Node *start)
Paints the shortest paths tree on the graph from start.
Distance_Type get_distance(Node *node)
Gets the accumulated distance to a node after painting.
Node * get_start_node() const noexcept
Get the start node of the last computation.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
DynArray< Graph::Node * > nodes
#define IS_NODE_VISITED(p, bit)
Determine whether the control bit is set or not to one.
#define NODE_COOKIE(p)
Return the node cookie
#define IS_ARC_VISITED(p, bit)
Determine whether the bit field is or not set to one.
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.
Arc of graph implemented with double-linked adjacency lists.
List_Graph< Graph_Node< int >, Graph_Arc< int > > GT
Array-based graph implementation.
Generic graph and digraph implementations.
Simple graph implementation with adjacency lists.