emstreeR (version 2.2.0)

ComputeMST: Euclidean Minimum Spanning Tree

Description

Computes an Euclidean Minimum Spanning Tree (EMST) from the data. ComputeMST is a wrapper around the homonym function in the 'mlpack' library.

Usage

ComputeMST(x, verbose = TRUE, scale = FALSE)

Arguments

x

a numeric matrix or data.frame.

verbose

If TRUE, mutes the output from the C++ code.

scale

If TRUE, it will scale your data with scale before computing the the minimum spanning tree and the distances to be presented will refer to the scaled data.

Value

an object of class MST and data.frame.

Details

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).

Examples

Run this code
# NOT RUN {
## 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

# }

Run the code above in your browser using DataCamp Workspace