Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00042 #ifndef OGDF_CROSSING_MINIMIZATION_MODULE_H
00043 #define OGDF_CROSSING_MINIMIZATION_MODULE_H
00044
00045
00046
00047 #include <ogdf/planarity/PlanRep.h>
00048 #include <ogdf/planarity/PlanarModule.h>
00049 #include <ogdf/basic/Module.h>
00050 #include <ogdf/basic/Logger.h>
00051 #include <ogdf/basic/Timeouter.h>
00052
00053
00054 namespace ogdf {
00055
00060 class OGDF_EXPORT CrossingMinimizationModule : public Module, public Timeouter
00061 {
00062 public:
00064 CrossingMinimizationModule() { }
00065
00066
00067 virtual ~CrossingMinimizationModule() { }
00068
00087 ReturnType call(PlanRep &PG,
00088 int cc,
00089 int& crossingNumber,
00090 const EdgeArray<int> * cost = 0,
00091 const EdgeArray<bool> * forbid = 0,
00092 const EdgeArray<unsigned int> * subgraphs = 0)
00093 {
00094 m_useCost = (cost != 0);
00095 m_useForbid = (forbid != 0);
00096 m_useSubgraphs = (subgraphs != 0);
00097
00098 if(!useCost()) cost = OGDF_NEW EdgeArray<int> (PG.original(), 1);
00099 if(!useForbid()) forbid = OGDF_NEW EdgeArray<bool> (PG.original(), 0);
00100 if(!useSubgraphs()) subgraphs = OGDF_NEW EdgeArray<unsigned int> (PG.original(), 1);
00101
00102 ReturnType R = doCall(PG, cc, *cost, *forbid, *subgraphs, crossingNumber);
00103
00104 if(!useCost()) delete cost;
00105 if(!useForbid()) delete forbid;
00106 if(!useSubgraphs()) delete subgraphs;
00107 return R;
00108 };
00109
00111 ReturnType operator()(PlanRep &PG,
00112 int cc,
00113 int& crossingNumber,
00114 const EdgeArray<int> * cost = 0,
00115 const EdgeArray<bool> * forbid = 0,
00116 const EdgeArray<unsigned int> * const subgraphs = 0) {
00117 return call(PG, cc, crossingNumber, cost, forbid, subgraphs);
00118 };
00119
00121 bool useCost() const { return m_useCost; }
00122
00124 bool useForbid() const { return m_useForbid; }
00125
00126 bool useSubgraphs() const { return m_useSubgraphs; }
00127
00128 protected:
00145 virtual ReturnType doCall(PlanRep &PG,
00146 int cc,
00147 const EdgeArray<int> &cost,
00148 const EdgeArray<bool> &forbid,
00149 const EdgeArray<unsigned int> &subgraphs,
00150 int& crossingNumber) = 0;
00151
00152 OGDF_MALLOC_NEW_DELETE
00153
00154 private:
00155 bool m_useCost;
00156 bool m_useForbid;
00157 bool m_useSubgraphs;
00158 };
00159
00160 }
00161
00162 #endif