From 01b7bec722e18851acfc826ca572d01a127339c1 Mon Sep 17 00:00:00 2001 From: mcarrier Date: Tue, 9 May 2017 14:04:29 +0000 Subject: git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Nerve_GIC@2408 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 324d557360a52e7181d9cf3c7d77c8445a367808 --- src/Nerve_GIC/example/CMakeLists.txt | 17 +++- src/Nerve_GIC/example/GIC.cpp | 23 ++---- src/Nerve_GIC/example/GIC.txt | 57 +++++++++++++ src/Nerve_GIC/example/MapperDelta.cpp | 62 -------------- src/Nerve_GIC/example/MapperDeltaCoord.cpp | 61 ++++++++++++++ src/Nerve_GIC/example/MapperDeltaCoord.txt | 125 +++++++++++++++++++++++++++++ src/Nerve_GIC/example/MapperDeltaFunc.cpp | 61 ++++++++++++++ src/Nerve_GIC/example/MapperDeltaFunc.txt | 16 ++++ src/Nerve_GIC/example/Nerve.cpp | 14 ++-- src/Nerve_GIC/example/Nerve.txt | 45 +++++++++++ src/Nerve_GIC/example/simple_GIC.cpp | 77 ------------------ 11 files changed, 392 insertions(+), 166 deletions(-) create mode 100644 src/Nerve_GIC/example/GIC.txt delete mode 100644 src/Nerve_GIC/example/MapperDelta.cpp create mode 100644 src/Nerve_GIC/example/MapperDeltaCoord.cpp create mode 100644 src/Nerve_GIC/example/MapperDeltaCoord.txt create mode 100644 src/Nerve_GIC/example/MapperDeltaFunc.cpp create mode 100644 src/Nerve_GIC/example/MapperDeltaFunc.txt create mode 100644 src/Nerve_GIC/example/Nerve.txt delete mode 100644 src/Nerve_GIC/example/simple_GIC.cpp (limited to 'src/Nerve_GIC/example') diff --git a/src/Nerve_GIC/example/CMakeLists.txt b/src/Nerve_GIC/example/CMakeLists.txt index e4debf2d..d499613d 100644 --- a/src/Nerve_GIC/example/CMakeLists.txt +++ b/src/Nerve_GIC/example/CMakeLists.txt @@ -1,8 +1,21 @@ cmake_minimum_required(VERSION 2.6) project(Nerve_GIC_examples) -add_executable ( GIC simple_GIC.cpp ) -target_link_libraries(GIC ${Boost_SYSTEM_LIBRARY}) +add_executable ( Nerve Nerve.cpp ) +target_link_libraries(Nerve ${Boost_SYSTEM_LIBRARY}) + +add_executable ( GIC GIC.cpp ) +target_link_libraries(GIC ${Boost_SYSTEM_LIBRARY}) + +add_executable ( MapperDeltaCoord MapperDeltaCoord.cpp ) +target_link_libraries(MapperDeltaCoord ${Boost_SYSTEM_LIBRARY}) + +add_executable ( MapperDeltaFunc MapperDeltaFunc.cpp ) +target_link_libraries(MapperDeltaFunc ${Boost_SYSTEM_LIBRARY}) + if (TBB_FOUND) + target_link_libraries(Nerve ${TBB_LIBRARIES}) target_link_libraries(GIC ${TBB_LIBRARIES}) + target_link_libraries(MapperDeltaCoord ${TBB_LIBRARIES}) + target_link_libraries(MapperDeltaFunc ${TBB_LIBRARIES}) endif() \ No newline at end of file diff --git a/src/Nerve_GIC/example/GIC.cpp b/src/Nerve_GIC/example/GIC.cpp index 5161a46b..30a485d5 100644 --- a/src/Nerve_GIC/example/GIC.cpp +++ b/src/Nerve_GIC/example/GIC.cpp @@ -3,7 +3,7 @@ void usage(int nbArgs, char * const progName) { std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; std::cerr << "Usage: " << progName << " filename.off threshold coordinate resolution gain\n"; - std::cerr << " i.e.: " << progName << " ../../data/points/test.off 1.5 1 10 0.3 \n"; + std::cerr << " i.e.: " << progName << " ../../../data/points/human.off 1.5 2 10 0.3 \n"; exit(-1); // ----- >> } @@ -12,7 +12,6 @@ int main(int argc, char **argv) { std::string off_file_name(argv[1]); double threshold = atof(argv[2]); - //std::string func_file_name = argv[3]; int coord = atoi(argv[3]); double resolution = atof(argv[4]); double gain = atof(argv[5]); @@ -30,24 +29,12 @@ int main(int argc, char **argv) { Gudhi::graph_induced_complex::Graph_induced_complex GIC; GIC.set_verbose(verb); - GIC.set_graph_from_automatic_rips(off_file_name); - //GIC.set_graph_from_rips(threshold, off_file_name); - //GIC.set_graph_from_OFF(off_file_name); - + GIC.set_graph_from_rips(threshold, off_file_name); GIC.set_function_from_coordinate(coord, off_file_name); - //GIC.set_function_from_file(func_file_name); - - GIC.set_color_from_coordinate(coord, off_file_name); - //GIC.set_color_from_file(func_file_name); - - GIC.set_automatic_resolution_for_GICMAP(); - GIC.set_gain(); + GIC.set_color_from_coordinate(off_file_name, coord); + GIC.set_resolution_double(resolution); GIC.set_gain(gain); GIC.set_cover_from_function(1); - - //GIC.find_GIC_simplices(); - //GIC.find_Nerve_simplices(); - GIC.find_GICMAP_simplices_with_functional_minimal_cover(); - + GIC.find_GIC_simplices(); GIC.plot_with_KeplerMapper(); Simplex_tree stree; GIC.create_complex(stree); diff --git a/src/Nerve_GIC/example/GIC.txt b/src/Nerve_GIC/example/GIC.txt new file mode 100644 index 00000000..9871cf41 --- /dev/null +++ b/src/Nerve_GIC/example/GIC.txt @@ -0,0 +1,57 @@ +Cloud +Function +0 0 +27 26 +0 -0.949318 240 +1 -0.949346 240 +2 -0.822129 50 +3 -0.822037 51 +4 -0.723847 48 +5 -0.722679 48 +6 -0.625409 57 +7 -0.625771 57 +8 -0.528161 99 +9 -0.528188 99 +10 -0.436343 126 +11 -0.436356 126 +12 -0.330775 194 +13 -0.233638 98 +14 -0.116276 100 +15 -0.129017 144 +16 -0.116513 103 +17 -0.0213554 243 +18 -0.0301512 65 +19 -0.0315443 66 +20 0.0750623 308 +21 0.166778 305 +22 0.270037 307 +23 0.371609 380 +24 0.468078 306 +25 0.567395 312 +26 0.721079 534 +0 3 +1 2 +2 5 +3 4 +4 7 +5 6 +6 9 +7 8 +8 10 +9 11 +10 12 +11 12 +12 13 +13 15 +14 19 +15 17 +16 18 +17 20 +18 20 +19 20 +20 21 +21 22 +22 23 +23 24 +24 25 +25 26 diff --git a/src/Nerve_GIC/example/MapperDelta.cpp b/src/Nerve_GIC/example/MapperDelta.cpp deleted file mode 100644 index 1f8f1582..00000000 --- a/src/Nerve_GIC/example/MapperDelta.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include - -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 \n"; - std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 --v \n"; - exit(-1); // ----- >> -} - -int main(int argc, char **argv) { - if ((argc != 6) && (argc != 7)) usage(argc, (argv[0] - 1)); - - std::string off_file_name(argv[1]); - int coord = atoi(argv[2]); - bool verb = 0; if(argc == 4) verb = 1; - - // Type definitions - using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,\ - boost::property < vertex_filtration_t, Filtration_value >,\ - boost::property < edge_filtration_t, Filtration_value > >; - - // --------------------------------------- - // Init of a Mapper Delta from an OFF file - // --------------------------------------- - - Gudhi::graph_induced_complex::Graph_induced_complex GIC; - GIC.set_verbose(verb); - - GIC.set_graph_from_automatic_rips(off_file_name); - GIC.set_function_from_coordinate(coord, off_file_name); - GIC.set_color_from_coordinate(coord, off_file_name); - GIC.set_automatic_resolution_for_GICMAP(); - GIC.set_gain(); - GIC.set_cover_from_function(1); - GIC.find_GICMAP_simplices_with_functional_minimal_cover(); - GIC.plot_with_KeplerMapper(); - - Simplex_tree stree; GIC.create_complex(stree); - - std::streambuf* streambufffer = std::cout.rdbuf(); - std::ostream output_stream(streambufffer); - - // ------------------------------------------ - // 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; - - 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; - } - } - - return 0; -} diff --git a/src/Nerve_GIC/example/MapperDeltaCoord.cpp b/src/Nerve_GIC/example/MapperDeltaCoord.cpp new file mode 100644 index 00000000..aa12afe6 --- /dev/null +++ b/src/Nerve_GIC/example/MapperDeltaCoord.cpp @@ -0,0 +1,61 @@ +#include + +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 \n"; + std::cerr << " i.e.: " << progName << " ../../../data/points/human.off 2 --v \n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { + if ((argc != 3) && (argc != 4)) usage(argc, (argv[0] - 1)); + + std::string off_file_name(argv[1]); + int coord = atoi(argv[2]); + bool verb = 0; if(argc == 4) verb = 1; + + // Type definitions + using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,\ + boost::property < vertex_filtration_t, Filtration_value >,\ + boost::property < edge_filtration_t, Filtration_value > >; + + // --------------------------------------- + // Init of a Mapper Delta from an OFF file + // --------------------------------------- + + Gudhi::graph_induced_complex::Graph_induced_complex GIC; + GIC.set_verbose(verb); + + GIC.set_graph_from_automatic_rips(off_file_name); + GIC.set_function_from_coordinate(coord, off_file_name); + GIC.set_color_from_coordinate(off_file_name, coord); + GIC.set_automatic_resolution_for_GICMAP(); GIC.set_gain(); + GIC.set_cover_from_function(1); + GIC.find_GICMAP_simplices_with_functional_minimal_cover(); + GIC.plot_with_KeplerMapper(); + + Simplex_tree stree; GIC.create_complex(stree); + + std::streambuf* streambufffer = std::cout.rdbuf(); + std::ostream output_stream(streambufffer); + + // ------------------------------------------ + // 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; + + 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; + } + } + + return 0; +} diff --git a/src/Nerve_GIC/example/MapperDeltaCoord.txt b/src/Nerve_GIC/example/MapperDeltaCoord.txt new file mode 100644 index 00000000..2c2296ea --- /dev/null +++ b/src/Nerve_GIC/example/MapperDeltaCoord.txt @@ -0,0 +1,125 @@ +Cloud +Function +0 0 +61 60 +0 -0.954369 220 +1 -0.954377 220 +2 -0.902361 54 +3 -0.901235 55 +4 -0.84796 27 +5 -0.844637 29 +6 -0.777883 37 +7 -0.778882 39 +8 -0.72868 42 +9 -0.72734 42 +10 -0.677728 48 +11 -0.676848 48 +12 -0.633796 48 +13 -0.634232 48 +14 -0.567924 52 +15 -0.567897 52 +16 -0.52287 77 +17 -0.522897 77 +18 -0.467859 105 +19 -0.467886 105 +20 -0.422377 87 +21 -0.422383 87 +22 -0.363537 80 +23 -0.363508 80 +24 -0.312836 126 +25 -0.267775 84 +26 -0.197152 78 +27 -0.149293 96 +28 -0.134636 48 +29 -0.134463 51 +30 -0.104389 93 +31 -0.108561 96 +32 -0.105219 93 +33 -0.0362235 183 +34 -0.0498358 53 +35 -0.050197 51 +36 -0.000444973 187 +37 0.000472738 42 +38 -0.000214643 42 +39 0.0616246 164 +40 0.0590725 29 +41 0.0590271 31 +42 0.108834 170 +43 0.110991 50 +44 0.110952 50 +45 0.158372 129 +46 0.161945 54 +47 0.161972 54 +48 0.210958 76 +49 0.221521 73 +50 0.221548 73 +51 0.263419 220 +52 0.324345 241 +53 0.371963 311 +54 0.422902 272 +55 0.476693 223 +56 0.530461 246 +57 0.58285 217 +58 0.63636 203 +59 0.690953 230 +60 0.76296 309 +0 3 +1 2 +2 4 +3 5 +4 6 +5 7 +6 9 +7 8 +8 10 +9 11 +10 13 +11 12 +12 14 +13 15 +14 17 +15 16 +16 18 +17 19 +18 20 +19 21 +20 22 +21 23 +22 24 +23 24 +24 25 +25 26 +26 27 +27 31 +28 30 +29 32 +30 35 +31 33 +32 34 +33 36 +34 37 +35 38 +36 39 +37 41 +38 40 +39 42 +40 43 +41 44 +42 45 +43 46 +44 47 +45 48 +46 49 +47 50 +48 51 +49 51 +50 51 +51 52 +52 53 +53 54 +54 55 +55 56 +56 57 +57 58 +58 59 +59 60 diff --git a/src/Nerve_GIC/example/MapperDeltaFunc.cpp b/src/Nerve_GIC/example/MapperDeltaFunc.cpp new file mode 100644 index 00000000..20924b9c --- /dev/null +++ b/src/Nerve_GIC/example/MapperDeltaFunc.cpp @@ -0,0 +1,61 @@ +#include + +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 \n"; + std::cerr << " i.e.: " << progName << " ../../../data/points/human.off 2 --v \n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { + if ((argc != 3) && (argc != 4)) usage(argc, (argv[0] - 1)); + + std::string off_file_name(argv[1]); + std::string func_file_name = argv[2]; + bool verb = 0; if(argc == 4) verb = 1; + + // Type definitions + using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,\ + boost::property < vertex_filtration_t, Filtration_value >,\ + boost::property < edge_filtration_t, Filtration_value > >; + + // --------------------------------------- + // Init of a Mapper Delta from an OFF file + // --------------------------------------- + + Gudhi::graph_induced_complex::Graph_induced_complex GIC; + GIC.set_verbose(verb); + + GIC.set_graph_from_automatic_rips(off_file_name); + GIC.set_function_from_file(func_file_name); + GIC.set_color_from_file(func_file_name); + GIC.set_automatic_resolution_for_GICMAP(); GIC.set_gain(); + GIC.set_cover_from_function(1); + GIC.find_GICMAP_simplices_with_functional_minimal_cover(); + GIC.plot_with_KeplerMapper(); + + Simplex_tree stree; GIC.create_complex(stree); + + std::streambuf* streambufffer = std::cout.rdbuf(); + std::ostream output_stream(streambufffer); + + // ------------------------------------------ + // 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; + + 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; + } + } + + return 0; +} diff --git a/src/Nerve_GIC/example/MapperDeltaFunc.txt b/src/Nerve_GIC/example/MapperDeltaFunc.txt new file mode 100644 index 00000000..046d2278 --- /dev/null +++ b/src/Nerve_GIC/example/MapperDeltaFunc.txt @@ -0,0 +1,16 @@ +Cloud +Function +0 0 +6 6 +0 -1382.24 20 +1 385.162 3 +2 246.455 12 +3 2204.66 4 +4 2238.94 5 +5 5346.1 39 +0 1 +0 2 +1 3 +2 4 +3 5 +4 5 diff --git a/src/Nerve_GIC/example/Nerve.cpp b/src/Nerve_GIC/example/Nerve.cpp index adcc715d..d4a68c71 100644 --- a/src/Nerve_GIC/example/Nerve.cpp +++ b/src/Nerve_GIC/example/Nerve.cpp @@ -3,16 +3,16 @@ 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/points/human.off 2 1 0.3 --v \n"; + std::cerr << " i.e.: " << progName << " ../../../data/points/human.off 2 10 0.3 --v \n"; exit(-1); // ----- >> } int main(int argc, char **argv) { - if ((argc != 6) && (argc != 7)) usage(argc, (argv[0] - 1)); + if ((argc != 5) && (argc != 6)) usage(argc, (argv[0] - 1)); std::string off_file_name(argv[1]); int coord = atoi(argv[2]); - double resolution = atof(argv[3]); + int resolution = atoi(argv[3]); double gain = atof(argv[4]); bool verb = 0; if(argc == 6) verb = 1; @@ -28,11 +28,11 @@ int main(int argc, char **argv) { Gudhi::graph_induced_complex::Graph_induced_complex GIC; GIC.set_verbose(verb); + GIC.set_graph_from_OFF(off_file_name); GIC.set_function_from_coordinate(coord, off_file_name); - GIC.set_color_from_coordinate(coord, off_file_name); - GIC.set_resolution_double(resolution); - GIC.set_gain(gain); - GIC.set_cover_from_function(1); + GIC.set_color_from_coordinate(off_file_name, --coord); + GIC.set_resolution_int(resolution); GIC.set_gain(gain); + GIC.set_cover_from_function(0); GIC.find_Nerve_simplices(); GIC.plot_with_KeplerMapper(); diff --git a/src/Nerve_GIC/example/Nerve.txt b/src/Nerve_GIC/example/Nerve.txt new file mode 100644 index 00000000..9ebb2fbb --- /dev/null +++ b/src/Nerve_GIC/example/Nerve.txt @@ -0,0 +1,45 @@ +Cloud +Function +0 0 +21 20 +0 -0.0149926 290 +1 -0.0152551 291 +2 -0.0695028 127 +3 -0.0700955 128 +4 -0.0449554 250 +5 -0.045006 251 +6 -0.0130144 247 +7 -0.0131973 247 +8 0.0766414 127 +9 -0.0118972 165 +10 -0.0121551 165 +11 0.0785204 128 +12 0.0559145 183 +13 -0.0298394 542 +14 0.0569878 181 +15 -0.0201742 388 +16 -0.00110905 208 +17 -0.00131087 208 +18 0.0228028 854 +19 0.0181739 764 +20 0.0307483 597 +0 2 +1 3 +2 5 +3 4 +4 6 +5 7 +6 9 +7 10 +8 12 +9 13 +10 13 +11 14 +12 16 +13 15 +14 17 +15 18 +16 18 +17 18 +18 19 +19 20 diff --git a/src/Nerve_GIC/example/simple_GIC.cpp b/src/Nerve_GIC/example/simple_GIC.cpp deleted file mode 100644 index 5161a46b..00000000 --- a/src/Nerve_GIC/example/simple_GIC.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include - -void usage(int nbArgs, char * const progName) { - std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " filename.off threshold coordinate resolution gain\n"; - std::cerr << " i.e.: " << progName << " ../../data/points/test.off 1.5 1 10 0.3 \n"; - exit(-1); // ----- >> -} - -int main(int argc, char **argv) { - if ((argc != 6) && (argc != 7)) usage(argc, (argv[0] - 1)); - - std::string off_file_name(argv[1]); - double threshold = atof(argv[2]); - //std::string func_file_name = argv[3]; - int coord = atoi(argv[3]); - double resolution = atof(argv[4]); - double gain = atof(argv[5]); - bool verb = 0; if(argc == 7) verb = 1; - - // Type definitions - using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,\ - boost::property < vertex_filtration_t, Filtration_value >,\ - boost::property < edge_filtration_t, Filtration_value > >; - - // ---------------------------------------------------------------------------- - // Init of a graph induced complex from an OFF file - // ---------------------------------------------------------------------------- - - Gudhi::graph_induced_complex::Graph_induced_complex GIC; - GIC.set_verbose(verb); - - GIC.set_graph_from_automatic_rips(off_file_name); - //GIC.set_graph_from_rips(threshold, off_file_name); - //GIC.set_graph_from_OFF(off_file_name); - - GIC.set_function_from_coordinate(coord, off_file_name); - //GIC.set_function_from_file(func_file_name); - - GIC.set_color_from_coordinate(coord, off_file_name); - //GIC.set_color_from_file(func_file_name); - - GIC.set_automatic_resolution_for_GICMAP(); - GIC.set_gain(); - GIC.set_cover_from_function(1); - - //GIC.find_GIC_simplices(); - //GIC.find_Nerve_simplices(); - GIC.find_GICMAP_simplices_with_functional_minimal_cover(); - - GIC.plot_with_KeplerMapper(); - - Simplex_tree stree; GIC.create_complex(stree); - - 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; - - 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; - } - } - - return 0; -} -- cgit v1.2.3