Euclidean Minimum Spanning Tree
Computes an Euclidean Minimum Spanning Tree (EMST) from the
data. ComputeMST
is a wrapper around the homonym function in
the 'mlpack' library.
ComputeMST(x, verbose = TRUE, scale = FALSE)
x |
a |
verbose |
If |
scale |
If |
Before the computation, ComputeMST runs some checks and
transformations (if needed) on the provided data using the
data_check
function. After the computation, it returns the
'cleaned' data plus 3 columns: from
, to
, and
distance
. Those columns show each pair of start and end points,
and the distance between them, forming the Minimum Spanning Tree (MST).
an object of class MST
and data.frame
.
It is worth noting that the afore mentioned columns (from
,
to
, and distance
) have no relationship with their
respective row in the output MST/data.frame
object. The authors
chose the data.frame
format for the output rather than a
list
because it is more suitable for plotting the MST with the
new 'ggplot2' Stat (stat_MST
) provided with this
package. The last row of the output at these three columns will always
be the same: 1 1 0.0000000
. This is because we always have n-1
edges for n points. Hence, this is done to 'complete' the data.frame
that is returned.
## artifical data set.seed(1984) n <- 15 c1 <- data.frame(x = rnorm(n, -0.2, sd = 0.2), y = rnorm(n, -2, sd = 0.2)) c2 <- data.frame(x = rnorm(n, -1.1, sd = 0.15), y = rnorm(n, -2, sd = 0.3)) d <- rbind(c1, c2) d <- as.data.frame(d) ## MST: out <- ComputeMST(d) out
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.