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;
81 for (
auto it = g.
get_node_it(); it.has_curr(); it.next())
83 auto node = it.get_curr();
84 auto dist =
dial.get_distance(node);
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.
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.
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.