Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

UpwardPlanarizerModule.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
35 #include <ogdf/basic/Module.h>
36 #include <ogdf/basic/basic.h>
37 #include <ogdf/basic/memory.h>
39 
40 namespace ogdf {
41 
47 public:
49  UpwardPlanarizerModule() : m_useCost(false), m_useForbid(false) { }
50 
51  // destruction
53 
72  ReturnType call(UpwardPlanRep& UPR, const EdgeArray<int>* cost = nullptr,
73  const EdgeArray<bool>* forbid = nullptr) {
74  m_useCost = (cost != nullptr);
75  m_useForbid = (forbid != nullptr);
76 
77  if (!useCost()) {
78  cost = new EdgeArray<int>(UPR.original(), 1);
79  }
80  if (!useForbid()) {
81  forbid = new EdgeArray<bool>(UPR.original(), 0);
82  }
83 
84 
85  ReturnType R = doCall(UPR, *cost, *forbid);
86 
87  if (!useCost()) {
88  delete cost;
89  }
90  if (!useForbid()) {
91  delete forbid;
92  }
93  return R;
94  }
95 
97  ReturnType operator()(UpwardPlanRep& UPR, const EdgeArray<int>* cost = nullptr,
98  const EdgeArray<bool>* forbid = nullptr) {
99  return call(UPR, cost, forbid);
100  }
101 
103  bool useCost() const { return m_useCost; }
104 
106  bool useForbid() const { return m_useForbid; }
107 
108 protected:
126  virtual ReturnType doCall(UpwardPlanRep& UPR, const EdgeArray<int>& cost,
127  const EdgeArray<bool>& forbid) = 0;
128 
130 
131 private:
132  bool m_useCost;
133  bool m_useForbid;
134 };
135 
136 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
Graph.h
Includes declaration of graph class.
UpwardPlanRep.h
Declaration of a base class for planar representations of graphs and cluster graphs.
ogdf::UpwardPlanarizerModule::UpwardPlanarizerModule
UpwardPlanarizerModule()
Initializes an upward planarizer module.
Definition: UpwardPlanarizerModule.h:49
ogdf::UpwardPlanarizerModule::operator()
ReturnType operator()(UpwardPlanRep &UPR, const EdgeArray< int > *cost=nullptr, const EdgeArray< bool > *forbid=nullptr)
Computes a upward planarized representation of the input graph (shorthand for call)
Definition: UpwardPlanarizerModule.h:97
ogdf::UpwardPlanarizerModule::m_useCost
bool m_useCost
True iff edge costs are given.
Definition: UpwardPlanarizerModule.h:132
ogdf::UpwardPlanarizerModule::m_useForbid
bool m_useForbid
True iff forbidden edges are given.
Definition: UpwardPlanarizerModule.h:133
OGDF_MALLOC_NEW_DELETE
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition: memory.h:92
ogdf::Module
Base class for modules.
Definition: Module.h:49
ogdf::UpwardPlanarizerModule::~UpwardPlanarizerModule
virtual ~UpwardPlanarizerModule()
Definition: UpwardPlanarizerModule.h:52
basic.h
Basic declarations, included by all source files.
ogdf::UpwardPlanarizerModule::useCost
bool useCost() const
Returns true iff edge costs are given.
Definition: UpwardPlanarizerModule.h:103
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::UpwardPlanarizerModule
Interface for upward planarization algorithms.
Definition: UpwardPlanarizerModule.h:46
ogdf::UpwardPlanarizerModule::useForbid
bool useForbid() const
Returns true iff forbidden edges are given.
Definition: UpwardPlanarizerModule.h:106
ogdf::UpwardPlanRep
Upward planarized representations (of a connected component) of a graph.
Definition: UpwardPlanRep.h:57
Module.h
Declares base class for all module types.
ogdf::UpwardPlanarizerModule::call
ReturnType call(UpwardPlanRep &UPR, const EdgeArray< int > *cost=nullptr, const EdgeArray< bool > *forbid=nullptr)
Computes a upward planarized representation (UPR) of the input graph G.
Definition: UpwardPlanarizerModule.h:72
ogdf::Module::ReturnType
ReturnType
The return type of a module.
Definition: Module.h:52
memory.h
Declaration of memory manager for allocating small pieces of memory.
ogdf::GraphCopyBase::original
const Graph & original() const
Returns a reference to the original graph.
Definition: GraphCopy.h:105
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716