Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ogdf::SpannerKortsarzPeleg< TWeight > Class Template Reference

Approximation multiplicative 2-spanner calculation. More...

#include <ogdf/graphalg/SpannerKortsarzPeleg.h>

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

Public Member Functions

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. More...
 
virtual ~SpannerModule ()
 
virtual ReturnType call (const GraphAttributes &GA, double stretch, GraphCopySimple &spanner, EdgeArray< bool > &inSpanner)
 Executes the algorithm. More...
 
int64_t getTimeNeeded ()
 
void setTimelimit (int64_t milliseconds)
 Sets the timelimit for the algorithm in milliseconds. More...
 
- Public Member Functions inherited from ogdf::Module
 Module ()
 Initializes a module. More...
 
virtual ~Module ()
 

Private Member Functions

void addToSpanner (edge e)
 Adds e from m_G to the spanner and sets inSpanner. More...
 
virtual SpannerModule< TWeight >::ReturnType execute () override
 Executes the core algorithm. More...
 
virtual void init (const GraphAttributes &GA, double stretch, GraphCopySimple &spanner, EdgeArray< bool > &inSpanner) override
 Initializes members and create an empty spanner. More...
 

Private Attributes

EpsilonTest m_eps
 
GraphCopySimple m_G
 The copy of GA.constGraph() to work on. Edges will be removed in each iteration. More...
 

Additional Inherited Members

- Public Types inherited from ogdf::Module
enum  ReturnType { ReturnType::Feasible, ReturnType::Optimal, ReturnType::NoFeasibleSolution, ReturnType::TimeoutFeasible, ReturnType::TimeoutInfeasible, ReturnType::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. More...
 
static bool isMultiplicativeSpanner (const GraphAttributes &GA, const GraphCopySimple &spanner, double stretch)
 Validates a spanner. More...
 
- 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. More...
 
- Protected Member Functions inherited from ogdf::SpannerModule< TWeight >
void assertTimeLeft ()
 Assert, that time is left. More...
 
int64_t getTimeLeft ()
 
int getWeight (const GraphAttributes &GA, edge e)
 
double getWeight (const GraphAttributes &GA, edge e)
 
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::SpannerKortsarzPeleg< TWeight >

Approximation multiplicative 2-spanner calculation.

G. Kortsarz und D. Peleg. Generating Sparse 2-Spanners. Journal of Algorithms 17.2 (1994), S. 222–236. doi: https://doi.org/10.1006/jagm.1994.1032.

Conditions for the graph:

  • simple
  • undirected
  • unweighted

The stretch \(s\) must satisfy: \(s=2\).

The preconditions can be checked with SpannerKortsarzPeleg::preconditionsOk.

Calculates a 2-spanner with an approximation ratio \(\mathcal{O}(|E|/|V|)\). The runtime is \(\mathcal{O}(m^2n^2\log(n^2/m))\) (given in the paper).

The implemented runtime can be bound by \(\mathcal{O}(nm\cdot MDS(n, m))\) with \(MDS(n, m)\) being the runtime for the maximumDensitySubgraph implementation. The used implementation has a runtime of \(\mathcal{O}(mn^2\log n)\) so this implementation has a runtime of \(\mathcal{O}(m^2n^3\log n)\).

Note that the practical runtime is not as high since the MDS-problem is only called for neighbor-graphs of a vertex. For sparse graphs, these subgraphs typically are not as huge as the input graph. But remember: For complete graphs, the running time will approach the upper bound given in the O-notation.

Definition at line 84 of file SpannerKortsarzPeleg.h.

Member Function Documentation

◆ addToSpanner()

template<typename TWeight >
void ogdf::SpannerKortsarzPeleg< TWeight >::addToSpanner ( edge  e)
inlineprivate

Adds e from m_G to the spanner and sets inSpanner.

Definition at line 216 of file SpannerKortsarzPeleg.h.

◆ execute()

template<typename TWeight >
virtual SpannerModule<TWeight>::ReturnType ogdf::SpannerKortsarzPeleg< 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 120 of file SpannerKortsarzPeleg.h.

◆ init()

template<typename TWeight >
virtual void ogdf::SpannerKortsarzPeleg< TWeight >::init ( const GraphAttributes GA,
double  stretch,
GraphCopySimple spanner,
EdgeArray< bool > &  inSpanner 
)
inlineoverrideprivatevirtual

Initializes members and create an empty spanner.

Reimplemented from ogdf::SpannerModule< TWeight >.

Definition at line 113 of file SpannerKortsarzPeleg.h.

◆ preconditionsOk()

template<typename TWeight >
virtual bool ogdf::SpannerKortsarzPeleg< 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 91 of file SpannerKortsarzPeleg.h.

Member Data Documentation

◆ m_eps

template<typename TWeight >
EpsilonTest ogdf::SpannerKortsarzPeleg< TWeight >::m_eps
private

Definition at line 87 of file SpannerKortsarzPeleg.h.

◆ m_G

template<typename TWeight >
GraphCopySimple ogdf::SpannerKortsarzPeleg< TWeight >::m_G
private

The copy of GA.constGraph() to work on. Edges will be removed in each iteration.

Definition at line 86 of file SpannerKortsarzPeleg.h.


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