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 
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  }
95  assert(value >= 0);
96  return intKeyBMap_.right.find(value)->second;
97  }
98 
100 };
101 
102 } // \ namesace gtsam
103 
gtsam::MetisIndex::shared_ptr
std::shared_ptr< MetisIndex > shared_ptr
Definition: MetisIndex.h:39
gtsam::MetisIndex::nKeys_
size_t nKeys_
Definition: MetisIndex.h:55
timing.h
Timing utilities.
gtsam::MetisIndex::intKeyBMap_
BiMap intKeyBMap_
Definition: MetisIndex.h:54
types.h
Typedefs for easier changing of types.
gtsam::MetisIndex::~MetisIndex
~MetisIndex()
Definition: MetisIndex.h:72
simple_graph::factors
const GaussianFactorGraph factors
Definition: testJacobianFactor.cpp:213
gtsam::MetisIndex::adj
const std::vector< int32_t > & adj() const
Definition: MetisIndex.h:88
Key.h
gtsam::MetisIndex::BiMap::insert
void insert(const Key &left_value, const int32_t &right_value)
Definition: MetisIndex.h:46
left
static char left
Definition: blas_interface.hh:62
gtsam::MetisIndex::xadj
const std::vector< int32_t > & xadj() const
Definition: MetisIndex.h:85
gtsam::MetisIndex::BiMap::left
std::map< Key, int32_t > left
Definition: MetisIndex.h:44
gtsam::MetisIndex::nValues
size_t nValues() const
Definition: MetisIndex.h:91
gtsam::MetisIndex
Definition: MetisIndex.h:37
MetisIndex-inl.h
gtsam::MetisIndex::xadj_
std::vector< int32_t > xadj_
Definition: MetisIndex.h:52
gtsam::MetisIndex::intToKey
Key intToKey(int32_t value) const
Definition: MetisIndex.h:94
gtsam::MetisIndex::MetisIndex
MetisIndex(const FACTORGRAPH &factorGraph)
Definition: MetisIndex.h:67
gtsam::MetisIndex::adj_
std::vector< int32_t > adj_
Definition: MetisIndex.h:53
right
static char right
Definition: blas_interface.hh:61
gtsam::MetisIndex::BiMap::right
std::unordered_map< int32_t, Key > right
Definition: MetisIndex.h:45
gtsam
traits
Definition: SFMdata.h:40
FactorGraph.h
Factor Graph Base Class.
gtsam::MetisIndex::MetisIndex
MetisIndex()
Definition: MetisIndex.h:62
int32_t
signed int int32_t
Definition: ms_stdint.h:82
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::MetisIndex::BiMap
Definition: MetisIndex.h:43
test_callbacks.value
value
Definition: test_callbacks.py:160


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:33:48