search for: nearest_neighbour

Displaying 1 result from an estimated 1 matches for "nearest_neighbour".

Did you mean: nearest_neighbor
2009 Apr 07
2
Minimum Spanning Tree
...n3,.4,.6,0 I've been messing around with some information I've found on the web that prints out an mst, however I think it does it with random values, instead of values provided in a dataset (like from my csv file). Here's what I tried looks like: x <- runif(100) y <- runif(100) nearest_neighbour <- function (x, y, d=dist(cbind(x,y)), ...) { n <- length(x) stopifnot(length(x) == length(y)) d <- as.matrix(d) stopifnot( dim(d)[1] == dim(d)[2] ) stopifnot( length(x) == dim(d)[1] ) i <- 1:n j <- apply(d, 2, function (a) order(a)[2]) segments(x[i], y[i], x[j], y[j...