Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Total_Cost< GT, Distance, SA > Class Template Reference

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)
 See total_cost.
 
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 {}
 

Detailed Description

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
class Aleph::Total_Cost< GT, Distance, SA >

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:

  • Call total_cost(g) / operator()(g) to compute the sum for a whole graph.
  • Use operator()(arc) as an accumulator with traversal utilities such as traverse_arcs(), then read the result via value().
Template Parameters
GTGraph type.
DistanceDistance accessor (defaults to Dft_Dist).
SAArc filter for Arc_Iterator.

Definition at line 2586 of file tpl_graph_utils.H.

Constructor & Destructor Documentation

◆ Total_Cost()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Aleph::Total_Cost< GT, Distance, SA >::Total_Cost ( Distance  __dist = Distance(),
SA  __sa = SA() 
)
inline

Definition at line 2594 of file tpl_graph_utils.H.

Member Function Documentation

◆ operator()() [1/2]

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Distance::Distance_Type Aleph::Total_Cost< GT, Distance, SA >::operator() ( GT &  g)
inline

See total_cost.

Definition at line 2613 of file tpl_graph_utils.H.

References Aleph::Total_Cost< GT, Distance, SA >::total_cost().

◆ operator()() [2/2]

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
bool Aleph::Total_Cost< GT, Distance, SA >::operator() ( typename GT::Arc *  a)
inline

◆ reset()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
void Aleph::Total_Cost< GT, Distance, SA >::reset ( )
inlinenoexcept

Reset the internal accumulator used by operator()(Arc*).

Definition at line 2619 of file tpl_graph_utils.H.

References Aleph::Total_Cost< GT, Distance, SA >::sum.

Referenced by TEST(), and TYPED_TEST().

◆ total_cost()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Distance::Distance_Type Aleph::Total_Cost< GT, Distance, SA >::total_cost ( GT &  g)
inline

◆ value()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Distance::Distance_Type Aleph::Total_Cost< GT, Distance, SA >::value ( ) const
inlinenoexcept

Return the accumulated value (after using operator()(Arc*)).

Definition at line 2625 of file tpl_graph_utils.H.

References Aleph::Total_Cost< GT, Distance, SA >::sum.

Referenced by TEST(), and TYPED_TEST().

Member Data Documentation

◆ dist

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Distance Aleph::Total_Cost< GT, Distance, SA >::dist
private

◆ sa

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
SA Aleph::Total_Cost< GT, Distance, SA >::sa
private

◆ sum

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Distance::Distance_Type Aleph::Total_Cost< GT, Distance, SA >::sum {}
private

The documentation for this class was generated from the following file: