gtsam  4.0.0
gtsam
MetisIndex.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9  * -------------------------------------------------------------------------- */
10 
17 #pragma once
18 
19 
20 #include <gtsam/inference/Key.h>
22 #include <gtsam/base/FastVector.h>
23 #include <gtsam/base/types.h>
24 #include <gtsam/base/timing.h>
25 
26 // Boost bimap generates many ugly warnings in CLANG
27 #ifdef __clang__
28 # pragma clang diagnostic push
29 # pragma clang diagnostic ignored "-Wredeclared-class-member"
30 #endif
31 #include <boost/bimap.hpp>
32 #ifdef __clang__
33 # pragma clang diagnostic pop
34 #endif
35 
36 #include <vector>
37 
38 namespace gtsam {
46 class GTSAM_EXPORT MetisIndex {
47 public:
48  typedef boost::shared_ptr<MetisIndex> shared_ptr;
49  typedef boost::bimap<Key, int32_t> bm_type;
50 
51 private:
52  FastVector<int32_t> xadj_; // Index of node's adjacency list in adj
53  FastVector<int32_t> adj_; // Stores ajacency lists of all nodes, appended into a single vector
54  FastVector<int32_t> iadj_; // Integer keys for passing into metis. One to one mapping with adj_;
55  boost::bimap<Key, int32_t> intKeyBMap_; // Stores Key <-> integer value relationship
56  size_t nKeys_;
57 
58 public:
61 
64  nKeys_(0) {
65  }
66 
67  template<class FG>
68  MetisIndex(const FG& factorGraph) :
69  nKeys_(0) {
70  augment(factorGraph);
71  }
72 
73  ~MetisIndex() {
74  }
78 
83  template<class FACTOR>
84  void augment(const FactorGraph<FACTOR>& factors);
85 
86  std::vector<int32_t> xadj() const {
87  return xadj_;
88  }
89  std::vector<int32_t> adj() const {
90  return adj_;
91  }
92  size_t nValues() const {
93  return nKeys_;
94  }
95  Key intToKey(int32_t value) const {
96  assert(value >= 0);
97  return intKeyBMap_.right.find(value)->second;
98  }
99 
101 };
102 
103 } // \ namesace gtsam
104 
Typedefs for easier changing of types.
Factor Graph Base Class.
The MetisIndex class converts a factor graph into the Compressed Sparse Row format for use in METIS a...
Definition: MetisIndex.h:46
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition: BayesTree.h:32
Timing utilities.
MetisIndex()
Default constructor, creates empty MetisIndex.
Definition: MetisIndex.h:63
A thin wrapper around std::vector that uses boost&#39;s pool_allocator.
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Global functions in a separate testing namespace.
Definition: chartTesting.h:28