diff options
author | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-05-29 14:45:32 +0000 |
---|---|---|
committer | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-05-29 14:45:32 +0000 |
commit | 2e0fed6817558aa0e887eb228642f7ebdd302d4c (patch) | |
tree | cde96fea6fa998d299803ac0b04e449a108ca90c /src/Nerve_GIC/example | |
parent | 17af44e0fcae39ceafa566bfd1e1de62e706aa0f (diff) |
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Nerve_GIC@2462 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: b158f4e6fab11aae7ee9927324829aa0b4c18026
Diffstat (limited to 'src/Nerve_GIC/example')
-rw-r--r-- | src/Nerve_GIC/example/GIC.cpp | 68 | ||||
-rw-r--r-- | src/Nerve_GIC/example/GICvoronoi.cpp | 68 | ||||
-rw-r--r-- | src/Nerve_GIC/example/MapperDeltaCoord.cpp | 72 | ||||
-rw-r--r-- | src/Nerve_GIC/example/MapperDeltaFunc.cpp | 72 | ||||
-rw-r--r-- | src/Nerve_GIC/example/MapperDeltaFunc.dot | 10 | ||||
-rw-r--r-- | src/Nerve_GIC/example/MapperDeltaFunc.txt | 10 | ||||
-rw-r--r-- | src/Nerve_GIC/example/Nerve.cpp | 74 |
7 files changed, 252 insertions, 122 deletions
diff --git a/src/Nerve_GIC/example/GIC.cpp b/src/Nerve_GIC/example/GIC.cpp index 1889cb33..0f50f712 100644 --- a/src/Nerve_GIC/example/GIC.cpp +++ b/src/Nerve_GIC/example/GIC.cpp @@ -1,3 +1,25 @@ +/* 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): Mathieu Carrière + * + * Copyright (C) 2017 INRIA Saclay (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/GIC.h> void usage(int nbArgs, char * const progName) { @@ -24,40 +46,44 @@ int main(int argc, char **argv) { Gudhi::graph_induced_complex::Graph_induced_complex GIC; GIC.set_verbose(verb); - GIC.read_point_cloud(off_file_name); + bool check = GIC.read_point_cloud(off_file_name); - GIC.set_color_from_coordinate(coord); - GIC.set_function_from_coordinate(coord); + if(!check) std::cout << "Incorrect OFF file." << std::endl; + else{ - GIC.set_graph_from_rips(threshold); + GIC.set_color_from_coordinate(coord); + GIC.set_function_from_coordinate(coord); - GIC.set_resolution_double(resolution); GIC.set_gain(gain); - GIC.set_cover_from_function(1); + GIC.set_graph_from_rips(threshold); - GIC.find_GIC_simplices(); + GIC.set_resolution_double(resolution); GIC.set_gain(gain); + GIC.set_cover_from_function(1); - GIC.plot_with_KeplerMapper(); + GIC.find_GIC_simplices(); - Simplex_tree stree; GIC.create_complex(stree); + GIC.plot_txt(); - std::streambuf* streambufffer = std::cout.rdbuf(); - std::ostream output_stream(streambufffer); + Simplex_tree stree; GIC.create_complex(stree); - // ---------------------------------------------------------------------------- - // Display information about the graph induced complex - // ---------------------------------------------------------------------------- + std::streambuf* streambufffer = std::cout.rdbuf(); + std::ostream output_stream(streambufffer); + + // ---------------------------------------------------------------------------- + // Display information about the graph induced complex + // ---------------------------------------------------------------------------- - if(verb){ - output_stream << "Graph induced complex is of dimension " << stree.dimension() << + if(verb){ + output_stream << "Graph induced complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices - " << stree.num_vertices() << " vertices." << std::endl; - output_stream << "Iterator on graph induced complex simplices" << std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - output_stream << vertex << " "; + output_stream << "Iterator on graph induced complex simplices" << std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + output_stream << vertex << " "; + } + output_stream << std::endl; } - output_stream << std::endl; } } diff --git a/src/Nerve_GIC/example/GICvoronoi.cpp b/src/Nerve_GIC/example/GICvoronoi.cpp index 9bf3de5e..8061c42d 100644 --- a/src/Nerve_GIC/example/GICvoronoi.cpp +++ b/src/Nerve_GIC/example/GICvoronoi.cpp @@ -1,3 +1,25 @@ +/* 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): Mathieu Carrière + * + * Copyright (C) 2017 INRIA Saclay (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/GIC.h> void usage(int nbArgs, char * const progName) { @@ -21,38 +43,42 @@ int main(int argc, char **argv) { Gudhi::graph_induced_complex::Graph_induced_complex GIC; GIC.set_verbose(verb); - GIC.read_point_cloud(off_file_name); + bool check = GIC.read_point_cloud(off_file_name); - GIC.set_color_from_coordinate(); + if(!check) std::cout << "Incorrect OFF file." << std::endl; + else{ - GIC.set_graph_from_OFF(off_file_name); + GIC.set_color_from_coordinate(); - GIC.set_cover_from_Voronoi(m); + GIC.set_graph_from_OFF(off_file_name); - GIC.find_GIC_simplices(); + GIC.set_cover_from_Voronoi(m); - GIC.plot_with_Geomview(); + GIC.find_GIC_simplices(); - Simplex_tree stree; GIC.create_complex(stree); + GIC.plot_OFF(); - std::streambuf* streambufffer = std::cout.rdbuf(); - std::ostream output_stream(streambufffer); + Simplex_tree stree; GIC.create_complex(stree); - // ---------------------------------------------------------------------------- - // Display information about the graph induced complex - // ---------------------------------------------------------------------------- + std::streambuf* streambufffer = std::cout.rdbuf(); + std::ostream output_stream(streambufffer); + + // ---------------------------------------------------------------------------- + // Display information about the graph induced complex + // ---------------------------------------------------------------------------- - if(verb){ - output_stream << "Graph induced complex is of dimension " << stree.dimension() << - " - " << stree.num_simplices() << " simplices - " << - stree.num_vertices() << " vertices." << std::endl; + if(verb){ + output_stream << "Graph induced complex is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.num_vertices() << " vertices." << std::endl; - output_stream << "Iterator on graph induced complex simplices" << std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - output_stream << vertex << " "; + output_stream << "Iterator on graph induced complex simplices" << std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + output_stream << vertex << " "; + } + output_stream << std::endl; } - output_stream << std::endl; } } diff --git a/src/Nerve_GIC/example/MapperDeltaCoord.cpp b/src/Nerve_GIC/example/MapperDeltaCoord.cpp index 9445e988..84a25bad 100644 --- a/src/Nerve_GIC/example/MapperDeltaCoord.cpp +++ b/src/Nerve_GIC/example/MapperDeltaCoord.cpp @@ -1,3 +1,25 @@ +/* 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): Mathieu Carrière + * + * Copyright (C) 2017 INRIA Saclay (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/GIC.h> void usage(int nbArgs, char * const progName) { @@ -21,40 +43,44 @@ int main(int argc, char **argv) { Gudhi::graph_induced_complex::Graph_induced_complex GIC; GIC.set_verbose(verb); - GIC.read_point_cloud(off_file_name); + bool check = GIC.read_point_cloud(off_file_name); + + if(!check) std::cout << "Incorrect OFF file." << std::endl; + else{ - GIC.set_color_from_coordinate(coord); - GIC.set_function_from_coordinate(coord); + GIC.set_color_from_coordinate(coord); + GIC.set_function_from_coordinate(coord); - GIC.set_graph_from_automatic_rips(); + GIC.set_graph_from_automatic_rips(); - GIC.set_automatic_resolution_for_GICMAP(); GIC.set_gain(); - GIC.set_cover_from_function(1); + GIC.set_automatic_resolution_for_GICMAP(); GIC.set_gain(); + GIC.set_cover_from_function(1); - GIC.find_GICMAP_simplices_with_functional_minimal_cover(); + GIC.find_GICMAP_simplices_with_functional_minimal_cover(); - GIC.plot_with_KeplerMapper(); + GIC.plot_txt(); - Simplex_tree stree; GIC.create_complex(stree); + Simplex_tree stree; GIC.create_complex(stree); - std::streambuf* streambufffer = std::cout.rdbuf(); - std::ostream output_stream(streambufffer); + std::streambuf* streambufffer = std::cout.rdbuf(); + std::ostream output_stream(streambufffer); - // ------------------------------------------ - // Display information about the Mapper Delta - // ------------------------------------------ + // ------------------------------------------ + // Display information about the Mapper Delta + // ------------------------------------------ - if(verb){ - output_stream << "Mapper Delta is of dimension " << stree.dimension() << - " - " << stree.num_simplices() << " simplices - " << - stree.num_vertices() << " vertices." << std::endl; + if(verb){ + output_stream << "Mapper Delta is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.num_vertices() << " vertices." << std::endl; - output_stream << "Iterator on Mapper Delta simplices" << std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - output_stream << vertex << " "; + output_stream << "Iterator on Mapper Delta simplices" << std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + output_stream << vertex << " "; + } + output_stream << std::endl; } - output_stream << std::endl; } } diff --git a/src/Nerve_GIC/example/MapperDeltaFunc.cpp b/src/Nerve_GIC/example/MapperDeltaFunc.cpp index 448323b1..fa95ca58 100644 --- a/src/Nerve_GIC/example/MapperDeltaFunc.cpp +++ b/src/Nerve_GIC/example/MapperDeltaFunc.cpp @@ -1,3 +1,25 @@ +/* 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): Mathieu Carrière + * + * Copyright (C) 2017 INRIA Saclay (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/GIC.h> void usage(int nbArgs, char * const progName) { @@ -21,40 +43,44 @@ int main(int argc, char **argv) { Gudhi::graph_induced_complex::Graph_induced_complex GIC; GIC.set_verbose(verb); - GIC.read_point_cloud(off_file_name); + bool check = GIC.read_point_cloud(off_file_name); + + if(!check) std::cout << "Incorrect OFF file." << std::endl; + else{ - GIC.set_color_from_file(func_file_name); - GIC.set_function_from_file(func_file_name); + GIC.set_color_from_file(func_file_name); + GIC.set_function_from_file(func_file_name); - GIC.set_graph_from_automatic_rips(); + GIC.set_graph_from_automatic_rips(); - GIC.set_automatic_resolution_for_GICMAP(); GIC.set_gain(); - GIC.set_cover_from_function(1); + GIC.set_automatic_resolution_for_GICMAP(); GIC.set_gain(); + GIC.set_cover_from_function(1); - GIC.find_GICMAP_simplices_with_functional_minimal_cover(); + GIC.find_GICMAP_simplices_with_functional_minimal_cover(); - GIC.plot_with_KeplerMapper(); + GIC.plot_pdf(); - Simplex_tree stree; GIC.create_complex(stree); + Simplex_tree stree; GIC.create_complex(stree); - std::streambuf* streambufffer = std::cout.rdbuf(); - std::ostream output_stream(streambufffer); + std::streambuf* streambufffer = std::cout.rdbuf(); + std::ostream output_stream(streambufffer); - // ------------------------------------------ - // Display information about the Mapper Delta - // ------------------------------------------ + // ------------------------------------------ + // Display information about the Mapper Delta + // ------------------------------------------ - if(verb){ - output_stream << "Mapper Delta is of dimension " << stree.dimension() << - " - " << stree.num_simplices() << " simplices - " << - stree.num_vertices() << " vertices." << std::endl; + if(verb){ + output_stream << "Mapper Delta is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.num_vertices() << " vertices." << std::endl; - output_stream << "Iterator on Mapper Delta simplices" << std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - output_stream << vertex << " "; + output_stream << "Iterator on Mapper Delta simplices" << std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + output_stream << vertex << " "; + } + output_stream << std::endl; } - output_stream << std::endl; } } diff --git a/src/Nerve_GIC/example/MapperDeltaFunc.dot b/src/Nerve_GIC/example/MapperDeltaFunc.dot new file mode 100644 index 00000000..beafa7f1 --- /dev/null +++ b/src/Nerve_GIC/example/MapperDeltaFunc.dot @@ -0,0 +1,10 @@ +graph Mapper { +0[shape=circle fontcolor=black color=black label="0:26" style=filled fillcolor="0, 1, 1"] +1[shape=circle fontcolor=black color=black label="1:4" style=filled fillcolor="0.240095, 1, 1"] +2[shape=circle fontcolor=black color=black label="2:11" style=filled fillcolor="0.209621, 1, 1"] +3[shape=circle fontcolor=black color=black label="3:42" style=filled fillcolor="0.6, 1, 1"] + 0 -- 1 [weight=15]; + 0 -- 2 [weight=15]; + 1 -- 3 [weight=15]; + 2 -- 3 [weight=15]; +}
\ No newline at end of file diff --git a/src/Nerve_GIC/example/MapperDeltaFunc.txt b/src/Nerve_GIC/example/MapperDeltaFunc.txt deleted file mode 100644 index d13d0695..00000000 --- a/src/Nerve_GIC/example/MapperDeltaFunc.txt +++ /dev/null @@ -1,10 +0,0 @@ -Mapper Delta is of dimension 1 - 8 simplices - 4 vertices. -Iterator on Mapper Delta simplices -0 -1 -1 0 -2 -2 0 -3 -3 1 -3 2 diff --git a/src/Nerve_GIC/example/Nerve.cpp b/src/Nerve_GIC/example/Nerve.cpp index 84f74625..8f8037d4 100644 --- a/src/Nerve_GIC/example/Nerve.cpp +++ b/src/Nerve_GIC/example/Nerve.cpp @@ -1,9 +1,31 @@ +/* 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): Mathieu Carrière + * + * Copyright (C) 2017 INRIA Saclay (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/GIC.h> void usage(int nbArgs, char * const progName) { std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; std::cerr << "Usage: " << progName << " filename.off coordinate resolution gain [--v] \n"; - std::cerr << " i.e.: " << progName << " ../../../../data/human.off 2 10 0.3 --v \n"; + std::cerr << " i.e.: " << progName << " ../../../../data/points/human.off 2 10 0.3 --v \n"; exit(-1); // ----- >> } @@ -23,40 +45,44 @@ int main(int argc, char **argv) { Gudhi::graph_induced_complex::Graph_induced_complex GIC; GIC.set_verbose(verb); - GIC.read_point_cloud(off_file_name); + bool check = GIC.read_point_cloud(off_file_name); + + if(!check) std::cout << "Incorrect OFF file." << std::endl; + else{ - GIC.set_color_from_coordinate(coord); - GIC.set_function_from_coordinate(coord); + GIC.set_color_from_coordinate(coord); + GIC.set_function_from_coordinate(coord); - GIC.set_graph_from_OFF(off_file_name); + GIC.set_graph_from_OFF(off_file_name); - GIC.set_resolution_int(resolution); GIC.set_gain(gain); - GIC.set_cover_from_function(0); + GIC.set_resolution_int(resolution); GIC.set_gain(gain); + GIC.set_cover_from_function(0); - GIC.find_Nerve_simplices(); + GIC.find_Nerve_simplices(); - GIC.plot_with_KeplerMapper(); + GIC.plot_txt(); - Simplex_tree stree; GIC.create_complex(stree); + Simplex_tree stree; GIC.create_complex(stree); - std::streambuf* streambufffer = std::cout.rdbuf(); - std::ostream output_stream(streambufffer); + std::streambuf* streambufffer = std::cout.rdbuf(); + std::ostream output_stream(streambufffer); - // ---------------------------------------------------------------------------- - // Display information about the graph induced complex - // ---------------------------------------------------------------------------- + // ---------------------------------------------------------------------------- + // Display information about the graph induced complex + // ---------------------------------------------------------------------------- - if(verb){ - output_stream << "Nerve is of dimension " << stree.dimension() << - " - " << stree.num_simplices() << " simplices - " << - stree.num_vertices() << " vertices." << std::endl; + if(verb){ + output_stream << "Nerve is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.num_vertices() << " vertices." << std::endl; - output_stream << "Iterator on Nerve simplices" << std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - output_stream << vertex << " "; + output_stream << "Iterator on Nerve simplices" << std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + output_stream << vertex << " "; + } + output_stream << std::endl; } - output_stream << std::endl; } } |