diff options
author | yuichi-ike <yuichi.ike.1990@gmail.com> | 2020-05-21 11:02:00 +0900 |
---|---|---|
committer | yuichi-ike <yuichi.ike.1990@gmail.com> | 2020-05-21 11:02:00 +0900 |
commit | 0c47b28201093851140ab499331017ef42312ce7 (patch) | |
tree | e0f4d09d0fc5cf36705b09f919081917d5195f63 /src/python/gudhi/dtm_rips_complex.py | |
parent | 97e889f34e929f3c2306803b6c37b57926bd1245 (diff) |
DTM Rips added (straightforward way)
Diffstat (limited to 'src/python/gudhi/dtm_rips_complex.py')
-rw-r--r-- | src/python/gudhi/dtm_rips_complex.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/python/gudhi/dtm_rips_complex.py b/src/python/gudhi/dtm_rips_complex.py new file mode 100644 index 00000000..6d2f9f31 --- /dev/null +++ b/src/python/gudhi/dtm_rips_complex.py @@ -0,0 +1,46 @@ +# This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. +# See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. +# Author(s): Yuichi Ike, Raphaƫl Tinarrage +# +# Copyright (C) 2020 Inria, Copyright (C) 2020 FUjitsu Laboratories Ltd. +# +# Modification(s): +# - YYYY/MM Author: Description of the modification + + +from gudhi.weighted_rips_complex import WeightedRipsComplex +from gudhi.point_cloud.dtm import DistanceToMeasure +from scipy.spatial.distance import cdist + +class DtmRipsComplex(WeightedRipsComplex): + """ + Class to generate a DTM Rips complex from a distance matrix or a point set, + in the way described in :cite:`dtmfiltrations`. + Remark that all the filtration values are doubled compared to the definition in the paper + for the consistency with RipsComplex. + """ + def __init__(self, + points=None, + distance_matrix=None, + k=1, + q=2, + max_filtration=float('inf')): + """ + Args: + points (Sequence[Sequence[float]]): list of points. + distance_matrix (ndarray): full distance matrix. + k (int): number of neighbors for the computation of DTM. Defaults to 1, which is equivalent to the usual Rips complex. + q (float): order used to compute the distance to measure. Defaults to 2. + max_filtration (float): specifies the maximal filtration value to be considered. + """ + if distance_matrix is None: + if points is None: + # Empty Rips construction + points=[] + distance_matrix = cdist(points,points) + self.distance_matrix = distance_matrix + dtm = DistanceToMeasure(k, q=q, metric="precomputed") + # TODO: address the error when k is too large + self.weights = dtm.fit_transform(distance_matrix) + self.max_filtration = max_filtration + |