|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Compute the total cost (sum of arc weights) of a graph. More...
#include <tpl_graph_utils.H>
Public Member Functions | |
| Total_Cost (Distance __dist=Distance(), SA __sa=SA()) | |
| Distance::Distance_Type | total_cost (GT &g) |
| Compute the total cost. | |
| Distance::Distance_Type | operator() (GT &g) |
| void | reset () noexcept |
Reset the internal accumulator used by operator()(Arc*). | |
| Distance::Distance_Type | value () const noexcept |
Return the accumulated value (after using operator()(Arc*)). | |
| bool | operator() (typename GT::Arc *a) |
Private Attributes | |
| Distance | dist |
| SA | sa |
| Distance::Distance_Type | sum {} |
Compute the total cost (sum of arc weights) of a graph.
Iterates over all arcs of a graph (filtered by SA) and sums their distance/weight using the Distance accessor.
Two usage patterns:
total_cost(g) / operator()(g) to compute the sum for a whole graph.operator()(arc) as an accumulator with traversal utilities such as traverse_arcs(), then read the result via value().| GT | Graph type. |
| Distance | Distance accessor (defaults to Dft_Dist). |
| SA | Arc filter for Arc_Iterator. |
Definition at line 2090 of file tpl_graph_utils.H.
|
inline |
Definition at line 2098 of file tpl_graph_utils.H.
|
inline |
Definition at line 2117 of file tpl_graph_utils.H.
References Aleph::Total_Cost< GT, Distance, SA >::total_cost().
|
inline |
Definition at line 2134 of file tpl_graph_utils.H.
References Aleph::Total_Cost< GT, Distance, SA >::dist, Aleph::maps(), Aleph::Total_Cost< GT, Distance, SA >::sa, and Aleph::Total_Cost< GT, Distance, SA >::sum.
|
inlinenoexcept |
Reset the internal accumulator used by operator()(Arc*).
Definition at line 2123 of file tpl_graph_utils.H.
References Aleph::Total_Cost< GT, Distance, SA >::sum.
Referenced by TEST().
|
inline |
Compute the total cost.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 2105 of file tpl_graph_utils.H.
References Aleph::Total_Cost< GT, Distance, SA >::dist, Aleph::maps(), Aleph::Total_Cost< GT, Distance, SA >::sa, and Aleph::Total_Cost< GT, Distance, SA >::sum.
Referenced by Aleph::Total_Cost< GT, Distance, SA >::operator()(), and TEST().
|
inlinenoexcept |
Return the accumulated value (after using operator()(Arc*)).
Definition at line 2129 of file tpl_graph_utils.H.
References Aleph::Total_Cost< GT, Distance, SA >::sum.
Referenced by TEST().
|
private |
Definition at line 2092 of file tpl_graph_utils.H.
Referenced by Aleph::Total_Cost< GT, Distance, SA >::operator()(), and Aleph::Total_Cost< GT, Distance, SA >::total_cost().
|
private |
Definition at line 2093 of file tpl_graph_utils.H.
Referenced by Aleph::Total_Cost< GT, Distance, SA >::operator()(), and Aleph::Total_Cost< GT, Distance, SA >::total_cost().
|
private |
Definition at line 2094 of file tpl_graph_utils.H.
Referenced by Aleph::Total_Cost< GT, Distance, SA >::operator()(), Aleph::Total_Cost< GT, Distance, SA >::reset(), Aleph::Total_Cost< GT, Distance, SA >::total_cost(), and Aleph::Total_Cost< GT, Distance, SA >::value().