46 cout <<
"=== Zero_One_BFS Algorithm Example ===" <<
endl <<
endl;
62 cout <<
"Graph with 0/1 weights:" <<
endl
63 <<
" A ---(0)---> B" <<
endl
68 <<
" C ---(0)---> E" <<
endl <<
endl;
74 cout <<
"Shortest distances from A:" <<
endl;
75 cout << setw(8) <<
"Node" << setw(10) <<
"Distance" <<
endl;
78 for (
auto it = g.
get_node_it(); it.has_curr(); it.next())
80 auto node = it.get_curr();
81 auto dist =
bfs01.get_distance(node);
82 cout << setw(8) << node->get_info()
83 << setw(10) << dist <<
endl;
86 cout <<
endl <<
"=== Performance ===" <<
endl
87 <<
"Time complexity: O(V + E)" <<
endl
88 <<
"Space complexity: O(V)" <<
endl;
0-1 BFS shortest path algorithm.
Core header for the Aleph-w library.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
0-1 BFS algorithm for shortest paths in graphs with 0/1 weights.
void paint_min_paths_tree(const GT &g, Node *start)
Paints the shortest paths tree on the graph from start.
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
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.