62template<
typename TWeight>
94 init(GA, stretch, spanner, inSpanner);
152 for (
node n : G.nodes) {
214template<
typename TWeight>
224template<
typename TWeight>
236 for (
edge e : G.edges) {
242 apspSpanner(GA, spanner, newDistances);
245 for (
edge e : G.edges) {
246 node u = e->source();
247 node v = e->target();
248 TWeight originalDistance = originalDistances[u][v];
249 TWeight newDistance = newDistances[spanner.
copy(u)][spanner.
copy(v)];
250 if (m_eps.
greater(
static_cast<double>(newDistance), stretch * originalDistance)) {
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.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
Declares base class for all module types.
Declaration of several shortest path algorithms.
Declaration of stopwatch classes.
Basic declarations, included by all source files.
Class for the representation of edges.
std::enable_if< std::is_integral< T >::value, bool >::type greater(const T &x, const T &y) const
Compare if x is GREATER than y for integral types.
Stores additional attributes of a graph (like layout information).
int intWeight(edge e) const
Returns the (integer) weight of edge e.
const Graph & constGraph() const
Returns a reference to the associated graph.
double doubleWeight(edge e) const
Returns the (real number) weight of edge e.
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).
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
const Graph & original() const
Returns a reference to the original graph.
Copies of graphs with mapping between nodes and edges.
void setOriginalGraph(const Graph *G) override
Re-initializes the copy using G (which might be null), but does not create any nodes or edges.
void clear() override
Removes all nodes and edges from this copy but does not break the link with the original graph.
edge copy(edge e) const override
Returns the edge in the graph copy corresponding to e.
Data type for general directed graphs (adjacency list representation).
int numberOfNodes() const
Returns the number of nodes in the graph.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
ReturnType
The return type of a module.
@ TimeoutInfeasible
The solution is not feasible due to a timeout.
Class for the representation of nodes.
Interface for spanner algorithms.
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.
virtual ReturnType execute()=0
Executes the core algorithm.
StopwatchCPU m_watch
Used for keeping track of time.
void assertTimeLeft()
Assert, that time is left.
bool isTimelimitEnabled()
virtual ReturnType call(const GraphAttributes &GA, double stretch, GraphCopySimple &spanner, EdgeArray< bool > &inSpanner)
Executes the algorithm.
SpannerModule()
Initializes a spanner module.
int64_t m_timelimit
Timelimit in milliseconds.
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
static bool isMultiplicativeSpanner(const GraphAttributes &GA, const GraphCopySimple &spanner, double stretch)
Validates a spanner.
void setTimelimit(int64_t milliseconds)
Sets the timelimit for the algorithm in milliseconds.
virtual bool preconditionsOk(const GraphAttributes &GA, double stretch, std::string &error)=0
static TWeight getWeight(const GraphAttributes &GA, edge e)
GraphCopySimple * m_spanner
Implements a stopwatch measuring CPU time.
void start(bool reset=false)
Starts the stopwatch.
void stop()
Stops the stopwatch and adds the difference between the current time and the starting time to the tot...
int64_t milliSeconds() const
Returns the currently elapsed time in milliseconds.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
double dijkstra_SPAP(const GraphAttributes &GA, NodeArray< NodeArray< TCost > > &shortestPathMatrix)
Computes all-pairs shortest paths in GA using Dijkstra's algorithm.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
TWeight getWeight(edge e, const EdgeArray< TWeight > &weights)
Helper function to get the edge weight of e from the EdgeArray weights.
The namespace for all OGDF objects.
A simple exception used to exit from the execution, if the timelimit is reached.