Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ogdf::SpannerIteratedWrapper< TWeight > Class Template Reference

A implementation-independed wrapper class to execute a spanner algorithm multiple times. More...

#include <ogdf/graphalg/SpannerIteratedWrapper.h>

+ Inheritance diagram for ogdf::SpannerIteratedWrapper< TWeight >:

Public Member Functions

 SpannerIteratedWrapper (SpannerModule< TWeight > *module, int maxIterations)
 Initializes the wrapper.
 
int getExecutedIterations ()
 
virtual bool preconditionsOk (const GraphAttributes &GA, double stretch, std::string &error) override
 
- Public Member Functions inherited from ogdf::SpannerModule< TWeight >
 SpannerModule ()
 Initializes a spanner module.
 
virtual ~SpannerModule ()
 
virtual ReturnType call (const GraphAttributes &GA, double stretch, GraphCopySimple &spanner, EdgeArray< bool > &inSpanner)
 Executes the algorithm.
 
int64_t getTimeNeeded ()
 
void setTimelimit (int64_t milliseconds)
 Sets the timelimit for the algorithm in milliseconds.
 
- Public Member Functions inherited from ogdf::Module
 Module ()
 Initializes a module.
 
virtual ~Module ()
 

Private Member Functions

virtual SpannerModule< TWeight >::ReturnType execute () override
 Executes the core algorithm.
 

Private Attributes

int m_iterations
 
const int m_maxIterations
 
std::unique_ptr< SpannerModule< TWeight > > m_module
 

Additional Inherited Members

- Public Types inherited from ogdf::Module
enum class  ReturnType { Feasible , Optimal , NoFeasibleSolution , TimeoutFeasible , TimeoutInfeasible , Error }
 The return type of a module. More...
 
- Static Public Member Functions inherited from ogdf::SpannerModule< TWeight >
static void apspSpanner (const GraphAttributes &GA, const GraphCopySimple &spanner, NodeArray< NodeArray< TWeight > > &shortestPathMatrix)
 Calculates an all-pair shortest-path on spanner with the weights given by GA.
 
static bool isMultiplicativeSpanner (const GraphAttributes &GA, const GraphCopySimple &spanner, double stretch)
 Validates a spanner.
 
- Static Public Member Functions inherited from ogdf::Module
static bool isSolution (ReturnType ret)
 Returns true iff ret indicates that the module returned a feasible solution.
 
- Protected Member Functions inherited from ogdf::SpannerModule< TWeight >
void assertTimeLeft ()
 Assert, that time is left.
 
int64_t getTimeLeft ()
 
int getWeight (const GraphAttributes &GA, edge e)
 
double getWeight (const GraphAttributes &GA, edge e)
 
virtual void init (const GraphAttributes &GA, double stretch, GraphCopySimple &spanner, EdgeArray< bool > &inSpanner)
 Initializes members and create an empty spanner.
 
bool isTimelimitEnabled ()
 
- Static Protected Member Functions inherited from ogdf::SpannerModule< TWeight >
static TWeight getWeight (const GraphAttributes &GA, edge e)
 
- Protected Attributes inherited from ogdf::SpannerModule< TWeight >
const GraphAttributesm_GA
 
EdgeArray< bool > * m_inSpanner
 
GraphCopySimplem_spanner
 
double m_stretch
 

Detailed Description

template<typename TWeight>
class ogdf::SpannerIteratedWrapper< TWeight >

A implementation-independed wrapper class to execute a spanner algorithm multiple times.

The amount of maximum iterations can be set. If this is reached or the optional timelimit is exceeded, the best solution so far is returned. The quality of the solution is determined by the sparsity of the spanner, namely the spanner with the least amount of edges regardless of whether the spanner is weighted or not.

If no valid solution was found and the timelimit is exceeded, SpannerModule::ReturnType::TimeoutInfeasible is returned. If all iterations are completed and no valid solution was found, SpannerModule::ReturnType::NoFeasibleSolution is returned. If an error happens, it is directly returned and the iterative execution aborted. If there is at least one valid result, the return type will be SpannerModule::ReturnType::Feasible and the spanner is valid.

Template Parameters
TWeightThe type of weights to get from GA

Definition at line 58 of file SpannerIteratedWrapper.h.

Constructor & Destructor Documentation

◆ SpannerIteratedWrapper()

template<typename TWeight >
ogdf::SpannerIteratedWrapper< TWeight >::SpannerIteratedWrapper ( SpannerModule< TWeight > *  module,
int  maxIterations 
)
inline

Initializes the wrapper.

Parameters
moduleThe algorithm implementation to use. It is internally put into a unique pointer, so this class will take care about the deletion of the algorithm.
maxIterationsThe maximum amount of alls to the algorithm.

Definition at line 67 of file SpannerIteratedWrapper.h.

Member Function Documentation

◆ execute()

template<typename TWeight >
virtual SpannerModule< TWeight >::ReturnType ogdf::SpannerIteratedWrapper< TWeight >::execute ( )
inlineoverrideprivatevirtual

Executes the core algorithm.

Called after initialization. This method is used for the timelimit, so do not forget to call assertTimeLeft from time to time.

Implements ogdf::SpannerModule< TWeight >.

Definition at line 87 of file SpannerIteratedWrapper.h.

◆ getExecutedIterations()

template<typename TWeight >
int ogdf::SpannerIteratedWrapper< TWeight >::getExecutedIterations ( )
inline
Returns
the amount of iterations during the last call of the wrapper.

Definition at line 79 of file SpannerIteratedWrapper.h.

◆ preconditionsOk()

template<typename TWeight >
virtual bool ogdf::SpannerIteratedWrapper< TWeight >::preconditionsOk ( const GraphAttributes GA,
double  stretch,
std::string &  error 
)
inlineoverridevirtual

Returns
true, if the given GA and stretch are valid for a specific algorithm. If not, an error message is provided via error

Implements ogdf::SpannerModule< TWeight >.

Definition at line 71 of file SpannerIteratedWrapper.h.

Member Data Documentation

◆ m_iterations

template<typename TWeight >
int ogdf::SpannerIteratedWrapper< TWeight >::m_iterations
private

Definition at line 84 of file SpannerIteratedWrapper.h.

◆ m_maxIterations

template<typename TWeight >
const int ogdf::SpannerIteratedWrapper< TWeight >::m_maxIterations
private

Definition at line 83 of file SpannerIteratedWrapper.h.

◆ m_module

template<typename TWeight >
std::unique_ptr<SpannerModule<TWeight> > ogdf::SpannerIteratedWrapper< TWeight >::m_module
private

Definition at line 82 of file SpannerIteratedWrapper.h.


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