diff options
Diffstat (limited to 'src/Bottleneck_distance/include/gudhi/Graph_matching.h')
-rw-r--r-- | src/Bottleneck_distance/include/gudhi/Graph_matching.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Bottleneck_distance/include/gudhi/Graph_matching.h b/src/Bottleneck_distance/include/gudhi/Graph_matching.h index fa20b2a2..10b7073a 100644 --- a/src/Bottleneck_distance/include/gudhi/Graph_matching.h +++ b/src/Bottleneck_distance/include/gudhi/Graph_matching.h @@ -36,7 +36,7 @@ namespace bottleneck_distance { class Graph_matching { public: /** \internal \brief Constructor constructing an empty matching. */ - explicit Graph_matching(); + explicit Graph_matching(Persistence_graph &g); /** \internal \brief Copy operator. */ Graph_matching& operator=(const Graph_matching& m); /** \internal \brief Is the matching perfect ? */ @@ -47,6 +47,7 @@ public: void set_r(double r); private: + Persistence_graph& g; double r; /** \internal \brief Given a point from V, provides its matched point in U, null_point_index() if there isn't. */ std::vector<int> v_to_u; @@ -61,13 +62,14 @@ private: void update(std::vector<int> & path); }; -inline Graph_matching::Graph_matching() - : r(0.), v_to_u(G::size(), null_point_index()), unmatched_in_u() { - for (int u_point_index = 0; u_point_index < G::size(); ++u_point_index) +inline Graph_matching::Graph_matching(Persistence_graph& g) + : g(g), r(0.), v_to_u(g.size(), null_point_index()), unmatched_in_u() { + for (int u_point_index = 0; u_point_index < g.size(); ++u_point_index) unmatched_in_u.emplace_back(u_point_index); } inline Graph_matching& Graph_matching::operator=(const Graph_matching& m) { + g = m.g; r = m.r; v_to_u = m.v_to_u; unmatched_in_u = m.unmatched_in_u; @@ -83,7 +85,7 @@ inline bool Graph_matching::multi_augment() { return false; Layered_neighbors_finder layered_nf(layering()); int max_depth = layered_nf.vlayers_number()*2 - 1; - double rn = sqrt(G::size()); + double rn = sqrt(g.size()); // verification of a necessary criterion in order to shortcut if possible if (max_depth <0 || (unmatched_in_u.size() > rn && max_depth >= rn)) return false; @@ -130,10 +132,10 @@ inline bool Graph_matching::augment(Layered_neighbors_finder & layered_nf, int u inline Layered_neighbors_finder Graph_matching::layering() const { std::list<int> u_vertices(unmatched_in_u); std::list<int> v_vertices; - Neighbors_finder nf(r); - for (int v_point_index = 0; v_point_index < G::size(); ++v_point_index) + Neighbors_finder nf(g, r); + for (int v_point_index = 0; v_point_index < g.size(); ++v_point_index) nf.add(v_point_index); - Layered_neighbors_finder layered_nf(r); + Layered_neighbors_finder layered_nf(g, r); for(int layer = 0; !u_vertices.empty(); layer++) { // one layer is one step in the BFS for (auto it1 = u_vertices.cbegin(); it1 != u_vertices.cend(); ++it1) { |