mst Compute a minimum spanning tree using Prim's algorithm

mst(D)

Arguments

D

A distance matrix

Value

MST a data frame object of 3 columns containing the parent nodes, child nodes, and corresponding weight of the MST edge

Examples

X <- runif(10,0,1) Y <- runif(10,0,1) D <- dist(cbind(X,Y)) mst(as.matrix(D))
#> parent child weight #> 1 2 5 0.28256568 #> 2 3 9 0.21780101 #> 3 4 1 0.04499130 #> 4 5 6 0.53045438 #> 5 6 9 0.02586169 #> 6 7 6 0.54069347 #> 7 8 3 0.14598682 #> 8 9 10 0.28732761 #> 9 10 1 0.14142846