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;
76 cout << setfill(
'-') << setw(18) <<
"-" << setfill(
' ') << endl;
78 for (
auto it = g.
get_node_it(); it.has_curr(); it.next())
80 auto node = it.get_curr();
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.
Distance_Type get_distance(Node *node)
Gets the accumulated distance to a node after painting.
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
Main namespace for Aleph-w library functions.
Arc of graph implemented with double-linked adjacency lists.
Generic graph and digraph implementations.