From 08ffcedc11119eba2f5a0a6f22329df197c86107 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 2 Jun 2020 22:59:11 +0200 Subject: code review: GUDHI_CHECK if u==v oninsert_edge method --- .../include/gudhi/Flag_complex_sparse_matrix.h | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/Collapse') diff --git a/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h b/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h index a675bd77..b53c8ab7 100644 --- a/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h +++ b/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h @@ -13,6 +13,7 @@ #define FLAG_COMPLEX_SPARSE_MATRIX_H_ #include +#include #include #include @@ -264,29 +265,26 @@ class Flag_complex_sparse_matrix { } // Insert an edge in the data structure + // @exception std::invalid_argument In debug mode, if u == v void insert_new_edge(Vertex_handle u, Vertex_handle v, Filtration_value filt_val) { // The edge must not be added before, it should be a new edge. insert_vertex(u, filt_val); - if (u != v) { - insert_vertex(v, filt_val); -#ifdef DEBUG_TRACES - std::cout << "Insertion of the edge begins " << u <<", " << v << std::endl; -#endif // DEBUG_TRACES + GUDHI_CHECK((u != v), + std::invalid_argument("Flag_complex_sparse_matrix::insert_new_edge with u == v")); - auto rw_u = vertex_to_row_.find(u); - auto rw_v = vertex_to_row_.find(v); + insert_vertex(v, filt_val); #ifdef DEBUG_TRACES - std::cout << "Inserting the edge " << u <<", " << v << std::endl; + std::cout << "Insertion of the edge begins " << u <<", " << v << std::endl; #endif // DEBUG_TRACES - sparse_row_adjacency_matrix_.insert(rw_u->second, rw_v->second) = filt_val; - sparse_row_adjacency_matrix_.insert(rw_v->second, rw_u->second) = filt_val; - } + + auto rw_u = vertex_to_row_.find(u); + auto rw_v = vertex_to_row_.find(v); #ifdef DEBUG_TRACES - else { - std::cout << "Already a member simplex, skipping..." << std::endl; - } + std::cout << "Inserting the edge " << u <<", " << v << std::endl; #endif // DEBUG_TRACES + sparse_row_adjacency_matrix_.insert(rw_u->second, rw_v->second) = filt_val; + sparse_row_adjacency_matrix_.insert(rw_v->second, rw_u->second) = filt_val; } public: -- cgit v1.2.3