summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Witness_complex/example/witness_complex_from_file.cpp3
-rw-r--r--src/Witness_complex/example/witness_complex_from_off.cpp44
-rw-r--r--src/Witness_complex/include/gudhi/Witness_complex.h26
3 files changed, 50 insertions, 23 deletions
diff --git a/src/Witness_complex/example/witness_complex_from_file.cpp b/src/Witness_complex/example/witness_complex_from_file.cpp
index c0e062fd..cf09899b 100644
--- a/src/Witness_complex/example/witness_complex_from_file.cpp
+++ b/src/Witness_complex/example/witness_complex_from_file.cpp
@@ -110,7 +110,8 @@ int main (int argc, char * const argv[])
// witnessComplex.witness_complex_from_points(point_vector);
std::vector<std::vector< int > > WL;
start = clock();
- witnessComplex.landmark_choice_by_furthest_points(point_vector, point_vector.size(), WL);
+ //witnessComplex.landmark_choice_by_furthest_points(point_vector, point_vector.size(), WL);
+ witnessComplex.landmark_choice_by_random_points(point_vector, point_vector.size(), WL);
end = clock();
std::cout << "Landmark choice took "
<< (double)(end-start)/CLOCKS_PER_SEC << " s. \n";
diff --git a/src/Witness_complex/example/witness_complex_from_off.cpp b/src/Witness_complex/example/witness_complex_from_off.cpp
index b1d7575a..04d4e601 100644
--- a/src/Witness_complex/example/witness_complex_from_off.cpp
+++ b/src/Witness_complex/example/witness_complex_from_off.cpp
@@ -23,6 +23,8 @@
#include <iostream>
#include <fstream>
#include <ctime>
+#include <sys/types.h>
+#include <sys/stat.h>
//#include <stdlib.h>
@@ -117,7 +119,8 @@ int main (int argc, char * const argv[])
clock_t start, end;
//Construct the Simplex Tree
Witness_complex<> witnessComplex;
-
+
+ /*
std::cout << "Let the carnage begin!\n";
start = clock();
Point_Vector point_vector;
@@ -137,4 +140,43 @@ int main (int argc, char * const argv[])
witnessComplex.st_to_file(ofs);
ofs.close();
}
+ */
+ std::cout << "Let the carnage begin!\n";
+ Point_Vector point_vector;
+ off_reader_cust(file_name, point_vector);
+ //std::cout << "Successfully read the points\n";
+ witnessComplex.setNbL(nbL);
+ // witnessComplex.witness_complex_from_points(point_vector);
+ std::vector<std::vector< int > > WL;
+ start = clock();
+ //witnessComplex.landmark_choice_by_furthest_points(point_vector, point_vector.size(), WL);
+ witnessComplex.landmark_choice_by_random_points(point_vector, point_vector.size(), WL);
+ end = clock();
+ std::cout << "Landmark choice took "
+ << (double)(end-start)/CLOCKS_PER_SEC << " s. \n";
+ // Write the WL matrix in a file
+ mkdir("output", S_IRWXU);
+ const size_t last_slash_idx = file_name.find_last_of("/");
+ if (std::string::npos != last_slash_idx)
+ {
+ file_name.erase(0, last_slash_idx + 1);
+ }
+ std::string out_file = "output/"+file_name+"_"+argv[2]+".wl";
+ //write_wl(out_file,WL);
+ start = clock();
+ witnessComplex.witness_complex(WL);
+ //
+ end = clock();
+ std::cout << "Howdy world! The process took "
+ << (double)(end-start)/CLOCKS_PER_SEC << " s. \n";
+
+ out_file = "output/"+file_name+"_"+argv[2]+".stree";
+ std::ofstream ofs (out_file, std::ofstream::out);
+ witnessComplex.st_to_file(ofs);
+ ofs.close();
+
+ out_file = "output/"+file_name+"_"+argv[2]+".badlinks";
+ std::ofstream ofs2(out_file, std::ofstream::out);
+ witnessComplex.write_bad_links(ofs2);
+ ofs2.close();
}
diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h
index c0199d92..f831ef44 100644
--- a/src/Witness_complex/include/gudhi/Witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Witness_complex.h
@@ -530,26 +530,7 @@ private:
out_file << "Bad links list\n";
std::cout << "Entered write_bad_links\n";
//typeVectorVertex testv = {9,15,17};
- /*
- Mein lieber Gott!
- Simplex_handle d1 = root()->members().find(9);
- if (d1 != root()->members().end())
- {
- Simplex_handle d2 = d1->second.children()->members().find(15);
- if (d2 != d1->second.children()->members().end())
- {
- Simplex_handle d3 = d2->second.children()->members().find(17);
- if (d3 != d2->second.children()->members().end())
- std::cout << "{9,15,17} is there\n";
- else
- std::cout << "Everything is jak maje być\n";
- }
- else
- std::cout << "{9,15} is not there\n";
- }
- else
- std::cout << "{9} is not there\n";
- */
+ int count = 0;
for (auto v: complex_vertex_range())
{
//std::cout << "Vertex " << v << ":\n";
@@ -571,8 +552,11 @@ private:
//std::cout << " dim " << d << "\n";
//Siblings* curr_sibl = root();
if (! link_is_pseudomanifold(link_vertices,d))
- out_file << "Bad link at " << v << "\n";
+ count++;
+ //out_file << "Bad link at " << v << "\n";
}
+ out_file << "Number of bad links: " << count << "/" << root()->size();
+ std::cout << "Number of bad links: " << count << "/" << root()->size() << std::endl;
}
private: