diff --git a/.cproject b/.cproject
index f41da3e32..ef7985e39 100644
--- a/.cproject
+++ b/.cproject
@@ -317,6 +317,7 @@
make
+
clean
true
true
@@ -476,7 +477,6 @@
make
-
testBayesTree.run
true
false
@@ -484,6 +484,7 @@
make
+
testSymbolicBayesNet.run
true
false
@@ -491,7 +492,6 @@
make
-
testSymbolicFactorGraph.run
true
false
@@ -683,7 +683,6 @@
make
-
testGraph.run
true
false
@@ -739,6 +738,7 @@
make
+
testSimulated2D.run
true
false
@@ -786,7 +786,6 @@
make
-
testErrors.run
true
false
@@ -794,7 +793,6 @@
make
-
testDSF.run
true
true
@@ -810,7 +808,6 @@
make
-
testConstraintOptimizer.run
true
true
@@ -818,6 +815,7 @@
make
+
testBTree.run
true
true
@@ -825,12 +823,19 @@
make
-
testSimulated2DOriented.run
true
false
true
+
+make
+
+testDSFVector.run
+true
+true
+true
+
make
-j2
diff --git a/cpp/DSF.h b/cpp/DSF.h
index eff4bdd8e..ce12068cc 100644
--- a/cpp/DSF.h
+++ b/cpp/DSF.h
@@ -110,7 +110,7 @@ namespace gtsam {
}
// get the nodes in the tree with the given label
- Set set(const Label& label) {
+ Set set(const Label& label) const {
Set set;
BOOST_FOREACH(const KeyLabel& pair, (Tree)*this) {
if (pair.second == label || findSet(pair.second) == label)
diff --git a/cpp/DSFVector.cpp b/cpp/DSFVector.cpp
new file mode 100644
index 000000000..2e1ccc305
--- /dev/null
+++ b/cpp/DSFVector.cpp
@@ -0,0 +1,58 @@
+/*
+ * DSFVector.cpp
+ *
+ * Created on: Jun 25, 2010
+ * Author: nikai
+ * Description: a faster implementation for DSF, which uses vector rather than btree.
+ * As a result, the size of the forest is prefixed.
+ */
+
+#include "DSFVector.h"
+
+using namespace std;
+
+namespace gtsam {
+
+ /* ************************************************************************* */
+ DSFVector::DSFVector (const size_t numNodes) {
+ resize(numNodes);
+ int index = 0;
+ for(iterator it = begin(); it!=end(); it++, index++)
+ *it = index;
+ }
+
+ /* ************************************************************************* */
+ size_t DSFVector::findSet(const size_t& key) const {
+ size_t parent = at(key);
+ return parent == key ? key : findSet(parent);
+ }
+
+ /* ************************************************************************* */
+ std::set DSFVector::set(const std::size_t& label) const {
+ std::set set;
+ size_t key = 0;
+ std::vector::const_iterator it = begin();
+ for (; it != end(); it++, key++) {
+ if (*it == label || findSet(*it) == label)
+ set.insert(key);
+ }
+ return set;
+ }
+
+ /* ************************************************************************* */
+ void DSFVector::makeUnionInPlace(const std::size_t& i1, const std::size_t& i2) {
+ at(findSet(i2)) = findSet(i1);
+ }
+
+ /* ************************************************************************* */
+ std::map > DSFVector::sets() const {
+ std::map > sets;
+ size_t key = 0;
+ std::vector::const_iterator it = begin();
+ for (; it != end(); it++, key++) {
+ sets[findSet(*it)].insert(key);
+ }
+ return sets;
+ }
+
+}
diff --git a/cpp/DSFVector.h b/cpp/DSFVector.h
new file mode 100644
index 000000000..e8f0bc6b2
--- /dev/null
+++ b/cpp/DSFVector.h
@@ -0,0 +1,41 @@
+/*
+ * DSFVector.h
+ *
+ * Created on: Jun 25, 2010
+ * Author: nikai
+ * Description: a faster implementation for DSF, which uses vector rather than btree.
+ * As a result, the size of the forest is prefixed.
+ */
+
+#pragma once
+
+#include
+#include