[BUG] Using distance matrix to compute the Vietoris Rips Persistance
andro-demir opened this issue · comments
Hi!
I'm trying to compute the Vietoris Rips persistence of my graph using its distance matrix.
I have an unweighted, undirected graph and its distance matrix is:
dist_matrix = np.array([[0,1,2,4,4],[1,0,1,3,3],[2,1,0,2,2],[4,3,2,0,2],[4,3,2,2,0]])
dist_matrix_{ij} represents the distance of the shortest between node i and node j.
I choose metric="precomputed", but the fit transform returns me an incorrect persistence diagram.
To reproduce
import numpy as np
from gtda.homology import VietorisRipsPersistence
from gtda.diagrams import PersistenceEntropy, BettiCurve
from gtda.plotting import plot_diagram
dist_matrix = np.array([[0,1,2,4,4],[1,0,1,3,3],[2,1,0,2,2],[4,3,2,0,2],[4,3,2,2,0]])
VR = VietorisRipsPersistence(metric="precomputed", homology_dimensions=[0,1], max_edge_length=np.inf)
diagrams = VR.fit_transform(dist_matrix.reshape(1, *dist_matrix.shape))
i = 0
plot_diagram(diagrams[i])
Could you please explain in what way the result is incorrect? Please explain your expectations clearly, even if they may be completely obvious to you.
Closing due to inactivity. @andro-demir please feel free to add more detail if you wish it reopened.