summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-09-18 15:46:22 +0000
committermcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-09-18 15:46:22 +0000
commitbe30f17d2ea337995215eedbcc831de0236c5e35 (patch)
tree02f7bae93d54533aec8b5b6fb90ed2813ef57073
parent7ea58c3ab5543c4a04638690eaebe1591ca47215 (diff)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Nerve_GIC@2683 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: cacaa8d543cb35bfd709092262809deb102230d5
-rwxr-xr-xdata/points/KleinBottle5D.off3
-rw-r--r--src/Nerve_GIC/doc/Intro_graph_induced_complex.h2
-rw-r--r--src/Nerve_GIC/include/gudhi/GIC.h31
3 files changed, 20 insertions, 16 deletions
diff --git a/data/points/KleinBottle5D.off b/data/points/KleinBottle5D.off
index ea5c3fa3..b578593c 100755
--- a/data/points/KleinBottle5D.off
+++ b/data/points/KleinBottle5D.off
@@ -1,4 +1,5 @@
-OFF
+nOFF
+5
15876 0 0
3 0 0 0 1
3.05 0 0.09983 0 0.9988
diff --git a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h
index 8d807f4b..c3930d1e 100644
--- a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h
+++ b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h
@@ -83,7 +83,7 @@ namespace graph_induced_complex {
* Finally, the next ne lines represent the edges, characterized by the ID of their vertices.
* Using e.g.
*
- * \code $> python visu.py && firefox SC.html
+ * \code $> python KeplerMapperVisuFromTxtFile.py && firefox SC.html
* \endcode
*
* one can obtain the following visualization:
diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h
index f00856ed..384bbc8c 100644
--- a/src/Nerve_GIC/include/gudhi/GIC.h
+++ b/src/Nerve_GIC/include/gudhi/GIC.h
@@ -142,7 +142,7 @@ class Graph_induced_complex {
private:
void fill_adjacency_matrix_from_st(){
std::vector<int> empty;
- for(int i = 0; i < n; i++) adjacency_matrix.insert(std::pair<int,std::vector<int> >(i,empty));
+ for(int i = 0; i < n; i++) adjacency_matrix[i] = empty;
for (auto simplex : st.complex_simplex_range()) {
if(st.dimension(simplex) == 1){
std::vector<int> vertices;
@@ -188,6 +188,7 @@ class Graph_induced_complex {
int numedges, numfaces, i, num; std::vector<int> edge(2);
std::vector<int> simplex;
std::ifstream input(off_file_name); std::string line; getline(input, line);
+ if(std::strcmp((char*) line.c_str(),"nOFF")==0) input >> data_dimension; else data_dimension = 3;
input >> n; input >> numfaces; input >> numedges; getline(input, line);
i = 0; while(i < n){
@@ -195,7 +196,7 @@ class Graph_induced_complex {
std::vector<double> point; std::istringstream iss(line);
point.assign(std::istream_iterator<double>(iss), std::istream_iterator<double>());
point_cloud.push_back(Point(point.begin(),point.end())); i++;
- } data_dimension = point_cloud[0].size();
+ }
i = 0; while(i < numfaces){
simplex.clear(); input >> num;
@@ -304,10 +305,10 @@ class Graph_induced_complex {
public: // Automatic tuning of Rips complex.
/** \brief Creates the graph G from a Rips complex whose threshold value is automatically tuned with subsampling.
*
- * @param[in] N number of subsampling iteration (default value 100).
+ * @param[in] N number of subsampling iteration (the default reasonable value is 100, but there is no guarantee on how to choose it).
*
*/
- template<typename Distance> void set_graph_from_automatic_rips(Distance distance, int N = 100){
+ template<typename Distance> double set_graph_from_automatic_rips(Distance distance, int N = 100){
int m = floor(n/ std::exp((1+rate_power)*std::log(std::log(n)/std::log(rate_constant))) );
m = std::min(m,n-1);
@@ -336,6 +337,8 @@ class Graph_induced_complex {
rips_complex_from_points.create_complex(st, 1);
fill_adjacency_matrix_from_st();
+ return delta;
+
}
@@ -511,20 +514,20 @@ class Graph_induced_complex {
if(i != 0){
std::pair<double, double> inter3 = intervals[i-1];
while(func[points[tmp]] < inter3.second && tmp != n){
- prop.insert(std::make_pair(points[tmp],adjacency_matrix[points[tmp]]));
+ prop[points[tmp]] = adjacency_matrix[points[tmp]];
tmp++;
}
}
std::pair<double, double> inter2 = intervals[i+1];
while(func[points[tmp]] < inter2.first && tmp != n){
- prop.insert(std::make_pair(points[tmp],adjacency_matrix[points[tmp]]));
+ prop[points[tmp]] = adjacency_matrix[points[tmp]];
tmp++;
}
pos = tmp;
while(func[points[tmp]] < inter1.second && tmp != n){
- prop.insert(std::make_pair(points[tmp],adjacency_matrix[points[tmp]]));
+ prop[points[tmp]] = adjacency_matrix[points[tmp]];
tmp++;
}
@@ -534,12 +537,12 @@ class Graph_induced_complex {
std::pair<double, double> inter3 = intervals[i-1];
while(func[points[tmp]] < inter3.second && tmp != n){
- prop.insert(std::make_pair(points[tmp],adjacency_matrix[points[tmp]]));
+ prop[points[tmp]] = adjacency_matrix[points[tmp]];
tmp++;
}
while(tmp != n){
- prop.insert(std::make_pair(points[tmp],adjacency_matrix[points[tmp]]));
+ prop[points[tmp]] = adjacency_matrix[points[tmp]];
tmp++;
}
@@ -548,7 +551,7 @@ class Graph_induced_complex {
// Compute the connected components with DFS
std::map<int,bool> visit; if(verbose) std::cout << "Preimage of interval " << i << std::endl;
for(std::map<int, std::vector<int> >::iterator it = prop.begin(); it != prop.end(); it++)
- visit.insert(std::pair<int,bool>(it->first, false));
+ visit[it->first] = false;
if (!(prop.empty())){
for(std::map<int, std::vector<int> >::iterator it = prop.begin(); it != prop.end(); it++){
if ( !(visit[it->first]) ){
@@ -785,10 +788,10 @@ class Graph_induced_complex {
*/
template<typename SimplicialComplexForGIC>
void create_complex(SimplicialComplexForGIC & complex) {
- size_t sz = simplices.size(); unsigned int dimension = 0;
- for(unsigned int i = 0; i < sz; i++){
- complex.insert_simplex_and_subfaces(simplices[i]);
- if(dimension < simplices[i].size()-1) dimension = simplices[i].size()-1;
+ unsigned int dimension = 0;
+ for(auto const& simplex : simplices){
+ complex.insert_simplex_and_subfaces(simplex);
+ if(dimension < simplex.size()-1) dimension = simplex.size()-1;
}
complex.set_dimension(dimension);
}