gtsam 4.1.1
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/types.h>
23#include <gtsam/base/timing.h>
24
25// Boost bimap generates many ugly warnings in CLANG
26#ifdef __clang__
27# pragma clang diagnostic push
28# pragma clang diagnostic ignored "-Wredeclared-class-member"
29#endif
30#include <boost/bimap.hpp>
31#ifdef __clang__
32# pragma clang diagnostic pop
33#endif
34
35#include <vector>
36
37namespace gtsam {
45class GTSAM_EXPORT MetisIndex {
46public:
47 typedef boost::shared_ptr<MetisIndex> shared_ptr;
48 typedef boost::bimap<Key, int32_t> bm_type;
49
50private:
51 std::vector<int32_t> xadj_; // Index of node's adjacency list in adj
52 std::vector<int32_t> adj_; // Stores ajacency lists of all nodes, appended into a single vector
53 boost::bimap<Key, int32_t> intKeyBMap_; // Stores Key <-> integer value relationship
54 size_t nKeys_;
55
56public:
59
62 nKeys_(0) {
63 }
64
65 template<class FG>
66 MetisIndex(const FG& factorGraph) :
67 nKeys_(0) {
68 augment(factorGraph);
69 }
70
71 ~MetisIndex() {
72 }
76
81 template<class FACTOR>
82 void augment(const FactorGraph<FACTOR>& factors);
83
84 const std::vector<int32_t>& xadj() const {
85 return xadj_;
86 }
87 const std::vector<int32_t>& adj() const {
88 return adj_;
89 }
90 size_t nValues() const {
91 return nKeys_;
92 }
93 Key intToKey(int32_t value) const {
94 assert(value >= 0);
95 return intKeyBMap_.right.find(value)->second;
96 }
97
99};
100
101} // \ namesace gtsam
102
Typedefs for easier changing of types.
Timing utilities.
Factor Graph Base Class.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
The MetisIndex class converts a factor graph into the Compressed Sparse Row format for use in METIS a...
Definition: MetisIndex.h:45
MetisIndex()
Default constructor, creates empty MetisIndex.
Definition: MetisIndex.h:61