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 
Typedefs for easier changing of types.
Key intToKey(int32_t value) const
Definition: MetisIndex.h:94
std::vector< int32_t > adj_
Definition: MetisIndex.h:53
const GaussianFactorGraph factors
const std::vector< int32_t > & adj() const
Definition: MetisIndex.h:88
const std::vector< int32_t > & xadj() const
Definition: MetisIndex.h:85
std::shared_ptr< MetisIndex > shared_ptr
Definition: MetisIndex.h:39
std::vector< int32_t > xadj_
Definition: MetisIndex.h:52
signed int int32_t
Definition: ms_stdint.h:82
void insert(const Key &left_value, const int32_t &right_value)
Definition: MetisIndex.h:46
std::map< Key, int32_t > left
Definition: MetisIndex.h:44
traits
Definition: chartTesting.h:28
size_t nValues() const
Definition: MetisIndex.h:91
std::unordered_map< int32_t, Key > right
Definition: MetisIndex.h:45
Factor Graph Base Class.
MetisIndex(const FACTORGRAPH &factorGraph)
Definition: MetisIndex.h:67
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
Timing utilities.


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:55