Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
CrossingMinimizationModule.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
37#include <ogdf/basic/Module.h>
39#include <ogdf/basic/basic.h>
40#include <ogdf/basic/memory.h>
41
42#include <cstdint>
43
44namespace ogdf {
45class PlanRep;
46
49public:
52
55
58
60 virtual CrossingMinimizationModule* clone() const = 0;
61
63
77 ReturnType call(PlanRep& pr, int cc, int& crossingNumber,
78 const EdgeArray<int>* pCostOrig = nullptr,
79 const EdgeArray<bool>* pForbiddenOrig = nullptr,
80 const EdgeArray<uint32_t>* pEdgeSubGraphs = nullptr) {
81 return doCall(pr, cc, pCostOrig, pForbiddenOrig, pEdgeSubGraphs, crossingNumber);
82 }
83
85
99 ReturnType operator()(PlanRep& pr, int cc, int& crossingNumber,
100 const EdgeArray<int>* pCostOrig = nullptr,
101 const EdgeArray<bool>* pForbiddenOrig = nullptr,
102 const EdgeArray<uint32_t>* pEdgeSubGraphs = nullptr) {
103 return call(pr, cc, crossingNumber, pCostOrig, pForbiddenOrig, pEdgeSubGraphs);
104 }
105
106protected:
108
122 virtual ReturnType doCall(PlanRep& pr, int cc, const EdgeArray<int>* pCostOrig,
123 const EdgeArray<bool>* pForbiddenOrig, const EdgeArray<uint32_t>* pEdgeSubGraphs,
124 int& crossingNumber) = 0;
125
136 static int computeCrossingNumber(GraphCopy& graphCopy, const EdgeArray<int>* pCost,
137 const EdgeArray<uint32_t>* pEdgeSubGraphs) {
138 if (pCost == nullptr) {
139 return graphCopy.numberOfNodes() - graphCopy.original().numberOfNodes();
140 } else {
141 int crossingNumber = 0;
142 for (node v : graphCopy.nodes) {
143 if (graphCopy.isDummy(v)) {
144 // Dummy node (crossing) found, calculate its cost.
145 edge e1 = graphCopy.original(v->firstAdj()->theEdge());
146 edge e2 = graphCopy.original(v->lastAdj()->theEdge());
147 if (pEdgeSubGraphs != nullptr) {
148 int subgraphCounter = 0;
149 for (int i = 0; i < 32; i++) {
150 if (((*pEdgeSubGraphs)[e1] & (1 << i)) != 0
151 && ((*pEdgeSubGraphs)[e2] & (1 << i)) != 0) {
152 subgraphCounter++;
153 }
154 }
155 crossingNumber += (subgraphCounter * (*pCost)[e1] * (*pCost)[e2]);
156 } else {
157 crossingNumber += (*pCost)[e1] * (*pCost)[e2];
158 }
159 }
160 }
161 return crossingNumber;
162 }
163 }
164
166};
167
168}
Includes declaration of graph class.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
Declares base class for all module types.
Declares base class for modules with timeout functionality.
Basic declarations, included by all source files.
Base class for crossing minimization algorithms.
static int computeCrossingNumber(GraphCopy &graphCopy, const EdgeArray< int > *pCost, const EdgeArray< uint32_t > *pEdgeSubGraphs)
Computes the (weighted) crossing number of the planarization graphCopy.
CrossingMinimizationModule()
Initializes a crossing minimization module (default constructor).
ReturnType call(PlanRep &pr, int cc, int &crossingNumber, const EdgeArray< int > *pCostOrig=nullptr, const EdgeArray< bool > *pForbiddenOrig=nullptr, const EdgeArray< uint32_t > *pEdgeSubGraphs=nullptr)
Computes a planarized representation of the input graph.
ReturnType operator()(PlanRep &pr, int cc, int &crossingNumber, const EdgeArray< int > *pCostOrig=nullptr, const EdgeArray< bool > *pForbiddenOrig=nullptr, const EdgeArray< uint32_t > *pEdgeSubGraphs=nullptr)
Computes a planarized representation of the input graph.
virtual ReturnType doCall(PlanRep &pr, int cc, const EdgeArray< int > *pCostOrig, const EdgeArray< bool > *pForbiddenOrig, const EdgeArray< uint32_t > *pEdgeSubGraphs, int &crossingNumber)=0
Actual algorithm call that needs to be implemented by derived classes.
virtual CrossingMinimizationModule * clone() const =0
Returns a new instance of the crossing minimization module with the same option settings.
CrossingMinimizationModule(const CrossingMinimizationModule &cmm)
Initializes an crossing minimization module (copy constructor).
Class for the representation of edges.
Definition Graph_d.h:364
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
Definition GraphCopy.h:172
const Graph & original() const
Returns a reference to the original graph.
Definition GraphCopy.h:104
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:390
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition Graph_d.h:979
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition Graph_d.h:929
Base class for modules.
Definition Module.h:49
ReturnType
The return type of a module.
Definition Module.h:52
Class for the representation of nodes.
Definition Graph_d.h:241
Planarized representations (of a connected component) of a graph.
Definition PlanRep.h:68
class for timeout funtionality.
Definition Timeouter.h:46
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition memory.h:92
Declaration of memory manager for allocating small pieces of memory.
The namespace for all OGDF objects.