46 cout <<
"=== Dial's Algorithm Example ===" << endl << endl;
65 cout <<
"Delivery network with small integer weights:" << endl
66 <<
" A ---(2)---> B ---(1)---> D ---(2)---> F" << endl
68 <<
" (3) (3) (2)" << endl
71 <<
" C ---(2)---> E -------------------------+" << endl << endl;
77 cout <<
"Shortest distances from A:" << endl;
78 cout << left << setw(10) <<
"Node" << setw(8) <<
"Hours" << endl;
79 cout << setfill(
'-') << setw(18) <<
"-" << setfill(
' ') << endl;
81 for (
auto it = g.
get_node_it(); it.has_curr(); it.next())
83 auto node = it.get_curr();
85 cout << left << setw(10) << (char)node->get_info()
86 << setw(8) << dist << endl;
89 cout << endl <<
"=== Performance ===" << endl
90 <<
"Time: O(V + E + C)" << endl
91 <<
"Space: O(V + C)" << endl;
Dial's algorithm for shortest paths with small integer weights.
Core header for the Aleph-w library.
Dial's algorithm for shortest paths with integer weights.
Distance_Type get_distance(Node *node)
Gets the accumulated distance to a node after painting.
void paint_min_paths_tree(const GT &g, Node *start)
Paints the shortest paths tree on the graph from start.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
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.