Approximation algorithm for calculating spanners. More...
#include <ogdf/graphalg/SpannerBerman.h>
Public Member Functions | |
SpannerBerman () | |
virtual | ~SpannerBerman () |
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 () |
Static Public Attributes | |
static Logger | logger |
Private Types | |
enum class | SeparationResult { NewConstraint , Fail , Solution } |
Used to indicate the result of the separation method. More... | |
Private Attributes | |
double | m_beta |
sqrt(n) | |
std::vector< CoinPackedVector * > | m_constraints |
Holds all constraints so they can be freed at destruction. | |
EdgeArray< bool > | m_E1 |
Holds the set E1 from the first part of the algorithm. | |
EdgeArray< bool > | m_E2 |
Holds the set E2 from the second part of the algorithm. | |
EpsilonTest | m_eps |
const Graph * | m_G |
const reference to the original graph | |
NodeArray< NodeArray< TWeight > > | m_inDistance |
m_inDistance[v][w]: distance from v in a v-rooted in-arborescense to w | |
EdgeArray< bool > | m_isThickEdge |
int | m_nSquared |
n^2 | |
int | m_OPT |
The current guess for our optimal LP value. | |
OsiSolverInterface * | m_osi |
the solver. | |
NodeArray< NodeArray< TWeight > > | m_outDistance |
m_outDistance[v][w]: distance from v in a v-rooted out-arborescense to w | |
EdgeArray< TWeight > | m_spannerWeight |
weights for m_spanner Caches, if an edge is thick (or thin). | |
double | m_sqrtlog |
sqrt(n) * ln(n) | |
int | m_thickEdgeNodeAmountLimit |
n/beta | |
EdgeArray< TWeight > | m_weight |
weights of each edge from m_G | |
Approximation algorithm for calculating spanners.
P. Berman, A. Bhattacharyya, K. Makarychev, S. Raskhodnikova und G. Yaroslavtsev. Approximation algorithms for spanner problems and Directed Steiner Forest. Information and Computation 222 (2013). 38th International Colloquium on Automata, Languages and Programming (ICALP 2011), S. 93–107. doi: https://doi.org/10.1016/j.ic. 2012.10.007.
Conditions for the graph:
The stretch \(s\) must satisfy: \(s\geq1\in\mathbb{R}\).
The preconditions can be checked with SpannerBerman::preconditionsOk.
Calculates a k-spanner with an approximation ratio of \(\mathcal{O}(n^{1/2}\log n)\) for the size. The graph can be directed and weighted. Undirected and/or unweighted graphs still preserve the approximation ratio.
To enable logging you have to set the log level of the algorithm's logger to Logger::Level::Default or below:
Definition at line 76 of file SpannerBerman.h.
|
strongprivate |
Used to indicate the result of the separation method.
Enumerator | |
---|---|
NewConstraint | |
Fail | |
Solution |
Definition at line 109 of file SpannerBerman.h.
|
inline |
Definition at line 80 of file SpannerBerman.h.
|
inlinevirtual |
Definition at line 85 of file SpannerBerman.h.
|
inlineprivate |
Actually calculates whether e
is thick or not.
Definition at line 338 of file SpannerBerman.h.
|
inlineprivate |
Add an edge to the spanner.
Only used in the first phase!
Definition at line 264 of file SpannerBerman.h.
|
inlineprivate |
Definition at line 392 of file SpannerBerman.h.
|
inlineprivate |
Definition at line 329 of file SpannerBerman.h.
|
inlineprivate |
Definition at line 583 of file SpannerBerman.h.
|
inlineprivate |
Definition at line 381 of file SpannerBerman.h.
|
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 183 of file SpannerBerman.h.
|
inlineprivate |
First part of the algorithm: Settle all thick edges.
Definition at line 209 of file SpannerBerman.h.
|
inlineprivate |
Calculates an in-arborescense rooted at root
.
Definition at line 246 of file SpannerBerman.h.
|
inlineoverrideprivatevirtual |
Initializes members and create an empty spanner.
Reimplemented from ogdf::SpannerModule< TWeight >.
Definition at line 157 of file SpannerBerman.h.
|
inlineprivate |
Shortcut for calling isSettledEdge with m_spanner and the current spanner weights.
Definition at line 367 of file SpannerBerman.h.
|
inlineprivate |
Definition at line 372 of file SpannerBerman.h.
|
inlineprivate |
Definition at line 139 of file SpannerBerman.h.
Definition at line 137 of file SpannerBerman.h.
|
inlineprivate |
Calculates an out-arborescense rooted at root
.
Definition at line 255 of file SpannerBerman.h.
|
inlineoverridevirtual |
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 88 of file SpannerBerman.h.
|
inlineprivate |
Definition at line 272 of file SpannerBerman.h.
|
inlineprivate |
Definition at line 574 of file SpannerBerman.h.
|
inlineprivate |
Resets the LP defining variables.
Deletes m_osi as well as every entry in m_constraints. Sets both variables to nullptr/empty list.
Definition at line 146 of file SpannerBerman.h.
|
inlineprivate |
The second part: Settling all thin edges.
Definition at line 410 of file SpannerBerman.h.
|
inlineprivate |
Definition at line 509 of file SpannerBerman.h.
Set a new value for m_OPT.
Logs about the new value and modifies the LP.
Definition at line 494 of file SpannerBerman.h.
|
static |
Definition at line 78 of file SpannerBerman.h.
|
private |
sqrt(n)
Definition at line 120 of file SpannerBerman.h.
|
private |
Holds all constraints so they can be freed at destruction.
Definition at line 132 of file SpannerBerman.h.
Holds the set E1 from the first part of the algorithm.
Definition at line 124 of file SpannerBerman.h.
Holds the set E2 from the second part of the algorithm.
Definition at line 125 of file SpannerBerman.h.
|
private |
Definition at line 135 of file SpannerBerman.h.
const reference to the original graph
Definition at line 111 of file SpannerBerman.h.
|
private |
m_inDistance[v][w]: distance from v in a v-rooted in-arborescense to w
Definition at line 127 of file SpannerBerman.h.
Definition at line 116 of file SpannerBerman.h.
|
private |
n^2
Definition at line 119 of file SpannerBerman.h.
|
private |
The current guess for our optimal LP value.
Definition at line 133 of file SpannerBerman.h.
|
private |
the solver.
Initial nullptr since it is initialized in the second phase.
Definition at line 131 of file SpannerBerman.h.
|
private |
m_outDistance[v][w]: distance from v in a v-rooted out-arborescense to w
Definition at line 128 of file SpannerBerman.h.
|
private |
weights for m_spanner Caches, if an edge is thick (or thin).
Use isThinEdge and isThickEdge for access. It is fully cached after calling calculateThickEdges
Definition at line 113 of file SpannerBerman.h.
|
private |
sqrt(n) * ln(n)
Definition at line 121 of file SpannerBerman.h.
|
private |
n/beta
Definition at line 122 of file SpannerBerman.h.
weights of each edge from m_G
Definition at line 112 of file SpannerBerman.h.