Aleph-w 3.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)
 
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 2092 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 2100 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

◆ 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 2125 of file tpl_graph_utils.H.

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

Referenced by TEST().

◆ 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 ( GT &  g)
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 2107 of file tpl_graph_utils.H.

References Aleph::blossom_maximum_cardinality_matching(), Aleph::Total_Cost< GT, Distance, SA >::dist, 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().

◆ 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 2131 of file tpl_graph_utils.H.

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

Referenced by 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: