summaryrefslogtreecommitdiff
path: root/src/Hasse_complex
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-02-24 10:49:25 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-02-24 10:49:25 +0000
commitd3d53b79217afc5df0deecb16f7d2f8b52629a99 (patch)
tree86358b238c3cf72f92d99170cd7b0f6e7005e448 /src/Hasse_complex
parent86ed4085d26398aed26dfd9c365f8f3ee187c92e (diff)
Add of hasse complex example
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@472 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d0221d0ad2374494416d01e75c08d4f8f139a5c5
Diffstat (limited to 'src/Hasse_complex')
-rw-r--r--src/Hasse_complex/example/CMakeLists.txt5
-rw-r--r--src/Hasse_complex/example/hasse_complex_from_simplex_tree.cpp124
2 files changed, 129 insertions, 0 deletions
diff --git a/src/Hasse_complex/example/CMakeLists.txt b/src/Hasse_complex/example/CMakeLists.txt
new file mode 100644
index 00000000..564df49d
--- /dev/null
+++ b/src/Hasse_complex/example/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.6)
+project(GUDHIHasseComplexExample)
+
+add_executable ( hasse_complex_from_simplex_tree hasse_complex_from_simplex_tree.cpp )
+add_test(hasse_complex_from_simplex_tree ${CMAKE_CURRENT_BINARY_DIR}/hasse_complex_from_simplex_tree)
diff --git a/src/Hasse_complex/example/hasse_complex_from_simplex_tree.cpp b/src/Hasse_complex/example/hasse_complex_from_simplex_tree.cpp
new file mode 100644
index 00000000..c7cff843
--- /dev/null
+++ b/src/Hasse_complex/example/hasse_complex_from_simplex_tree.cpp
@@ -0,0 +1,124 @@
+/* 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): Vincent Rouvreau
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (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 <iostream>
+#include <ctime>
+#include "gudhi/graph_simplicial_complex.h"
+#include "gudhi/Simplex_tree.h"
+
+using namespace Gudhi;
+
+typedef std::vector< Vertex_handle > typeVectorVertex;
+typedef std::pair<typeVectorVertex, Filtration_value> typeSimplex;
+typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool;
+typedef Simplex_tree<> typeST;
+
+int main(int argc, char * const argv[]) {
+ // TEST OF INSERTION
+ std::cout << "********************************************************************" << std::endl;
+ std::cout << "TEST OF INSERTION" << std::endl;
+ typeST st;
+
+ // ++ FIRST
+ std::cout << " - INSERT (2,1,0)" << std::endl;
+ typeVectorVertex SimplexVector1;
+ SimplexVector1.push_back(2);
+ SimplexVector1.push_back(1);
+ SimplexVector1.push_back(0);
+ st.insert_simplex_and_subfaces(SimplexVector1, 0.3);
+
+ // ++ SECOND
+ std::cout << " - INSERT 3" << std::endl;
+ typeVectorVertex SimplexVector2;
+ SimplexVector2.push_back(3);
+ st.insert_simplex_and_subfaces(SimplexVector2, 0.1);
+
+ // ++ THIRD
+ std::cout << " - INSERT (0,3)" << std::endl;
+ typeVectorVertex SimplexVector3;
+ SimplexVector3.push_back(3);
+ SimplexVector3.push_back(0);
+ st.insert_simplex_and_subfaces(SimplexVector3, 0.2);
+
+ // ++ FOURTH
+ std::cout << " - INSERT (1,0) (already inserted)" << std::endl;
+ typeVectorVertex SimplexVector4;
+ SimplexVector4.push_back(1);
+ SimplexVector4.push_back(0);
+ st.insert_simplex_and_subfaces(SimplexVector4, 0.2);
+
+ // ++ FIFTH
+ std::cout << " - INSERT (3,4,5)" << std::endl;
+ typeVectorVertex SimplexVector5;
+ SimplexVector5.push_back(3);
+ SimplexVector5.push_back(4);
+ SimplexVector5.push_back(5);
+ st.insert_simplex_and_subfaces(SimplexVector5, 0.3);
+
+ // ++ SIXTH
+ std::cout << " - INSERT (0,1,6,7)" << std::endl;
+ typeVectorVertex SimplexVector6;
+ SimplexVector6.push_back(0);
+ SimplexVector6.push_back(1);
+ SimplexVector6.push_back(6);
+ SimplexVector6.push_back(7);
+ st.insert_simplex_and_subfaces(SimplexVector6, 0.4);
+
+ /* Inserted simplex: */
+ /* 1 6 */
+ /* o---o */
+ /* /X\7/ 4 */
+ /* o---o---o---o */
+ /* 2 0 3\X/ */
+ /* o */
+ /* 5 */
+
+ /* In other words: */
+ /* A facet [2,1,0] */
+ /* An edge [0,3] */
+ /* A facet [3,4,5] */
+ /* A cell [0,1,6,7] */
+ /* A cell [4,5,8,9] */
+ /* A facet [9,10,11] */
+ /* An edge [11,6] */
+ /* An edge [10,12,2] */
+
+ // ++ GENERAL VARIABLE SET
+ st.set_filtration(0.4); // Max filtration value
+ st.set_dimension(3); // Max dimension = 3 -> (0,1,6,7)
+
+ std::cout << "The complex contains " << st.num_simplices() << " simplices - " << st.num_vertices() << " vertices " << std::endl;
+ std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl;
+ std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl;
+ std::cout << "**************************************************************" << std::endl;
+
+ for( auto f_simplex : st.filtration_simplex_range() )
+ {
+ std::cout << " " << "[" << st.filtration(f_simplex) << "] ";
+ for( auto vertex : st.simplex_vertex_range(f_simplex) )
+ {
+ std::cout << (int)vertex;
+ }
+ }
+
+ return 0;
+}