2 #ifndef OPENGM_PLANAR_MAXCUT_HXX
3 #define OPENGM_PLANAR_MAXCUT_HXX
16 typedef size_t node_type;
17 typedef double value_type;
21 PlanarMaxCut(
size_t numberOfNodes,
size_t numberOfEdges);
22 void addEdge(node_type,node_type,value_type);
24 template <
class VEC>
void getCut(VEC&);
25 template <
class VEC>
void getLabeling(VEC&);
28 planargraph::PlanarGraph graph_;
30 size_t numberOfNodes_;
31 size_t numberOfEdges_;
35 inline PlanarMaxCut::PlanarMaxCut() {
40 inline PlanarMaxCut::PlanarMaxCut(
size_t numberOfNodes,
size_t numberOfEdges) {
41 numberOfNodes_ = numberOfNodes;
42 numberOfEdges_ = numberOfEdges;
44 for(
size_t variableId=0; variableId < numberOfNodes; ++variableId)
50 inline PlanarMaxCut::~PlanarMaxCut()
54 inline void PlanarMaxCut::addEdge(node_type n1, node_type n2, value_type cost) {
55 assert(n1 < numberOfNodes_);
56 assert(n2 < numberOfNodes_);
57 long int e = graph_.find_edge(n1,n2);
59 graph_.add_edge(n1, n2, cost);
61 graph_.add_edge_weight(e, cost);
65 void PlanarMaxCut::calculateCut() {
68 graph_.construct_dual();
69 graph_.calculate_maxcut();
74 void PlanarMaxCut::getCut(VEC& cut) {
77 std::vector<bool> temp = graph_.get_cut();
78 if(cut.size()<temp.size())
79 cut.resize(temp.size());
80 for(
size_t i=0; i<temp.size(); ++i)
86 void PlanarMaxCut::getLabeling(VEC& segmentation) {
89 std::vector<int> temp;
90 graph_.get_labeling(temp);
91 if(segmentation.size()<temp.size())
92 segmentation.resize(temp.size());
93 for(
size_t i=0; i<temp.size(); ++i)
94 segmentation[i]=temp[i];
103 #endif // #ifndef OPENGM_PLANAR_MAXCUT_HXX