|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
73 template<
typename TWeight>
85 std::string& error)
override {
87 error =
"The graph must be undirected";
91 if (std::modf(stretch, &integralPart) != 0.0) {
95 int intStretch =
static_cast<int>(stretch);
97 error =
"The stretch must be >= 1.0";
100 if (intStretch % 2 == 0) {
101 error =
"The stretch must be odd";
153 int k = (
static_cast<int>(
m_stretch) + 1) / 2;
155 for (
int iteration = 1; iteration <= k - 1; iteration++) {
162 for (
node oldCenter : clusterCenters.
nodes()) {
164 sampledClusterCenters.
insert(oldCenter);
170 if (sampledClusterCenters.
isMember(oldCluster[v])) {
182 TWeight minWeight = std::numeric_limits<TWeight>::max();
183 edge minEdge =
nullptr;
190 if (sampledClusterCenters.
isMember(center)) {
220 if (
A[center] !=
nullptr
221 && (minEdge ==
nullptr || minEdge ==
A[center]
237 v->allAdjEntries(adjs);
266 clusterCenters =
std::move(sampledClusterCenters);
289 if (
A[center] !=
nullptr) {
297 while ((a = v->
firstAdj()) !=
nullptr) {
323 template<
typename TWeight>
The namespace for all OGDF objects.
Stores additional attributes of a graph (like layout information).
Declaration of class GraphAttributes which extends a Graph by additional attributes.
virtual void init(const GraphAttributes &GA, double stretch, GraphCopySimple &spanner, EdgeArray< bool > &inSpanner) override
Initializes members and create an empty spanner.
void delEdge(edge e) override
Removes edge e.
A implementation-independed wrapper class to execute a spanner algorithm multiple times.
Compare floating point numbers with epsilons and integral numbers with normal compare operators.
Includes declaration of graph class.
edge copy(edge e) const override
Returns the edge in the graph copy corresponding to e.
GraphCopySimple * m_spanner
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
SpannerBaswanaSenIterated()
void phase1()
Phase 1: Forming clusters.
virtual void init(const GraphAttributes &GA, double stretch, GraphCopySimple &spanner, EdgeArray< bool > &inSpanner)
Initializes members and create an empty spanner.
const RS::list_type & nodes()
Returns a reference to the list of nodes contained in this set.
void assertTimeLeft()
Assert, that time is left.
Copies of graphs with mapping between nodes and edges.
bool directed() const
Returns if the graph is directed.
const Graph & constGraph() const
Returns a reference to the associated graph.
Declaration and implementation of NodeSet, EdgeSet, and AdjEntrySet classes.
Basic module for spanner algorithms.
Class for adjacency list elements.
std::enable_if< std::is_integral< T >::value, bool >::type less(const T &x, const T &y) const
Compare if x is LESS than y for integral types.
void init(const Graph &G)
Re-initializes the copy using G, creating copies for all nodes and edges in G.
Randomized multiplicative spanner calculation by forming clusters.
edge theEdge() const
Returns the edge associated with this adjacency entry.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
void addToSpanner(edge e)
Adds e from m_G to the spanner and sets inSpanner.
int numberOfNodes() const
Returns the number of nodes in the graph.
NodeArray< node > m_cluster
the current cluster for each iteration in phase 1 and the final cluster from phase 1 which is used in...
const T & move(const T &v)
Decralation of GraphElement and GraphList classes.
void insert(element_type v)
Inserts element v into this set.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
void phase2()
Phase 2: Vertex-Cluster Joining.
node source() const
Returns the source node of the edge.
Declaration of graph copy classes.
RegisteredArray for nodes, edges and adjEntries of a graph.
bool isMember(element_type v) const
Returns true iff element v is contained in this set.
Interface for spanner algorithms.
A wrapper class for iterating calls to spanner algorithms.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
void clear() override
Removes all nodes and edges from this copy but does not break the link with the original graph.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Basic declarations, included by all source files.
const GraphAttributes * m_GA
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
virtual bool preconditionsOk(const GraphAttributes &GA, double stretch, std::string &error) override
Class for the representation of edges.
Declaration of doubly linked lists and iterators.
Use the ogdf::SpannerIteratedWrapper to execute the ogdf::SpannerBaswanaSen algorithm up to 1000 time...
node target() const
Returns the target node of the edge.
ReturnType
The return type of a module.
std::string to_string(const std::function< std::ostream &(std::ostream &)> &func)
Class for the representation of nodes.
edge newEdge(edge eOrig)
Creates a new edge in the graph copy with original edge eOrig.
virtual SpannerModule< TWeight >::ReturnType execute() override
Executes the core algorithm.
GraphCopySimple m_G
The copy of GA.constGraph() to work on. Edges will be removed in each iteration.
double randomDouble(double low, double high)
Returns a random double value from the interval [low, high).
const Graph & original() const
Returns a reference to the original graph.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
static TWeight getWeight(const GraphAttributes &GA, edge e)