if(require("TDAstats"))
{
# create two diagrams
D1 <- TDAstats::calculate_homology(TDAstats::circle2d[sample(1:100,10),],
dim = 1,threshold = 2)
D2 <- TDAstats::calculate_homology(TDAstats::circle2d[sample(1:100,10),],
dim = 1,threshold = 2)
g <- list(D1,D2)
# calculate their 1D MDS embedding in dimension 0 with the bottleneck distance
mds <- diagram_mds(diagrams = g,k = 1,dim = 0,p = Inf,num_workers = 2)
# repeat but with a precomputed distance matrix, gives same result just much faster
Dmat <- distance_matrix(diagrams = list(D1,D2),dim = 0,p = Inf,num_workers = 2)
mds <- diagram_mds(D = Dmat,k = 1)
}
Run the code above in your browser using DataLab