Edge_length_cost.h
1 /* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2  * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3  * Author(s): David Salinas
4  *
5  * Copyright (C) 2014 Inria
6  *
7  * Modification(s):
8  * - YYYY/MM Author: Description of the modification
9  */
10 
11 #ifndef CONTRACTION_POLICIES_EDGE_LENGTH_COST_H_
12 #define CONTRACTION_POLICIES_EDGE_LENGTH_COST_H_
13 
14 #include <gudhi/Contraction/policies/Cost_policy.h>
15 
16 namespace Gudhi {
17 
18 namespace contraction {
19 
23 template< typename EdgeProfile>
24 class Edge_length_cost : public Cost_policy<EdgeProfile> {
25  public:
26  typedef typename Cost_policy<EdgeProfile>::Cost_type Cost_type;
27  typedef typename EdgeProfile::Point Point;
28 
29  Cost_type operator()(const EdgeProfile& profile, const boost::optional<Point>& placement) const override {
30  double res = 0;
31  auto p0_coord = profile.p0().begin();
32  auto p1_coord = profile.p1().begin();
33  for (; p0_coord != profile.p0().end(); p0_coord++, p1_coord++) {
34  res += (*p0_coord - *p1_coord) * (*p0_coord - *p1_coord);
35  }
36  return res;
37  }
38 };
39 
40 } // namespace contraction
41 
42 } // namespace Gudhi
43 
44 #endif // CONTRACTION_POLICIES_EDGE_LENGTH_COST_H_
Definition: SimplicialComplexForAlpha.h:14
Policy to specify the cost of contracting an edge.
Definition: Cost_policy.h:25
return a cost corresponding to the squared length of the edge
Definition: Edge_length_cost.h:24
GUDHI  Version 3.1.1  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Fri Feb 7 2020 16:35:36 for GUDHI by Doxygen 1.8.13