diff --git a/gtsam/inference/VariableIndex.cpp b/gtsam/inference/VariableIndex.cpp index 26ba191dd..8ce667664 100644 --- a/gtsam/inference/VariableIndex.cpp +++ b/gtsam/inference/VariableIndex.cpp @@ -30,11 +30,11 @@ bool VariableIndex::equals(const VariableIndex& other, double tol) const { } /* ************************************************************************* */ -void VariableIndex::print(const string& str) const { +void VariableIndex::print(const string& str, const KeyFormatter& keyFormatter) const { cout << str; cout << "nEntries = " << nEntries() << ", nFactors = " << nFactors() << "\n"; BOOST_FOREACH(KeyMap::value_type key_factors, index_) { - cout << "var " << key_factors.first << ":"; + cout << "var " << keyFormatter(key_factors.first) << ":"; BOOST_FOREACH(const size_t factor, key_factors.second) cout << " " << factor; cout << "\n"; diff --git a/gtsam/inference/VariableIndex.h b/gtsam/inference/VariableIndex.h index 14fbc2072..ed7aaae55 100644 --- a/gtsam/inference/VariableIndex.h +++ b/gtsam/inference/VariableIndex.h @@ -106,7 +106,8 @@ public: bool equals(const VariableIndex& other, double tol=0.0) const; /** Print the variable index (for unit tests and debugging). */ - void print(const std::string& str = "VariableIndex: ") const; + void print(const std::string& str = "VariableIndex: ", + const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; /** * Output dual hypergraph to Metis file format for use with hmetis