summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/example/simple_simplex_tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Simplex_tree/example/simple_simplex_tree.cpp')
-rw-r--r--src/Simplex_tree/example/simple_simplex_tree.cpp81
1 files changed, 14 insertions, 67 deletions
diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp
index 6d20e43e..a2e1f0e9 100644
--- a/src/Simplex_tree/example/simple_simplex_tree.cpp
+++ b/src/Simplex_tree/example/simple_simplex_tree.cpp
@@ -21,7 +21,6 @@
*/
#include <iostream>
-#include <ctime>
#include "gudhi/graph_simplicial_complex.h"
#include "gudhi/Simplex_tree.h"
@@ -35,10 +34,6 @@ int main(int argc, char * const argv[]) {
const Filtration_value SECOND_FILTRATION_VALUE = 0.2;
const Filtration_value THIRD_FILTRATION_VALUE = 0.3;
const Filtration_value FOURTH_FILTRATION_VALUE = 0.4;
- Vertex_handle FIRST_VERTEX_HANDLE = (Vertex_handle) 0;
- Vertex_handle SECOND_VERTEX_HANDLE = (Vertex_handle) 1;
- Vertex_handle THIRD_VERTEX_HANDLE = (Vertex_handle) 2;
- Vertex_handle FOURTH_VERTEX_HANDLE = (Vertex_handle) 3;
// TEST OF INSERTION
std::cout << "********************************************************************" << std::endl;
@@ -55,173 +50,132 @@ int main(int argc, char * const argv[]) {
// ++ FIRST
std::cout << " * INSERT 0" << std::endl;
- typeVectorVertex firstSimplexVector;
- firstSimplexVector.push_back(FIRST_VERTEX_HANDLE);
+ typeVectorVertex firstSimplexVector = { 0 };
typePairSimplexBool returnValue =
simplexTree.insert_simplex(firstSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + 0 INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - 0 NOT INSERTED" << std::endl;
}
// ++ SECOND
std::cout << " * INSERT 1" << std::endl;
- typeVectorVertex secondSimplexVector;
- secondSimplexVector.push_back(SECOND_VERTEX_HANDLE);
+ typeVectorVertex secondSimplexVector = { 1 };
returnValue =
simplexTree.insert_simplex(secondSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + 1 INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - 1 NOT INSERTED" << std::endl;
}
// ++ THIRD
std::cout << " * INSERT (0,1)" << std::endl;
- typeVectorVertex thirdSimplexVector;
- thirdSimplexVector.push_back(FIRST_VERTEX_HANDLE);
- thirdSimplexVector.push_back(SECOND_VERTEX_HANDLE);
+ typeVectorVertex thirdSimplexVector = { 0, 1 };
returnValue =
simplexTree.insert_simplex(thirdSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + (0,1) INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - (0,1) NOT INSERTED" << std::endl;
}
// ++ FOURTH
std::cout << " * INSERT 2" << std::endl;
- typeVectorVertex fourthSimplexVector;
- fourthSimplexVector.push_back(THIRD_VERTEX_HANDLE);
+ typeVectorVertex fourthSimplexVector = { 2 };
returnValue =
simplexTree.insert_simplex(fourthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + 2 INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - 2 NOT INSERTED" << std::endl;
}
// ++ FIFTH
std::cout << " * INSERT (2,0)" << std::endl;
- typeVectorVertex fifthSimplexVector;
- fifthSimplexVector.push_back(THIRD_VERTEX_HANDLE);
- fifthSimplexVector.push_back(FIRST_VERTEX_HANDLE);
+ typeVectorVertex fifthSimplexVector = { 2, 0 };
returnValue =
simplexTree.insert_simplex(fifthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + (2,0) INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - (2,0) NOT INSERTED" << std::endl;
}
// ++ SIXTH
std::cout << " * INSERT (2,1)" << std::endl;
- typeVectorVertex sixthSimplexVector;
- sixthSimplexVector.push_back(THIRD_VERTEX_HANDLE);
- sixthSimplexVector.push_back(SECOND_VERTEX_HANDLE);
+ typeVectorVertex sixthSimplexVector = { 2, 1 };
returnValue =
simplexTree.insert_simplex(sixthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + (2,1) INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - (2,1) NOT INSERTED" << std::endl;
}
// ++ SEVENTH
std::cout << " * INSERT (2,1,0)" << std::endl;
- typeVectorVertex seventhSimplexVector;
- seventhSimplexVector.push_back(THIRD_VERTEX_HANDLE);
- seventhSimplexVector.push_back(SECOND_VERTEX_HANDLE);
- seventhSimplexVector.push_back(FIRST_VERTEX_HANDLE);
+ typeVectorVertex seventhSimplexVector = { 2, 1, 0 };
returnValue =
simplexTree.insert_simplex(seventhSimplexVector, Filtration_value(THIRD_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + (2,1,0) INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - (2,1,0) NOT INSERTED" << std::endl;
}
// ++ EIGHTH
std::cout << " * INSERT 3" << std::endl;
- typeVectorVertex eighthSimplexVector;
- eighthSimplexVector.push_back(FOURTH_VERTEX_HANDLE);
+ typeVectorVertex eighthSimplexVector = { 3 };
returnValue =
simplexTree.insert_simplex(eighthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + 3 INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - 3 NOT INSERTED" << std::endl;
}
// ++ NINETH
std::cout << " * INSERT (3,0)" << std::endl;
- typeVectorVertex ninethSimplexVector;
- ninethSimplexVector.push_back(FOURTH_VERTEX_HANDLE);
- ninethSimplexVector.push_back(FIRST_VERTEX_HANDLE);
+ typeVectorVertex ninethSimplexVector = { 3, 0 };
returnValue =
simplexTree.insert_simplex(ninethSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + (3,0) INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - (3,0) NOT INSERTED" << std::endl;
}
// ++ TENTH
std::cout << " * INSERT 0 (already inserted)" << std::endl;
- typeVectorVertex tenthSimplexVector;
- tenthSimplexVector.push_back(FIRST_VERTEX_HANDLE);
+ typeVectorVertex tenthSimplexVector = { 0 };
returnValue =
simplexTree.insert_simplex(tenthSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); // With a different filtration value
if (returnValue.second == true) {
std::cout << " + 0 INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - 0 NOT INSERTED" << std::endl;
}
// ++ ELEVENTH
std::cout << " * INSERT (2,1,0) (already inserted)" << std::endl;
- typeVectorVertex eleventhSimplexVector;
- eleventhSimplexVector.push_back(THIRD_VERTEX_HANDLE);
- eleventhSimplexVector.push_back(SECOND_VERTEX_HANDLE);
- eleventhSimplexVector.push_back(FIRST_VERTEX_HANDLE);
+ typeVectorVertex eleventhSimplexVector = { 2, 1, 0 };
returnValue =
simplexTree.insert_simplex(eleventhSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE));
if (returnValue.second == true) {
std::cout << " + (2,1,0) INSERTED" << std::endl;
- int nb_simplices = simplexTree.num_simplices() + 1;
- simplexTree.set_num_simplices(nb_simplices);
} else {
std::cout << " - (2,1,0) NOT INSERTED" << std::endl;
}
@@ -262,9 +216,7 @@ int main(int argc, char * const argv[]) {
else
std::cout << "***- NO IT ISN'T\n";
- Vertex_handle UNKNOWN_VERTEX_HANDLE = (Vertex_handle) 15;
- typeVectorVertex unknownSimplexVector;
- unknownSimplexVector.push_back(UNKNOWN_VERTEX_HANDLE);
+ typeVectorVertex unknownSimplexVector = { 15 };
simplexFound = simplexTree.find(unknownSimplexVector);
std::cout << "**************IS THE SIMPLEX {15} IN THE SIMPLEX TREE ?\n";
if (simplexFound != simplexTree.null_simplex())
@@ -279,9 +231,7 @@ int main(int argc, char * const argv[]) {
else
std::cout << "***- NO IT ISN'T\n";
- typeVectorVertex otherSimplexVector;
- otherSimplexVector.push_back(UNKNOWN_VERTEX_HANDLE);
- otherSimplexVector.push_back(SECOND_VERTEX_HANDLE);
+ typeVectorVertex otherSimplexVector = { 1, 15 };
simplexFound = simplexTree.find(otherSimplexVector);
std::cout << "**************IS THE SIMPLEX {15,1} IN THE SIMPLEX TREE ?\n";
if (simplexFound != simplexTree.null_simplex())
@@ -289,10 +239,7 @@ int main(int argc, char * const argv[]) {
else
std::cout << "***- NO IT ISN'T\n";
- typeVectorVertex invSimplexVector;
- invSimplexVector.push_back(SECOND_VERTEX_HANDLE);
- invSimplexVector.push_back(THIRD_VERTEX_HANDLE);
- invSimplexVector.push_back(FIRST_VERTEX_HANDLE);
+ typeVectorVertex invSimplexVector = { 1, 2, 0 };
simplexFound = simplexTree.find(invSimplexVector);
std::cout << "**************IS THE SIMPLEX {1,2,0} IN THE SIMPLEX TREE ?\n";
if (simplexFound != simplexTree.null_simplex())