-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_Data2Diagram_GUDHI_Dionysus.R
33 lines (30 loc) · 1.36 KB
/
1_Data2Diagram_GUDHI_Dionysus.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# author: ismailguzel
library(TDA)
# Upload the dataset from Data directory
Dataset <- read.csv("Data/Original_Coordinates.csv", header = TRUE , sep = ",", dec = ",")
Dataset <- Dataset[-1]
Dataset <- Dataset[1:24,]
Dataset$x <- as.matrix(sapply(Dataset$x, as.character))
Dataset$x <- as.matrix(sapply(Dataset$x, as.numeric))
Dataset$y <- as.matrix(sapply(Dataset$y, as.character))
Dataset$y <- as.matrix(sapply(Dataset$y, as.numeric))
# Choose epsilon and maximum dimension
maxscale <- 0.30 # epsilon
maxdimension <- 2 # components and loops
# Construct the Rips Complex via GUDHI
Rips_Gudhi <- ripsFiltration(Dataset,
maxdimension,
maxscale,
dist = "euclidean",
library = "GUDHI")
# Construct the Rips Complex via Dionysus
Rips_Dionysus <- ripsFiltration(Dataset,
maxdimension,
maxscale,
dist = "euclidean",
library = "dionysus")
Filt_Gudhi <- filtrationDiag(Rips_Gudhi, maxdimension, library = "GUDHI")
Filt_Dionysus <- filtrationDiag(Rips_Dionysus, maxdimension, library = "dionysus")
# Save the diagrams outputs
write.csv(Filt_Gudhi$diagram,"Outputs/gudhi_bd.csv")
write.csv(Filt_Dionysus$diagram,"Outputs/dionysus_bd.csv")