105template<
typename TWeight>
144 std::string& error)
override {
146 error =
"The graph must be undirected";
150 if (std::modf(stretch, &integralPart) != 0.0) {
151 error =
"The stretch is required to be an integer, not " + to_string(stretch);
154 int intStretch =
static_cast<int>(stretch);
155 if (intStretch < 1) {
156 error =
"The stretch must be >= 1.0";
159 if (intStretch % 2 == 0) {
160 error =
"The stretch must be odd";
164 error =
"The graph must be unweighted";
217 while (!queue.
empty()) {
219 int distance = bfsNode.
depth + 1;
222 node u = adj->twinNode();
232 values[u] =
r[u] - distance;
235 if (distance <
m_k) {
246 double maxValue = std::numeric_limits<double>::lowest();
256 if (values[u] != std::numeric_limits<double>::lowest()
257 &&
m_eps.
geq(values[u], maxValue)) {
258 edge e = firstEdge[u];
261 (*m_inSpanner)[e] =
true;
294template<
typename TWeight>
Compare floating point numbers with epsilons and integral numbers with normal compare operators.
Includes declaration of graph class.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Decralation of GraphElement and GraphList classes.
A wrapper class for iterating calls to spanner algorithms.
Basic module for spanner algorithms.
Declaration and implementation of list-based queues (classes QueuePure<E> and Queue<E>).
Basic declarations, included by all source files.
Class for adjacency list elements.
Class for the representation of edges.
std::enable_if< std::is_integral< T >::value, bool >::type geq(const T &x, const T &y) const
Compare if x is GEQ to y for integral types.
Stores additional attributes of a graph (like layout information).
bool directed() const
Returns if the graph is directed.
const Graph & constGraph() const
Returns a reference to the associated graph.
static const long edgeDoubleWeight
Corresponds to edge attribute doubleWeight(edge).
bool has(long attr) const
Returns true iff all attributes in attr are available.
static const long edgeIntWeight
Corresponds to edge attribute intWeight(edge).
Copies of graphs with mapping between nodes and edges.
edge newEdge(edge eOrig)
Creates a new edge in the graph copy with original edge eOrig.
Data type for general directed graphs (adjacency list representation).
int numberOfNodes() const
Returns the number of nodes in the graph.
int numberOfEdges() const
Returns the number of edges in the graph.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
ReturnType
The return type of a module.
Class for the representation of nodes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Implementation of list-based queues.
iterator emplace(Args &&... args)
Adds a new element at the end of the queue.
bool empty() const
Returns true iff the queue is empty.
E pop()
Removes front element and returns it.
Randomized multiplicative spanner calculation by propagating random messages through the graph.
int m_intStretch
m_stretch, but as an integer
double m_c
the parameter for the exponential distribution.
double m_beta
The parameter for the exponential distribution.
virtual SpannerModule< TWeight >::ReturnType execute() override
Executes the core algorithm.
virtual void init(const GraphAttributes &GA, double stretch, GraphCopySimple &spanner, EdgeArray< bool > &inSpanner) override
Initializes members and create an empty spanner.
int m_k
the parameter k derived from the stretch
virtual bool preconditionsOk(const GraphAttributes &GA, double stretch, std::string &error) override
void setEpsilon(double epsilon)
Sets the epsilon for this algorithm.
const Graph * m_G
The original graph.
const double DEFAULT_EPSILON
The default value for epsilon.
SpannerElkinNeiman(double epsilon)
Use the ogdf::SpannerIteratedWrapper to execute the ogdf::SpannerElkinNeiman algorithm up to 200 time...
SpannerElkinNeimanIterated()
A implementation-independed wrapper class to execute a spanner algorithm multiple times.
Interface for spanner algorithms.
void assertTimeLeft()
Assert, that time is left.
virtual void init(const GraphAttributes &GA, double stretch, GraphCopySimple &spanner, EdgeArray< bool > &inSpanner)
Initializes members and create an empty spanner.
const GraphAttributes * m_GA
EdgeArray< bool > * m_inSpanner
GraphCopySimple * m_spanner
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
int connectedComponents(const Graph &G, NodeArray< int > &component, List< node > *isolated=nullptr, ArrayBuffer< node > *reprs=nullptr)
Computes the connected components of G and optionally generates a list of isolated nodes.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
double randomDoubleExponential(double beta)
Returns a random double value from the exponential distribution.
void updateMax(T &max, const T &newValue)
Stores the maximum of max and newValue in max.
The namespace for all OGDF objects.
Declaration of simple graph algorithms.
edge p
The first edge of the path.
BfsNode(node _n, double _depth, edge _p)
node n
The current node to visit all neighbors from.
int depth
The depth of the node n.