summaryrefslogtreecommitdiff
path: root/src/Nerve_GIC
diff options
context:
space:
mode:
authormcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-05-25 09:27:36 +0000
committermcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-05-25 09:27:36 +0000
commit52b0f4082174888c190a005fd55232e3c38b99d4 (patch)
treea38ff0166e42bafcc81f00f6f0e9e48d2ce0b29a /src/Nerve_GIC
parent78335c71e46bd3b77d1595edef63cedbe6cf006c (diff)
parent979de853d97225b2b5466ec0a896a06dd08325e9 (diff)
small modif to avoid assert on compute_PD()
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Nerve_GIC@3459 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b0e73b4e1e77743419b06d142467ebfceacf83cf
Diffstat (limited to 'src/Nerve_GIC')
-rw-r--r--src/Nerve_GIC/doc/COPYRIGHT2
-rw-r--r--src/Nerve_GIC/doc/Intro_graph_induced_complex.h46
-rw-r--r--src/Nerve_GIC/example/CMakeLists.txt24
-rw-r--r--src/Nerve_GIC/example/CoordGIC.cpp6
-rw-r--r--src/Nerve_GIC/example/FuncGIC.cpp6
-rw-r--r--src/Nerve_GIC/example/GIC.cpp95
-rwxr-xr-xsrc/Nerve_GIC/example/KeplerMapperVisuFromTxtFile.py72
-rw-r--r--src/Nerve_GIC/include/gudhi/GIC.h36
-rw-r--r--src/Nerve_GIC/test/test_GIC.cpp2
-rw-r--r--src/Nerve_GIC/utilities/CMakeLists.txt28
-rwxr-xr-xsrc/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py89
-rw-r--r--src/Nerve_GIC/utilities/Nerve.cpp (renamed from src/Nerve_GIC/example/Nerve.cpp)6
-rw-r--r--src/Nerve_GIC/utilities/Nerve.txt (renamed from src/Nerve_GIC/example/Nerve.txt)0
-rw-r--r--src/Nerve_GIC/utilities/VoronoiGIC.cpp (renamed from src/Nerve_GIC/example/VoronoiGIC.cpp)6
-rw-r--r--src/Nerve_GIC/utilities/covercomplex.md69
-rwxr-xr-xsrc/Nerve_GIC/utilities/km.py (renamed from src/Nerve_GIC/example/km.py)0
-rw-r--r--src/Nerve_GIC/utilities/km.py.COPYRIGHT (renamed from src/Nerve_GIC/example/km.py.COPYRIGHT)0
17 files changed, 236 insertions, 251 deletions
diff --git a/src/Nerve_GIC/doc/COPYRIGHT b/src/Nerve_GIC/doc/COPYRIGHT
index 0c36a526..6b33053e 100644
--- a/src/Nerve_GIC/doc/COPYRIGHT
+++ b/src/Nerve_GIC/doc/COPYRIGHT
@@ -4,7 +4,7 @@ computational topology.
Author(s): Mathieu Carrière
-Copyright (C) 2017 INRIA
+Copyright (C) 2017 Inria
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
diff --git a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h
index 7578cc53..bc8aecc3 100644
--- a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h
+++ b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h
@@ -4,7 +4,7 @@
*
* Author(s): Mathieu Carriere
*
- * Copyright (C) 2017 INRIA
+ * Copyright (C) 2017 Inria
*
* 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
@@ -70,15 +70,15 @@ namespace cover_complex {
*
* When launching:
*
- * \code $> ./Nerve ../../data/points/human.off 2 10 0.3 --v
+ * \code $> ./Nerve ../../data/points/human.off 2 10 0.3 -v
* \endcode
*
* the program output is:
*
* \include Nerve_GIC/Nerve.txt
*
- * The program also writes a file SC.txt. The first three lines in this file are the location of the input point cloud
- * and the function used to compute the cover.
+ * The program also writes a file ../../data/points/human_sc.txt. The first three lines in this file are the location
+ * of the input point cloud and the function used to compute the cover.
* The fourth line contains the number of vertices nv and edges ne of the Nerve.
* The next nv lines represent the vertices. Each line contains the vertex ID,
* the number of data points it contains, and their average color function value.
@@ -113,12 +113,12 @@ namespace cover_complex {
*
* When launching:
*
- * \code $> ./VoronoiGIC ../../data/points/human.off 700 --v
+ * \code $> ./VoronoiGIC ../../data/points/human.off 700 -v
* \endcode
*
* the program outputs SC.off. Using e.g.
*
- * \code $> geomview SC.off
+ * \code $> geomview ../../data/points/human_sc.off
* \endcode
*
* one can obtain the following visualization:
@@ -146,7 +146,7 @@ namespace cover_complex {
*
* When launching:
*
- * \code $> ./CoordGIC ../../data/points/KleinBottle5D.off 0 --v
+ * \code $> ./CoordGIC ../../data/points/KleinBottle5D.off 0 -v
* \endcode
*
* the program outputs SC.dot. Using e.g.
@@ -169,15 +169,13 @@ namespace cover_complex {
*
* When launching:
*
- * \code $> ./FuncGIC ../../data/points/COIL_database/lucky_cat.off ../../data/points/COIL_database/lucky_cat_PCA1 --v
+ * \code $> ./FuncGIC ../../data/points/COIL_database/lucky_cat.off ../../data/points/COIL_database/lucky_cat_PCA1 -v
* \endcode
*
* the program outputs again SC.dot which gives the following visualization after using neato:
*
* \image html "funcGICvisu.jpg" "Visualization with neato"
*
- * \copyright GNU General Public License v3.
- * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim
*/
/** @} */ // end defgroup cover_complex
@@ -186,31 +184,3 @@ namespace cover_complex {
} // namespace Gudhi
#endif // DOC_COVER_COMPLEX_INTRO_COVER_COMPLEX_H_
-
-
-/* * \subsection gicexample Example with cover from function
- *
- * 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.075 and gain 0)
- * covering the height function (coordinate 2),
- * and the graph G comes from a Rips complex built with threshold 0.075.
- * Note that if the gain is too big, the number of cliques increases a lot,
- * which make the computation time much larger.
- *
- * \include Nerve_GIC/GIC.cpp
- *
- * When launching:
- *
- * \code $> ./GIC ../../data/points/human.off 0.075 2 0.075 0 --v
- * \endcode
- *
- * the program outputs SC.txt, which can be visualized with python and firefox as before:
- *
- * \image html "gicvisu.jpg" "Visualization with KeplerMapper"
- * */
-
-
-/* * Using e.g.
- *
- * \code $> python KeplerMapperVisuFromTxtFile.py && firefox SC.html
- * \endcode */
diff --git a/src/Nerve_GIC/example/CMakeLists.txt b/src/Nerve_GIC/example/CMakeLists.txt
index 73728dc0..542c6af4 100644
--- a/src/Nerve_GIC/example/CMakeLists.txt
+++ b/src/Nerve_GIC/example/CMakeLists.txt
@@ -3,31 +3,27 @@ project(Nerve_GIC_examples)
if (NOT CGAL_VERSION VERSION_LESS 4.8.1)
- add_executable ( Nerve Nerve.cpp )
add_executable ( CoordGIC CoordGIC.cpp )
add_executable ( FuncGIC FuncGIC.cpp )
- add_executable ( VoronoiGIC VoronoiGIC.cpp )
if (TBB_FOUND)
- target_link_libraries(Nerve ${TBB_LIBRARIES})
target_link_libraries(CoordGIC ${TBB_LIBRARIES})
target_link_libraries(FuncGIC ${TBB_LIBRARIES})
- target_link_libraries(VoronoiGIC ${TBB_LIBRARIES})
endif()
- file(COPY KeplerMapperVisuFromTxtFile.py km.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
-
- add_test(NAME Nerve_GIC_example_nerve COMMAND $<TARGET_FILE:Nerve>
- "${CMAKE_SOURCE_DIR}/data/points/human.off" "2" "10" "0.3")
-
- add_test(NAME Nerve_GIC_example_VoronoiGIC COMMAND $<TARGET_FILE:VoronoiGIC>
- "${CMAKE_SOURCE_DIR}/data/points/human.off" "100")
+ # Copy files for not to pollute sources when testing
+ file(COPY "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+ file(COPY "${CMAKE_SOURCE_DIR}/data/points/COIL_database/lucky_cat.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+ file(COPY "${CMAKE_SOURCE_DIR}/data/points/COIL_database/lucky_cat_PCA1" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
add_test(NAME Nerve_GIC_example_CoordGIC COMMAND $<TARGET_FILE:CoordGIC>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "0")
+ "tore3D_1307.off" "0")
add_test(NAME Nerve_GIC_example_FuncGIC COMMAND $<TARGET_FILE:FuncGIC>
- "${CMAKE_SOURCE_DIR}/data/points/COIL_database/lucky_cat.off"
- "${CMAKE_SOURCE_DIR}/data/points/COIL_database/lucky_cat_PCA1")
+ "lucky_cat.off"
+ "lucky_cat_PCA1")
+
+ install(TARGETS CoordGIC DESTINATION bin)
+ install(TARGETS FuncGIC DESTINATION bin)
endif (NOT CGAL_VERSION VERSION_LESS 4.8.1)
diff --git a/src/Nerve_GIC/example/CoordGIC.cpp b/src/Nerve_GIC/example/CoordGIC.cpp
index 7e595382..73edae18 100644
--- a/src/Nerve_GIC/example/CoordGIC.cpp
+++ b/src/Nerve_GIC/example/CoordGIC.cpp
@@ -4,7 +4,7 @@
*
* Author(s): Mathieu Carrière
*
- * Copyright (C) 2017 INRIA
+ * Copyright (C) 2017 Inria
*
* 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
@@ -27,8 +27,8 @@
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 [--v] \n";
- std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 --v \n";
+ std::cerr << "Usage: " << progName << " filename.off coordinate [-v] \n";
+ std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 -v \n";
exit(-1); // ----- >>
}
diff --git a/src/Nerve_GIC/example/FuncGIC.cpp b/src/Nerve_GIC/example/FuncGIC.cpp
index 3762db4e..1f5de999 100644
--- a/src/Nerve_GIC/example/FuncGIC.cpp
+++ b/src/Nerve_GIC/example/FuncGIC.cpp
@@ -4,7 +4,7 @@
*
* Author(s): Mathieu Carrière
*
- * Copyright (C) 2017 INRIA
+ * Copyright (C) 2017 Inria
*
* 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
@@ -27,9 +27,9 @@
void usage(int nbArgs, char *const progName) {
std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n";
- std::cerr << "Usage: " << progName << " filename.off function [--v] \n";
+ std::cerr << "Usage: " << progName << " filename.off function [-v] \n";
std::cerr << " i.e.: " << progName << " ../../data/points/COIL_database/lucky_cat.off "
- "../../data/points/COIL_database/lucky_cat_PCA1 --v \n";
+ "../../data/points/COIL_database/lucky_cat_PCA1 -v \n";
exit(-1); // ----- >>
}
diff --git a/src/Nerve_GIC/example/GIC.cpp b/src/Nerve_GIC/example/GIC.cpp
deleted file mode 100644
index 2bc24a4d..00000000
--- a/src/Nerve_GIC/example/GIC.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/* 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
- *
- * 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>
-
-#include <string>
-#include <vector>
-
-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 [--v] \n";
- std::cerr << " i.e.: " << progName << " ../../data/points/human.off 0.075 2 0.075 0 --v \n";
- exit(-1); // ----- >>
-}
-
-int main(int argc, char **argv) {
- if ((argc != 6) && (argc != 7)) usage(argc, argv[0]);
-
- using Point = std::vector<float>;
-
- std::string off_file_name(argv[1]);
- double threshold = atof(argv[2]);
- int coord = atoi(argv[3]);
- double resolution = atof(argv[4]);
- double gain = atof(argv[5]);
- bool verb = 0;
- if (argc == 7) verb = 1;
-
- // ----------------------------------------------------------------------------
- // Init of a graph induced complex from an OFF file
- // ----------------------------------------------------------------------------
-
- Gudhi::graph_induced_complex::Graph_induced_complex<Point> GIC;
- GIC.set_verbose(verb);
-
- 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_graph_from_rips(threshold, Gudhi::Euclidean_distance());
-
- GIC.set_resolution_with_interval_length(resolution);
- GIC.set_gain(gain);
- GIC.set_cover_from_function();
-
- GIC.find_GIC_simplices();
-
- GIC.plot_TXT_for_KeplerMapper();
-
- Gudhi::Simplex_tree<> stree;
- GIC.create_complex(stree);
-
- // ----------------------------------------------------------------------------
- // Display information about the graph induced complex
- // ----------------------------------------------------------------------------
-
- if (verb) {
- std::cout << "Graph induced complex is of dimension " << stree.dimension() << " - " << stree.num_simplices()
- << " simplices - " << stree.num_vertices() << " vertices." << std::endl;
-
- std::cout << "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)) {
- std::cout << vertex << " ";
- }
- std::cout << std::endl;
- }
- }
- }
-
- return 0;
-}
diff --git a/src/Nerve_GIC/example/KeplerMapperVisuFromTxtFile.py b/src/Nerve_GIC/example/KeplerMapperVisuFromTxtFile.py
deleted file mode 100755
index d2897774..00000000
--- a/src/Nerve_GIC/example/KeplerMapperVisuFromTxtFile.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env python
-
-import km
-import numpy as np
-from collections import defaultdict
-
-"""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 Carriere
-
- Copyright (C) 2017 INRIA
-
- 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/>.
-"""
-
-__author__ = "Mathieu Carriere"
-__copyright__ = "Copyright (C) 2017 INRIA"
-__license__ = "GPL v3"
-
-network = {}
-mapper = km.KeplerMapper(verbose=0)
-data = np.zeros((3,3))
-projected_data = mapper.fit_transform( data, projection="sum", scaler=None )
-
-f = open('SC.txt','r')
-nodes = defaultdict(list)
-links = defaultdict(list)
-custom = defaultdict(list)
-
-dat = f.readline()
-lens = f.readline()
-color = f.readline();
-param = [float(i) for i in f.readline().split(" ")]
-
-nums = [int(i) for i in f.readline().split(" ")]
-num_nodes = nums[0]
-num_edges = nums[1]
-
-for i in range(0,num_nodes):
- point = [float(j) for j in f.readline().split(" ")]
- nodes[ str(int(point[0])) ] = [ int(point[0]), point[1], int(point[2]) ]
- links[ str(int(point[0])) ] = []
- custom[ int(point[0]) ] = point[1]
-
-m = min([custom[i] for i in range(0,num_nodes)])
-M = max([custom[i] for i in range(0,num_nodes)])
-
-for i in range(0,num_edges):
- edge = [int(j) for j in f.readline().split(" ")]
- links[ str(edge[0]) ].append( str(edge[1]) )
- links[ str(edge[1]) ].append( str(edge[0]) )
-
-network["nodes"] = nodes
-network["links"] = links
-network["meta"] = lens
-
-mapper.visualize(network, color_function = color, path_html="SC.html", title=dat,
-graph_link_distance=30, graph_gravity=0.1, graph_charge=-120, custom_tooltips=custom, width_html=0,
-height_html=0, show_tooltips=True, show_title=True, show_meta=True, res=param[0],gain=param[1], minimum=m,maximum=M)
diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h
index e6c508fc..8834858c 100644
--- a/src/Nerve_GIC/include/gudhi/GIC.h
+++ b/src/Nerve_GIC/include/gudhi/GIC.h
@@ -4,7 +4,7 @@
*
* Author: Mathieu Carriere
*
- * Copyright (C) 2017 INRIA
+ * Copyright (C) 2017 Inria
*
* 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
@@ -63,6 +63,7 @@ namespace Gudhi {
namespace cover_complex {
using Simplex_tree = Gudhi::Simplex_tree<>;
+using Simplex_handle = Simplex_tree::Simplex_handle;
using Filtration_value = Simplex_tree::Filtration_value;
using Rips_complex = Gudhi::rips_complex::Rips_complex<Filtration_value>;
using Persistence_diagram = std::vector<std::pair<double, double> >;
@@ -269,6 +270,7 @@ class Cover_complex {
point_cloud.emplace_back(point.begin(), point.begin() + data_dimension);
boost::add_vertex(one_skeleton_OFF);
vertices.push_back(boost::add_vertex(one_skeleton)); cover.emplace_back();
+ cover.emplace_back();
i++;
}
}
@@ -369,9 +371,8 @@ class Cover_complex {
double d;
std::vector<double> zeros(n);
for (int i = 0; i < n; i++) distances.push_back(zeros);
- std::string distance = point_cloud_name;
- distance.append("_dist");
- std::ifstream input(distance.c_str(), std::ios::out | std::ios::binary);
+ std::string distance = point_cloud_name + "_dist";
+ std::ifstream input(distance, std::ios::out | std::ios::binary);
if (input.good()) {
if (verbose) std::cout << "Reading distances..." << std::endl;
@@ -487,7 +488,7 @@ class Cover_complex {
char coordinate[100];
sprintf(coordinate, "coordinate %d", k);
functional_cover = true;
- cover_name = coordinate;
+ cover_name = "coordinate " + std::to_string(k);
}
public: // Set function from vector.
@@ -955,8 +956,7 @@ class Cover_complex {
* of its 1-skeleton in a .pdf file.
*/
void plot_DOT() {
- char mapp[100];
- sprintf(mapp, "%s_sc.dot", point_cloud_name.c_str());
+ std::string mapp = point_cloud_name + "_sc.dot";
std::ofstream graphic(mapp);
double maxv = std::numeric_limits<double>::lowest();
@@ -996,7 +996,7 @@ class Cover_complex {
}
graphic << "}";
graphic.close();
- std::cout << ".dot file generated. It can be visualized with e.g. neato." << std::endl;
+ std::cout << mapp << " file generated. It can be visualized with e.g. neato." << std::endl;
}
public: // Create a .txt file that can be compiled with KeplerMapper.
@@ -1006,8 +1006,7 @@ class Cover_complex {
void write_info() {
int num_simplices = simplices.size();
int num_edges = 0;
- char mapp[100];
- sprintf(mapp, "%s_sc.txt", point_cloud_name.c_str());
+ std::string mapp = point_cloud_name + "_sc.txt";
std::ofstream graphic(mapp);
for (int i = 0; i < num_simplices; i++)
@@ -1033,7 +1032,8 @@ class Cover_complex {
if (cover_color[simplices[i][0]].first > mask && cover_color[simplices[i][1]].first > mask)
graphic << name2id[simplices[i][0]] << " " << name2id[simplices[i][1]] << std::endl;
graphic.close();
- std::cout << ".txt generated. It can be visualized with e.g. python KeplerMapperVisuFromTxtFile.py and firefox."
+ std::cout << mapp
+ << " generated. It can be visualized with e.g. python KeplerMapperVisuFromTxtFile.py and firefox."
<< std::endl;
}
@@ -1051,9 +1051,8 @@ class Cover_complex {
std::vector<std::vector<int> > edges, faces;
int numsimplices = simplices.size();
- char gic[100];
- sprintf(gic, "%s_sc.off", point_cloud_name.c_str());
- std::ofstream graphic(gic);
+ std::string mapp = point_cloud_name + "_sc.off";
+ std::ofstream graphic(mapp);
graphic << "OFF" << std::endl;
for (int i = 0; i < numsimplices; i++) {
@@ -1080,7 +1079,7 @@ class Cover_complex {
for (int i = 0; i < numfaces; i++)
graphic << 3 << " " << faces[i][0] << " " << faces[i][1] << " " << faces[i][2] << std::endl;
graphic.close();
- std::cout << ".off generated. It can be visualized with e.g. geomview." << std::endl;
+ std::cout << mapp << " generated. It can be visualized with e.g. geomview." << std::endl;
}
// *******************************************************************************************************************
@@ -1111,8 +1110,9 @@ class Cover_complex {
for (std::map<int, double>::iterator it = cover_std.begin(); it != cover_std.end(); it++) {
int vertex = it->first; float val = it->second;
int vert[] = {vertex}; int edge[] = {vertex, -2};
- st.assign_filtration(st.find(vert), -2 + (val - minf)/(maxf - minf));
- st.assign_filtration(st.find(edge), 2 - (val - minf)/(maxf - minf));
+ Simplex_handle shv = st.find(vert); Simplex_handle she = st.find(edge);
+ if(shv != st.null_simplex()) st.assign_filtration(shv, -2 + (val - minf)/(maxf - minf));
+ if(she != st.null_simplex()) st.assign_filtration(she, 2 - (val - minf)/(maxf - minf));
}
st.make_filtration_non_decreasing();
@@ -1167,7 +1167,7 @@ class Cover_complex {
Cboot.point_cloud.push_back(this->point_cloud[id]); Cboot.cover.emplace_back(); Cboot.func.push_back(this->func[id]);
boost::add_vertex(Cboot.one_skeleton_OFF); Cboot.vertices.push_back(boost::add_vertex(Cboot.one_skeleton));
}
- Cboot.set_color_from_vector(Cboot.func);
+ Cboot.set_color_from_vector(Cboot.func);
for (int j = 0; j < n; j++) {
std::vector<double> dist(n);
diff --git a/src/Nerve_GIC/test/test_GIC.cpp b/src/Nerve_GIC/test/test_GIC.cpp
index e3067d35..0db2cce2 100644
--- a/src/Nerve_GIC/test/test_GIC.cpp
+++ b/src/Nerve_GIC/test/test_GIC.cpp
@@ -4,7 +4,7 @@
*
* Author(s): Mathieu Carrière
*
- * Copyright (C) 2017 INRIA
+ * Copyright (C) 2017 Inria
*
* 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
diff --git a/src/Nerve_GIC/utilities/CMakeLists.txt b/src/Nerve_GIC/utilities/CMakeLists.txt
new file mode 100644
index 00000000..7a838a8c
--- /dev/null
+++ b/src/Nerve_GIC/utilities/CMakeLists.txt
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 2.6)
+project(Nerve_GIC_examples)
+
+if (NOT CGAL_VERSION VERSION_LESS 4.8.1)
+
+ add_executable ( Nerve Nerve.cpp )
+ add_executable ( VoronoiGIC VoronoiGIC.cpp )
+
+ if (TBB_FOUND)
+ target_link_libraries(Nerve ${TBB_LIBRARIES})
+ target_link_libraries(VoronoiGIC ${TBB_LIBRARIES})
+ endif()
+
+ file(COPY KeplerMapperVisuFromTxtFile.py km.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+ # Copy files for not to pollute sources when testing
+ file(COPY "${CMAKE_SOURCE_DIR}/data/points/human.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+
+ add_test(NAME Nerve_GIC_utilities_nerve COMMAND $<TARGET_FILE:Nerve>
+ "human.off" "2" "10" "0.3")
+
+ add_test(NAME Nerve_GIC_utilities_VoronoiGIC COMMAND $<TARGET_FILE:VoronoiGIC>
+ "human.off" "100")
+
+ install(TARGETS Nerve DESTINATION bin)
+ install(TARGETS VoronoiGIC DESTINATION bin)
+ install(FILES KeplerMapperVisuFromTxtFile.py km.py km.py.COPYRIGHT DESTINATION bin)
+
+endif (NOT CGAL_VERSION VERSION_LESS 4.8.1)
diff --git a/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py b/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py
new file mode 100755
index 00000000..701e7a52
--- /dev/null
+++ b/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+import km
+import numpy as np
+from collections import defaultdict
+import argparse
+
+"""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 Carriere
+
+ Copyright (C) 2017 Inria
+
+ 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/>.
+"""
+
+__author__ = "Mathieu Carriere"
+__copyright__ = "Copyright (C) 2017 Inria"
+__license__ = "GPL v3"
+
+parser = argparse.ArgumentParser(description='Creates an html Keppler Mapper '
+ 'file to visualize a SC.txt file.',
+ epilog='Example: '
+ './KeplerMapperVisuFromTxtFile.py '
+ '-f ../../data/points/human.off_sc.txt'
+ '- Constructs an human.off_sc.html file.')
+parser.add_argument("-f", "--file", type=str, required=True)
+
+args = parser.parse_args()
+
+with open(args.file, 'r') as f:
+ network = {}
+ mapper = km.KeplerMapper(verbose=0)
+ data = np.zeros((3,3))
+ projected_data = mapper.fit_transform( data, projection="sum", scaler=None )
+
+ nodes = defaultdict(list)
+ links = defaultdict(list)
+ custom = defaultdict(list)
+
+ dat = f.readline()
+ lens = f.readline()
+ color = f.readline();
+ param = [float(i) for i in f.readline().split(" ")]
+
+ nums = [int(i) for i in f.readline().split(" ")]
+ num_nodes = nums[0]
+ num_edges = nums[1]
+
+ for i in range(0,num_nodes):
+ point = [float(j) for j in f.readline().split(" ")]
+ nodes[ str(int(point[0])) ] = [ int(point[0]), point[1], int(point[2]) ]
+ links[ str(int(point[0])) ] = []
+ custom[ int(point[0]) ] = point[1]
+
+ m = min([custom[i] for i in range(0,num_nodes)])
+ M = max([custom[i] for i in range(0,num_nodes)])
+
+ for i in range(0,num_edges):
+ edge = [int(j) for j in f.readline().split(" ")]
+ links[ str(edge[0]) ].append( str(edge[1]) )
+ links[ str(edge[1]) ].append( str(edge[0]) )
+
+ network["nodes"] = nodes
+ network["links"] = links
+ network["meta"] = lens
+
+ html_output_filename = args.file.rsplit('.', 1)[0] + '.html'
+ mapper.visualize(network, color_function = color, path_html=html_output_filename, title=dat,
+ graph_link_distance=30, graph_gravity=0.1, graph_charge=-120, custom_tooltips=custom, width_html=0,
+ height_html=0, show_tooltips=True, show_title=True, show_meta=True, res=param[0],gain=param[1], minimum=m,maximum=M)
+ message = repr(html_output_filename) + " is generated. You can now use your favorite web browser to visualize it."
+ print(message)
+
+
+ f.close()
diff --git a/src/Nerve_GIC/example/Nerve.cpp b/src/Nerve_GIC/utilities/Nerve.cpp
index 6abdedc7..667129e0 100644
--- a/src/Nerve_GIC/example/Nerve.cpp
+++ b/src/Nerve_GIC/utilities/Nerve.cpp
@@ -4,7 +4,7 @@
*
* Author(s): Mathieu Carrière
*
- * Copyright (C) 2017 INRIA
+ * Copyright (C) 2017 Inria
*
* 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
@@ -27,8 +27,8 @@
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 10 0.3 --v \n";
+ std::cerr << "Usage: " << progName << " filename.off coordinate resolution gain [-v] \n";
+ std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 10 0.3 -v \n";
exit(-1); // ----- >>
}
diff --git a/src/Nerve_GIC/example/Nerve.txt b/src/Nerve_GIC/utilities/Nerve.txt
index 839ff45e..839ff45e 100644
--- a/src/Nerve_GIC/example/Nerve.txt
+++ b/src/Nerve_GIC/utilities/Nerve.txt
diff --git a/src/Nerve_GIC/example/VoronoiGIC.cpp b/src/Nerve_GIC/utilities/VoronoiGIC.cpp
index 32431cc2..33deca40 100644
--- a/src/Nerve_GIC/example/VoronoiGIC.cpp
+++ b/src/Nerve_GIC/utilities/VoronoiGIC.cpp
@@ -4,7 +4,7 @@
*
* Author(s): Mathieu Carrière
*
- * Copyright (C) 2017 INRIA
+ * Copyright (C) 2017 Inria
*
* 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
@@ -27,8 +27,8 @@
void usage(int nbArgs, char *const progName) {
std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n";
- std::cerr << "Usage: " << progName << " filename.off N [--v] \n";
- std::cerr << " i.e.: " << progName << " ../../data/points/human.off 100 --v \n";
+ std::cerr << "Usage: " << progName << " filename.off N [-v] \n";
+ std::cerr << " i.e.: " << progName << " ../../data/points/human.off 100 -v \n";
exit(-1); // ----- >>
}
diff --git a/src/Nerve_GIC/utilities/covercomplex.md b/src/Nerve_GIC/utilities/covercomplex.md
new file mode 100644
index 00000000..683c1b75
--- /dev/null
+++ b/src/Nerve_GIC/utilities/covercomplex.md
@@ -0,0 +1,69 @@
+---
+layout: page
+title: "Cover complex"
+meta_title: "Cover complex"
+teaser: ""
+permalink: /covercomplex/
+---
+{::comment}
+Leave the lines above as it is required by the web site generator 'Jekyll'
+{:/comment}
+
+
+## Nerve ##
+This program builds the Nerve of a point cloud sampled on an OFF file.
+The cover C comes from the preimages of intervals covering a coordinate function,
+which are then refined into their connected components using the triangulation of the .OFF file.
+
+The program also writes a file SC.txt.
+The first three lines in this file are the location of the input point cloud and the function used to compute the cover.
+The fourth line contains the number of vertices nv and edges ne of the Nerve. The next nv lines represent the vertices.
+Each line contains the vertex ID, the number of data points it contains, and their average color function value.
+Finally, the next ne lines represent the edges, characterized by the ID of their vertices.
+
+**Usage**
+
+`Nerve <OFF input file> coordinate resolution gain [-v]`
+
+where
+
+* `coordinate` is the coordinate function to cover
+* `resolution` is the number of the intervals
+* `gain` is the gain for each interval
+* `-v` is optional, it activates verbose mode.
+
+**Example**
+
+`Nerve ../../data/points/human.off 2 10 0.3`
+
+* 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).
+
+`python KeplerMapperVisuFromTxtFile.py -f ../../data/points/human.off_sc.txt`
+
+* Constructs `human.off_sc.html` file. You can now use your favorite web browser to visualize it.
+
+## VoronoiGIC ##
+
+This util builds the Graph Induced Complex (GIC) of a point cloud.
+It subsamples *N* points in the point cloud, which act as seeds of a geodesic Voronoï diagram.
+Each cell of the diagram is then an element of C.
+
+The program also writes a file `*_sc.off`, that is an OFF file that can be visualized with GeomView.
+
+**Usage**
+
+`VoroniGIC <OFF input file> samples_number [-v]`
+
+where
+
+* `samples_number` is the number of samples to take from the point cloud
+* `-v` is optional, it activates verbose mode.
+
+**Example**
+
+`VoroniGIC ../../data/points/human.off 700`
+
+* Builds the Voronoi Graph Induced Complex with 700 subsamples from `human.off` file.
+`../../data/points/human_sc.off` can be visualized with GeomView.
+
diff --git a/src/Nerve_GIC/example/km.py b/src/Nerve_GIC/utilities/km.py
index 53024aab..53024aab 100755
--- a/src/Nerve_GIC/example/km.py
+++ b/src/Nerve_GIC/utilities/km.py
diff --git a/src/Nerve_GIC/example/km.py.COPYRIGHT b/src/Nerve_GIC/utilities/km.py.COPYRIGHT
index bef7b121..bef7b121 100644
--- a/src/Nerve_GIC/example/km.py.COPYRIGHT
+++ b/src/Nerve_GIC/utilities/km.py.COPYRIGHT