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<class GT, class Distance = Dft_Dist<GT>, class 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 2090 of file tpl_graph_utils.H.

Constructor & Destructor Documentation

◆ Total_Cost()

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

Definition at line 2098 of file tpl_graph_utils.H.

Member Function Documentation

◆ operator()() [1/2]

template<class GT , class Distance = Dft_Dist<GT>, class SA = Dft_Show_Arc<GT>>
Distance::Distance_Type Aleph::Total_Cost< GT, Distance, SA >::operator() ( GT g)
inline

◆ operator()() [2/2]

◆ reset()

template<class GT , class Distance = Dft_Dist<GT>, class 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 2123 of file tpl_graph_utils.H.

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

Referenced by TEST().

◆ total_cost()

template<class GT , class Distance = Dft_Dist<GT>, class 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 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().

◆ value()

template<class GT , class Distance = Dft_Dist<GT>, class 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 2129 of file tpl_graph_utils.H.

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

Referenced by TEST().

Member Data Documentation

◆ dist

template<class GT , class Distance = Dft_Dist<GT>, class SA = Dft_Show_Arc<GT>>
Distance Aleph::Total_Cost< GT, Distance, SA >::dist
private

◆ sa

template<class GT , class Distance = Dft_Dist<GT>, class SA = Dft_Show_Arc<GT>>
SA Aleph::Total_Cost< GT, Distance, SA >::sa
private

◆ sum


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