summaryrefslogtreecommitdiff
path: root/src/Persistence_representations/utilities/persistence_intervals
diff options
context:
space:
mode:
Diffstat (limited to 'src/Persistence_representations/utilities/persistence_intervals')
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt44
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp22
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp20
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp1
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp39
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp30
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp13
7 files changed, 81 insertions, 88 deletions
diff --git a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt
index 105b7efb..897e12a3 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt
+++ b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt
@@ -1,46 +1,32 @@
cmake_minimum_required(VERSION 2.6)
project(Persistence_representations_intervals_utilities)
-file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/")
-add_executable ( plot_persistence_intervals plot_persistence_intervals.cpp )
-target_link_libraries( plot_persistence_intervals ${Boost_SYSTEM_LIBRARY})
-
-add_test(NAME plot_persistence_intervals COMMAND $<TARGET_FILE:plot_persistence_intervals>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt")
-
-add_executable ( compute_birth_death_range_in_persistence_diagram compute_birth_death_range_in_persistence_diagram.cpp )
-target_link_libraries( compute_birth_death_range_in_persistence_diagram ${Boost_SYSTEM_LIBRARY})
-
-add_test(NAME compute_birth_death_range_in_persistence_diagram COMMAND $<TARGET_FILE:compute_birth_death_range_in_persistence_diagram>
- "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt")
+add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals_lengths.cpp )
-add_executable ( compute_number_of_dominant_intervals compute_number_of_dominant_intervals.cpp )
-target_link_libraries( compute_number_of_dominant_intervals ${Boost_SYSTEM_LIBRARY})
+add_test(NAME plot_histogram_of_intervals_lengths COMMAND $<TARGET_FILE:plot_histogram_of_intervals_lengths>
+ "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "-1")
-add_test(NAME compute_number_of_dominant_intervals COMMAND $<TARGET_FILE:compute_number_of_dominant_intervals>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" "-1" "2")
+add_persistence_representation_plot_utility(plot_persistence_intervals "")
+add_persistence_representation_plot_utility(plot_persistence_Betti_numbers "")
-add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals_lengths.cpp )
-target_link_libraries( plot_histogram_of_intervals_lengths ${Boost_SYSTEM_LIBRARY})
+add_persistence_representation_creation_utility(compute_birth_death_range_in_persistence_diagram "-1")
-add_test(NAME plot_histogram_of_intervals_lengths COMMAND $<TARGET_FILE:plot_histogram_of_intervals_lengths>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" "2")
-add_executable ( plot_persistence_Betti_numbers plot_persistence_Betti_numbers.cpp )
-target_link_libraries( plot_persistence_Betti_numbers ${Boost_SYSTEM_LIBRARY})
+add_executable ( compute_number_of_dominant_intervals compute_number_of_dominant_intervals.cpp )
+add_test(NAME Persistence_representation_utilities_compute_number_of_dominant_intervals
+ COMMAND $<TARGET_FILE:compute_number_of_dominant_intervals>
+ "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "-1" "2")
-add_test(NAME plot_persistence_Betti_numbers COMMAND $<TARGET_FILE:plot_persistence_Betti_numbers>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt")
if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1)
add_executable ( compute_bottleneck_distance compute_bottleneck_distance.cpp )
- target_link_libraries( compute_bottleneck_distance ${Boost_SYSTEM_LIBRARY})
if (TBB_FOUND)
target_link_libraries(compute_bottleneck_distance ${TBB_LIBRARIES})
endif(TBB_FOUND)
-
- add_test(NAME compute_bottleneck_distance COMMAND $<TARGET_FILE:compute_bottleneck_distance>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt"
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt")
+ add_test(NAME Persistence_representation_utilities_compute_bottleneck_distance
+ COMMAND $<TARGET_FILE:compute_bottleneck_distance>
+ "-1"
+ "${CMAKE_CURRENT_BINARY_DIR}/../first.pers"
+ "${CMAKE_CURRENT_BINARY_DIR}/../second.pers")
endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1)
diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp
index 66fa31ca..9102da79 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp
@@ -20,7 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
#include <iostream>
@@ -31,16 +30,21 @@
using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals;
int main(int argc, char** argv) {
- std::cout << "This program compute the range of birth and death times of persistence pairs in diagrams provided as "
- "an input. \n";
- std::cout << "The first parameter of the program is the dimension of persistence to be used. If your file contains ";
- std::cout << "the information about dimension of persistence pairs, please provide here the dimension of persistence "
- "pairs you want to use. If your input files consist only ";
- std::cout << "of birth-death pairs, please set this first parameter to -1 \n";
- std::cout << "The remaining parameters of the program are the names of files with persistence diagrams. \n";
+ std::cout << "This program computes the range of birth and death times of persistence pairs in diagrams provided as "
+ << "an input.\n"
+ << "The first parameter is the dimension of persistence to be used to create persistence intervals. "
+ << "If your file contains the information about dimension of persistence pairs, please provide here the "
+ << "dimension of persistence pairs you want to use. "
+ << "If your input files consist only of birth-death pairs, please set this first parameter to -1.\n"
+ << "The remaining parameters of the program are the names of files with persistence diagrams.\n";
+
+ if (argc < 3) {
+ std::cout << "Wrong parameter list, the program will now terminate \n";
+ return 1;
+ }
- int dim = atoi(argv[1]);
unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = atoi(argv[1]);
if (dim >= 0) {
dimension = (unsigned)dim;
}
diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp
index 0b1b526d..c8290845 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp
@@ -21,7 +21,6 @@
*/
#include <gudhi/Persistence_intervals_with_distances.h>
-#include <gudhi/read_persistence_from_file.h>
#include <iostream>
#include <sstream>
@@ -31,21 +30,21 @@
using Persistence_intervals_with_distances = Gudhi::Persistence_representations::Persistence_intervals_with_distances;
int main(int argc, char** argv) {
- std::cout << "This program compute the bottleneck distance of persistence diagrams stored in a files. \n";
- std::cout << "The first parameter of the program is the dimension of persistence to be used to construct persistence "
- "landscapes. If your file contains ";
- std::cout << "the information about dimension of persistence pairs, please provide here the dimension of persistence "
- "pairs you want to use. If your input files consist only ";
- std::cout << "of birth-death pairs, please set this first parameter to -1 \n";
- std::cout << "The remaining parameters of this programs are names of files with persistence diagrams.\n";
+ std::cout << "This program computes the bottleneck distance of persistence pairs in diagrams provided as "
+ << "an input.\n"
+ << "The first parameter is the dimension of persistence to be used to create persistence intervals. "
+ << "If your file contains the information about dimension of persistence pairs, please provide here the "
+ << "dimension of persistence pairs you want to use. "
+ << "If your input files consist only of birth-death pairs, please set this first parameter to -1.\n"
+ << "The remaining parameters of the program are the names of files with persistence diagrams.\n";
if (argc < 3) {
std::cout << "Wrong number of parameters, the program will now terminate \n";
return 1;
}
- int dim = atoi(argv[1]);
unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = atoi(argv[1]);
if (dim >= 0) {
dimension = (unsigned)dim;
}
@@ -80,7 +79,7 @@ int main(int argc, char** argv) {
// and now output the result to the screen and a file:
std::ofstream out;
- out.open("distance");
+ out.open("distance.itv");
for (size_t i = 0; i != distance.size(); ++i) {
for (size_t j = 0; j != distance.size(); ++j) {
std::cout << distance[i][j] << " ";
@@ -91,5 +90,6 @@ int main(int argc, char** argv) {
}
out.close();
+ std::cout << "Distance can be found in 'distance.itv' file\n";
return 0;
}
diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp
index 1286ca57..b3d126f0 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp
@@ -20,7 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
#include <iostream>
diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp
index d68f4584..ccb5b645 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp
@@ -20,7 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
#include <iostream>
@@ -31,30 +30,34 @@
using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals;
int main(int argc, char** argv) {
- std::cout << "This program compute a histogram of barcode's length. A number of bins in the histogram is a parameter "
- "of this program. \n";
- if (argc != 3) {
+ std::cout << "This program computes a histogram of barcode's length. A number of bins in the histogram is a "
+ << "parameter of this program. \n";
+ if ((argc != 3) && (argc != 4)) {
std::cout << "To run this program, please provide the name of a file with persistence diagram and number of "
- "dominant intervals you would like to get \n";
- std::cout << "The third parameter of a program is the dimension of the persistence that is to be used. If your "
- "file contains only birth-death pairs, you can skip this parameter\n";
+ << "dominant intervals you would like to get. Set a negative number dominant intervals value "
+ << "If your file contains only birth-death pairs.\n"
+ << "The third parameter is the dimension of the persistence that is to be used. If your "
+ << "file contains only birth-death pairs, you can skip this parameter\n";
return 1;
}
- unsigned dimension = std::numeric_limits<unsigned>::max();
- int dim = -1;
- if (argc > 2) {
- dim = atoi(argv[2]);
+
+ unsigned dominant_interval_number = std::numeric_limits<unsigned>::max();
+ int nbr = atoi(argv[2]);
+ if (nbr >= 0) {
+ dominant_interval_number = static_cast<unsigned>(nbr);
}
- if (dim >= 0) {
- dimension = (unsigned)dim;
+
+ int persistence_dimension = -1;
+ if (argc == 4) {
+ persistence_dimension = atoi(argv[3]);
}
- Persistence_intervals p(argv[1], dimension);
- std::vector<std::pair<double, double> > dominant_intervals = p.dominant_intervals(atoi(argv[2]));
+ Persistence_intervals p(argv[1], dominant_interval_number);
+ std::vector<std::pair<double, double> > dominant_intervals = p.dominant_intervals(persistence_dimension);
std::vector<size_t> histogram = p.histogram_of_lengths(10);
std::stringstream gnuplot_script;
- gnuplot_script << argv[1] << "_Gnuplot_script";
+ gnuplot_script << argv[1] << "_GnuplotScript";
std::ofstream out;
out.open(gnuplot_script.str().c_str());
@@ -66,7 +69,9 @@ int main(int argc, char** argv) {
out << histogram[i] << std::endl;
}
out << std::endl;
- std::cout << "To visualize, open gnuplot and type: load \'" << gnuplot_script.str().c_str() << "\'" << std::endl;
out.close();
+
+ std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'"
+ << gnuplot_script.str().c_str() << "\'\"" << std::endl;
return 0;
}
diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp
index da2b9319..b433c2b3 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp
@@ -20,7 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
#include <iostream>
@@ -31,29 +30,24 @@
using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals;
int main(int argc, char** argv) {
- std::cout << "This program compute a plot of persistence Betti numbers. The input parameter is a file with "
- "persistence intervals. \n";
- std::cout << "The second optional parameter of a program is the dimension of the persistence that is to be used. If "
- "your file contains only birth-death pairs, you can skip this parameter\n";
- if (argc < 2) {
- std::cout << "To run this program, please provide the name of a file with persistence diagram and number of "
- "dominant intervals you would like to get \n";
+ if ((argc != 3) && (argc != 2)) {
+ std::cout << "This program creates a gnuplot script of Betti numbers from a single persistence diagram file"
+ << "(*.pers).\n"
+ << "To run this program, please provide the name of a file with persistence diagram.\n"
+ << "The second optional parameter of a program is the dimension of the persistence that is to be used. "
+ << "If your file contains only birth-death pairs, you can skip this parameter.\n";
return 1;
}
+
unsigned dimension = std::numeric_limits<unsigned>::max();
int dim = -1;
- if (argc > 2) {
+ if (argc == 3) {
dim = atoi(argv[2]);
}
if (dim >= 0) {
dimension = (unsigned)dim;
}
- std::stringstream gnuplot_script;
- gnuplot_script << argv[1] << "_Gnuplot_script";
- std::ofstream out;
- out.open(gnuplot_script.str().c_str());
-
Persistence_intervals p(argv[1], dimension);
std::vector<std::pair<double, size_t> > pbns = p.compute_persistent_betti_numbers();
@@ -69,6 +63,11 @@ int main(int argc, char** argv) {
xRangeEnd += (xRangeEnd - xRangeBegin) / 100.0;
yRangeEnd += yRangeEnd / 100;
+ std::stringstream gnuplot_script;
+ gnuplot_script << argv[1] << "_GnuplotScript";
+ std::ofstream out;
+ out.open(gnuplot_script.str().c_str());
+
out << "set xrange [" << xRangeBegin << " : " << xRangeEnd << "]" << std::endl;
out << "set yrange [" << yRangeBegin << " : " << yRangeEnd << "]" << std::endl;
out << "plot '-' using 1:2 notitle with lp " << std::endl;
@@ -81,7 +80,8 @@ int main(int argc, char** argv) {
out << std::endl;
out.close();
- std::cout << "To visualize, open gnuplot and type: load \'" << gnuplot_script.str().c_str() << "\'" << std::endl;
+ std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'"
+ << gnuplot_script.str().c_str() << "\'\"" << std::endl;
return 0;
}
diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp
index e7d29e84..33387802 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp
@@ -20,9 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
-#include <gudhi/read_persistence_from_file.h>
#include <iostream>
#include <limits>
@@ -32,15 +30,16 @@
using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals;
int main(int argc, char** argv) {
- if (argc < 2) {
- std::cout << "To run this program, please provide the name of a file with persistence diagram \n";
- std::cout << "The second optional parameter of a program is the dimension of the persistence that is to be used. "
- "If your file contains only birth-death pairs, you can skip this parameter\n";
+ if ((argc != 3) && (argc != 2)) {
+ std::cout << "This program creates a gnuplot script from a single persistence diagram file (*.pers).\n"
+ << "To run this program, please provide the name of a file with persistence diagram.\n"
+ << "The second optional parameter of a program is the dimension of the persistence that is to be used. "
+ << "If your file contains only birth-death pairs, you can skip this parameter.\n";
return 1;
}
unsigned dimension = std::numeric_limits<unsigned>::max();
int dim = -1;
- if (argc > 2) {
+ if (argc == 3) {
dim = atoi(argv[2]);
}
if (dim >= 0) {