summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-05-09 14:04:29 +0000
committermcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-05-09 14:04:29 +0000
commit01b7bec722e18851acfc826ca572d01a127339c1 (patch)
treee6cef530da4187ac6841d8d682ca1d0797e54ff5
parentaa67dab1eebe3cdba573741857051005ba72cc3b (diff)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Nerve_GIC@2408 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 324d557360a52e7181d9cf3c7d77c8445a367808
-rw-r--r--src/Nerve_GIC/doc/Intro_graph_induced_complex.h72
-rw-r--r--src/Nerve_GIC/example/CMakeLists.txt17
-rw-r--r--src/Nerve_GIC/example/GIC.cpp23
-rw-r--r--src/Nerve_GIC/example/GIC.txt57
-rw-r--r--src/Nerve_GIC/example/MapperDeltaCoord.cpp (renamed from src/Nerve_GIC/example/MapperDelta.cpp)9
-rw-r--r--src/Nerve_GIC/example/MapperDeltaCoord.txt125
-rw-r--r--src/Nerve_GIC/example/MapperDeltaFunc.cpp61
-rw-r--r--src/Nerve_GIC/example/MapperDeltaFunc.txt16
-rw-r--r--src/Nerve_GIC/example/Nerve.cpp14
-rw-r--r--src/Nerve_GIC/example/Nerve.txt45
-rw-r--r--src/Nerve_GIC/example/simple_GIC.cpp77
-rw-r--r--src/Nerve_GIC/include/gudhi/GIC.h17
12 files changed, 396 insertions, 137 deletions
diff --git a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h
index 0b51e345..44e23983 100644
--- a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h
+++ b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h
@@ -33,9 +33,7 @@ namespace graph_induced_complex {
*
* @{
*
- * \section complexes Graph induced complexes (GIC) and Nerves
- *
- * GIC and Nerves are simplicial complexes built on top of a point cloud P.
+ * \section nerves Nerves
*
* \subsection nervedefinition Nerve definition
*
@@ -46,78 +44,106 @@ namespace graph_induced_complex {
*
* \subsection nerveexample Example
*
- * This example builds the Nerve of a point cloud sampled on a 3D human shape.
- * The cover C comes from the preimages of intervals covering the height function.
+ * This example builds the Nerve of a point cloud sampled on a 3D human shape (human.off).
+ * The cover C comes from the preimages of intervals (10 intervals with gain 0.3)
+ * covering the height function (coordinate 2),
+ * which are then refined into their connected components using the triangulation of the .OFF file.
* All intervals have the resolution (either the length or the number of the intervals)
* and gain (overlap percentage).
*
- * \include
+ * \include Nerve_GIC/Nerve.cpp
*
* When launching:
*
- * \code $>
+ * \code $> ./Nerve ../../../data/points/human.off 2 10 0.3
* \endcode
*
* the program output is:
*
- * \include
+ * \include Nerve_GIC/Nerve.txt
+ *
+ * \section gic Graph Induced Complexes (GIC)
*
- * \section gicdefinition GIC definition
+ * \subsection gicdefinition GIC definition
*
* Again, assume you are given a cover C of your point cloud P. Moreover, assume
* you are also given a graph G built on top of P. Then, for any clique in G
* whose nodes all belong to different elements of C, the GIC includes a corresponding
* simplex, whose dimension is the number of nodes in the clique minus one.
+ * See <a target="_blank" href="https://arxiv.org/abs/1304.0662"> this article </a>
+ * for more details.
*
* \subsection gicexample Example
*
- * This example builds the GIC of a point cloud sampled on a 3D human shape.
- * The cover C comes from the preimages of intervals covering the height function,
- * and the graph G comes from a Rips complex built with a threshold parameter.
+ * This example builds the GIC of a point cloud sampled on a 3D human shape (human.off).
+ * The cover C comes from the preimages of intervals (with length 0.1 and gain 0)
+ * covering the height function (coordinate 2),
+ * and the graph G comes from a Rips complex built with threshold 0.1.
* Note that if the gain is too big, the number of cliques increases a lot,
* which make the computation time much larger.
*
- * \include
+ * \include Nerve_GIC/GIC.cpp
*
* When launching:
*
- * \code $>
+ * \code $> ./GIC ../../../data/points/human.off 0.1 2 0.1 0
* \endcode
*
* the program output is:
*
- * \include
+ * \include Nerve_GIC/GIC.txt
*
* \subsection mapperdeltadefinition Mapper Delta
*
* If one restricts to the cliques in G whose nodes all belong to preimages of consecutive
* intervals (assuming the cover of the height function is minimal, i.e. no more than
* two intervals can intersect at a time), the GIC is of dimension one, i.e. a graph.
- * We call this graph the Mapper Delta, since it is related to the usual Mapper (see
- * <a target="_blank" href="https://arxiv.org/abs/1511.05823"> this article </a>).
+ * We call this graph the Mapper Delta, since it is related to the usual Mapper. See
+ * <a target="_blank" href="https://arxiv.org/abs/1511.05823"> this article </a> for more details.
*
* \subsection mapperdeltaexample Example
*
* Mapper Delta comes with optimal selection for the Rips threshold,
* the resolution and the gain of the function cover. In this example,
- * we compute the Mapper Delta of a point cloud sampled on a 3D human shape,
+ * we compute the Mapper Delta of a point cloud sampled on a 3D human shape (human.off),
* where the graph G comes from a Rips complex with optimal threshold,
- * and the cover C comes from the preimages of intervals covering the height function,
+ * and the cover C comes from the preimages of intervals covering the height function (coordinate 2),
* with optimal resolution and gain. Note that optimal threshold, resolution and gain
* also exist for the Nerve of this cover.
*
- * \include
+ * \include Nerve_GIC/MapperDeltaCoord.cpp
*
* When launching:
*
- * \code $>
+ * \code $> ./MapperDeltaCoord ../../../data/points/human.off 2
* \endcode
*
* the program output is:
*
- * \include
+ * \include MapperDeltaCoord.txt
+ *
+ * We also provide an example on a set of 72 pictures taken around the same object (lucky_cat.off).
+ * The function is now the first eigenfunction given by PCA, whose values
+ * are written in a file (lucky_cat_PCA1). Threshold, resolution and gain are automatically selected as before.
+ *
+ * \include Nerve_GIC/MapperDeltaFunc.cpp
+ *
+ * When launching:
+ *
+ * \code $> ./MapperDeltaFunc ../../../data/points/COIL_database/lucky_cat.off ../../../data/points/COIL_database/lucky_cat_PCA1
+ * \endcode
+ *
+ * the program output is:
+ *
+ * \include MapperDeltaFunc.txt
+ *
+ * If you have python and firefox, all the previous .txt files can then be plotted using
+ * <a target="_blank" href="https://github.com/MLWave/kepler-mapper"> Kepler-Mapper </a>
+ * with the following:
+ *
+ * \code python visu.py && firefox SC_visu.html
+ * \endcode
*
- *
* \copyright GNU General Public License v3.
* \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim
*/
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/MapperDeltaCoord.cpp
index 1f8f1582..aa12afe6 100644
--- a/src/Nerve_GIC/example/MapperDelta.cpp
+++ b/src/Nerve_GIC/example/MapperDeltaCoord.cpp
@@ -3,12 +3,12 @@
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";
+ 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));
+ if ((argc != 3) && (argc != 4)) usage(argc, (argv[0] - 1));
std::string off_file_name(argv[1]);
int coord = atoi(argv[2]);
@@ -28,9 +28,8 @@ int main(int argc, char **argv) {
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_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();
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 <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 \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 <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 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;
-}
diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h
index abd833e0..c373b25c 100644
--- a/src/Nerve_GIC/include/gudhi/GIC.h
+++ b/src/Nerve_GIC/include/gudhi/GIC.h
@@ -45,6 +45,7 @@
#include <algorithm> // for std::max
#include <cstdint> // for std::uint32_t
#include <random>
+#include <cassert>
#define CONSTANT 10
#define ETA 0.001
@@ -549,7 +550,7 @@ class Graph_induced_complex {
* @param[in] off_file_name name of the input .OFF file.
*
*/
- void set_color_from_coordinate(int k = 0, const std::string& off_file_name){
+ void set_color_from_coordinate(const std::string& off_file_name, int k = 0){
Points_off_reader<Point> off_reader(off_file_name);
int numpts = off_reader.get_point_cloud().size();
for(int i = 0; i < numpts; i++) func_color.insert(std::pair<int,double>(i,off_reader.get_point_cloud()[i][k]));
@@ -569,7 +570,7 @@ class Graph_induced_complex {
/** \brief Creates a .dot file for neato once the simplicial complex is computed to get a .pdf output.
*/
void plot_with_neato(){
- char mapp[11] = "mapper.dot"; std::ofstream graphic(mapp); graphic << "graph Mapper {" << std::endl;
+ char mapp[11] = "SC.dot"; std::ofstream graphic(mapp); graphic << "graph Mapper {" << std::endl;
double maxv, minv; maxv = std::numeric_limits<double>::min(); minv = std::numeric_limits<double>::max();
for (std::map<Cover_t,std::pair<int,double> >::iterator iit = cover_color.begin(); iit != cover_color.end(); iit++){
maxv = std::max(maxv, iit->second.second); minv = std::min(minv, iit->second.second);
@@ -598,7 +599,7 @@ class Graph_induced_complex {
void plot_with_KeplerMapper(){
int num_simplices = simplices.size(); int num_edges = 0;
- char mapp[11] = "mapper.txt"; std::ofstream graphic(mapp);
+ char mapp[11] = "SC.txt"; std::ofstream graphic(mapp);
for (int i = 0; i < num_simplices; i++)
if (simplices[i].size() == 2)
if (cover_color[simplices[i][0]].first > MASK && cover_color[simplices[i][1]].first > MASK)
@@ -711,11 +712,17 @@ class Graph_induced_complex {
}
public:
- /** \brief Computes the simplices in the Mapper Delta.
+ /** \brief Computes the simplices in the Mapper Delta by looking at all the edges of the graph
+ * and adding the corresponding edges in the Mapper Delta if the images of the endpoints belong
+ * to consecutive intervals.
+ *
+ * \remark WARNING: the output of this function is correct ONLY if the cover is minimal, i.e.
+ * the gain is less than 0.5!!!
+ *
*/
void find_GICMAP_simplices_with_functional_minimal_cover(){
- int v1, v2;
+ int v1, v2; assert(gain < 0.5);
// Loop on all points.
for(std::map<int,std::vector<Cover_t> >::iterator it = cover.begin(); it != cover.end(); it++){