53 cout <<
"=== Bidirectional BFS Example ===" <<
endl <<
endl;
81 cout <<
"Social network (degrees of separation):" <<
endl
83 <<
" Alice --- Bob --- Charlie --- David" <<
endl
85 <<
" Eve --- Frank - Grace" <<
endl <<
endl;
92 cout <<
"Finding shortest paths:" <<
endl;
94 for (
auto [src, tgt] :
queries) {
96 bool found =
bibfs(g, src, tgt, path);
98 cout <<
" " << left << setw(12) << src->get_info()
99 <<
" to " << left << setw(12) << tgt->get_info()
103 path.
for_each_node([](
auto * n) { cout << n->get_info() <<
" "; });
111 cout <<
endl <<
"=== Performance ===" <<
endl
112 <<
"Time: O(b^(d/2))" <<
endl
113 <<
"Space: O(b^(d/2))" <<
endl
114 <<
"vs Standard BFS: O(b^d) both time and space" <<
endl;
Bidirectional BFS for shortest unweighted path.
Core header for the Aleph-w library.
Simple dynamic array with automatic resizing and functional operations.
Bidirectional BFS for finding shortest unweighted paths.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
void for_each_node(Operation op=Operation()) const
Execute an operation on each node of path.
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.
Generic graph and digraph implementations.