summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/example/mini_simplex_tree.cpp
diff options
context:
space:
mode:
authorskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-12-07 14:45:43 +0000
committerskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-12-07 14:45:43 +0000
commitc4078affdbf6fac7150c10ade96fcb72270ac013 (patch)
tree1ad197bb90078a56036a49c6ee3766a032f85e63 /src/Simplex_tree/example/mini_simplex_tree.cpp
parentf70e386fc98f1dbd8287d1cb7cc715710a8f751b (diff)
parent061e43a2a48525bc5a69482a1ea80f20ff505e55 (diff)
Merged with trunk and removed unnecessary files
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@934 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d0ec52d222d22c102e9fe57590882cd0024c82d5
Diffstat (limited to 'src/Simplex_tree/example/mini_simplex_tree.cpp')
-rw-r--r--src/Simplex_tree/example/mini_simplex_tree.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/Simplex_tree/example/mini_simplex_tree.cpp b/src/Simplex_tree/example/mini_simplex_tree.cpp
new file mode 100644
index 00000000..7e48aaaf
--- /dev/null
+++ b/src/Simplex_tree/example/mini_simplex_tree.cpp
@@ -0,0 +1,69 @@
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Marc Glisse
+ *
+ * Copyright (C) 2015 INRIA Saclay - Ile-de-France (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gudhi/Simplex_tree.h>
+#include <iostream>
+#include <initializer_list>
+
+using namespace Gudhi;
+
+struct MyOptions : Simplex_tree_options_full_featured {
+ // Not doing persistence, so we don't need those
+ static const bool store_key = false;
+ static const bool store_filtration = false;
+ // I have few vertices
+ typedef short Vertex_handle;
+};
+typedef Simplex_tree<MyOptions> ST;
+
+// Dictionary should be private, but for now this is the easiest way.
+static_assert(sizeof(ST::Dictionary::value_type) < sizeof(Simplex_tree<>::Dictionary::value_type),
+ "Not storing the filtration and key should save some space");
+
+int main() {
+ ST st;
+
+ /* Complex to build. */
+ /* 1 */
+ /* o */
+ /* /X\ */
+ /* o---o---o */
+ /* 2 0 3 */
+
+ auto triangle012 = {0, 1, 2};
+ auto edge03 = {0, 3};
+ st.insert_simplex_and_subfaces(triangle012);
+ st.insert_simplex_and_subfaces(edge03);
+ // FIXME: Remove this line
+ st.set_dimension(2);
+
+ auto edge02 = {0, 2};
+ ST::Simplex_handle e = st.find(edge02);
+ // We are not using filtrations so everything has value 0
+ assert(st.filtration(e) == 0);
+ for (ST::Simplex_handle t : st.cofaces_simplex_range(e, 1)) {
+ // Only coface is 012
+ for (ST::Vertex_handle v : st.simplex_vertex_range(t)) // v in { 0, 1, 2 }
+ std::cout << v;
+ std::cout << '\n';
+ }
+}