This file is indexed.

/usr/include/opengm/inference/auxiliary/planar_maxcut.hxx is in libopengm-dev 2.3.6-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
#pragma once
#ifndef OPENGM_PLANAR_MAXCUT_HXX
#define OPENGM_PLANAR_MAXCUT_HXX
#include "planar_graph.hxx"

namespace opengm {

/// OpenGM wrappers around third party algorithms
namespace external {

/// \cond HIDDEN_SYMBOLS
   
/// \brief MAXCUT for planar graphs
class PlanarMaxCut {
public:
   typedef size_t node_type;
   typedef double value_type;

   PlanarMaxCut();
   ~PlanarMaxCut();
   PlanarMaxCut(size_t numberOfNodes, size_t numberOfEdges);
   void addEdge(node_type,node_type,value_type);
   void calculateCut();
   template <class VEC> void getCut(VEC&);
   template <class VEC> void getLabeling(VEC&);
      
private:
   planargraph::PlanarGraph graph_; 
 
   size_t      numberOfNodes_;
   size_t      numberOfEdges_; // usused so far
};

    
   inline PlanarMaxCut::PlanarMaxCut() {
      numberOfNodes_ = 0;
      numberOfEdges_ = 0;
   }

   inline PlanarMaxCut::PlanarMaxCut(size_t numberOfNodes, size_t numberOfEdges) { 
      numberOfNodes_ = numberOfNodes;
      numberOfEdges_ = numberOfEdges;

      for(size_t variableId=0; variableId < numberOfNodes; ++variableId)
      {
         graph_.add_node();
      }
   }
    
   inline PlanarMaxCut::~PlanarMaxCut() 
   {
   }  
    
   inline void PlanarMaxCut::addEdge(node_type n1, node_type n2, value_type cost) {
      assert(n1 < numberOfNodes_);
      assert(n2 < numberOfNodes_); 
      long int e = graph_.find_edge(n1,n2);
      if(e == -1){
         graph_.add_edge(n1, n2, cost);
      } else {
         graph_.add_edge_weight(e, cost);
      }
   }
   
   void PlanarMaxCut::calculateCut() { 

      graph_.planarize();      // Planarize graph
      graph_.construct_dual(); // Construct dual graph
      graph_.calculate_maxcut();          // Perform perfect matching / max cut  

   }
   
   template <class VEC>
   void PlanarMaxCut::getCut(VEC& cut) { 
      
      // todo: add temptated interface in planargraph
      std::vector<bool> temp = graph_.get_cut();
      if(cut.size()<temp.size())
         cut.resize(temp.size());
      for(size_t i=0; i<temp.size(); ++i)
         cut[i]=temp[i];
      return;
   }

   template <class VEC>
   void PlanarMaxCut::getLabeling(VEC& segmentation) { 
      
      // todo: add temptated interface in planargraph
      std::vector<int> temp;
      graph_.get_labeling(temp);
      if(segmentation.size()<temp.size())
         segmentation.resize(temp.size());
      for(size_t i=0; i<temp.size(); ++i)
         segmentation[i]=temp[i];
      return;
   }

/// \endcond 

} // namespace external
} // namespace opengm

#endif // #ifndef OPENGM_PLANAR_MAXCUT_HXX