GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
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/types.h>
23 #include <gtsam/base/timing.h>
24 
25 #include <vector>
26 #include <map>
27 #include <unordered_map>
28 
29 namespace gtsam {
37 class GTSAM_EXPORT MetisIndex {
38 public:
39  typedef std::shared_ptr<MetisIndex> shared_ptr;
40 
41 private:
42  // Stores Key <-> integer value relationship
43  struct BiMap {
44  std::map<Key, int32_t> left;
45  std::unordered_map<int32_t, Key> right;
46  void insert(const Key& left_value, const int32_t& right_value) {
47  left[left_value] = right_value;
48  right[right_value] = left_value;
49  }
50  };
51 
52  std::vector<int32_t> xadj_; // Index of node's adjacency list in adj
53  std::vector<int32_t> adj_; // Stores ajacency lists of all nodes, appended into a single vector
54  BiMap intKeyBMap_; // Stores Key <-> integer value relationship
55  size_t nKeys_;
56 
57 public:
60 
63  nKeys_(0) {
64  }
65 
66  template<class FACTORGRAPH>
67  MetisIndex(const FACTORGRAPH& factorGraph) :
68  nKeys_(0) {
69  augment(factorGraph);
70  }
71 
72  ~MetisIndex() {
73  }
77 
82  template<class FACTORGRAPH>
83  void augment(const FACTORGRAPH& factors);
84 
85  const std::vector<int32_t>& xadj() const {
86  return xadj_;
87  }
88  const std::vector<int32_t>& adj() const {
89  return adj_;
90  }
91  size_t nValues() const {
92  return nKeys_;
93  }
94  Key intToKey(int32_t value) const {
95  assert(value >= 0);
96  return intKeyBMap_.right.find(value)->second;
97  }
98 
100 };
101 
102 } // \ namesace gtsam
103 
Typedefs for easier changing of types.
MetisIndex()
Definition: MetisIndex.h:62
Definition: MetisIndex.h:37
Definition: chartTesting.h:28
Factor Graph Base Class.
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
Timing utilities.