From 85dc5c1e96c66e1505599eab2ee7e61174fd169d Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 4 Jun 2020 22:06:50 +0200 Subject: code review: remove u_set_dominated_edges_ as it is redundant with critical_edge_indicator_ --- .../include/gudhi/Flag_complex_sparse_matrix.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h b/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h index 3afacd0e..75df52bf 100644 --- a/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h +++ b/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h @@ -86,9 +86,6 @@ class Flag_complex_sparse_matrix { // Unordered set of removed edges. (to enforce removal from the matrix) std::unordered_set> u_set_removed_edges_; - // Unordered set of dominated edges. (to inforce removal from the matrix) - std::unordered_set> u_set_dominated_edges_; - // Map from edge to its index std::unordered_map> edge_to_index_map_; @@ -203,15 +200,11 @@ class Flag_complex_sparse_matrix { std::cout << "The following edge is critical with filt value: {" << u << "," << v << "}; " << filt << std::endl; #endif // DEBUG_TRACES - } else - u_set_dominated_edges_.emplace(std::minmax(vertex_to_row_[u], vertex_to_row_[v])); - } else - // Idx is not affected hence dominated. - u_set_dominated_edges_.emplace(std::minmax(vertex_to_row_[u], vertex_to_row_[v])); + } + } } } } - u_set_dominated_edges_.clear(); } // Returns list of non-zero columns of a particular indx. @@ -224,9 +217,17 @@ class Flag_complex_sparse_matrix { // Iterate over the non-zero columns for (typename Sparse_row_matrix::InnerIterator it(sparse_row_adjacency_matrix_, rw_u); it; ++it) { Row_index rw_v = it.index(); + + bool dominated_edge_not_found = false; + try { + edge_to_index_map_.at(std::minmax(row_to_vertex_[rw_u], row_to_vertex_[rw_v])); + } catch (const std::out_of_range& oor) { + dominated_edge_not_found = true; + } + // If the vertex v is not dominated and the edge {u,v} is still in the matrix if (u_set_removed_edges_.find(std::minmax(rw_u, rw_v)) == u_set_removed_edges_.end() && - u_set_dominated_edges_.find(std::minmax(rw_u, rw_v)) == u_set_dominated_edges_.end()) { + dominated_edge_not_found) { // inner index, here it is equal to it.columns() non_zero_indices.push_back(rw_v); #ifdef DEBUG_TRACES -- cgit v1.2.3