#
# R
# Mapa de Caminhos
# Sábado 28 fevereiro 2026
# by
# j
#
x <- c()
y <- c()
w <- c()
z <- c()
max <- 500
i <- 1
while (i<=max) {
x0 <- runif(1, min=0, max=100)
y0 <- runif(1, min=0, max=100)
x <- c(x,x0)
y <- c(y,y0)
i <- i + 1
}
plot(x, y, pch=19, col="red", cex = 0.1)
i <-1
while (i <= max) {
xi <- x[i]
yi <- y[i]
min = 10000
j <- i
while ( j<= max) {
if ( i != j ) {
d <- sqrt( (xi - x[j])^2 + (yi-y[j])^2 )
if (d<min) {
min <- d
k <- j
}
}
j <- j + 1
}
w <- c(w,x[k])
z <- c(z,y[k])
segments(xi, yi, x[k], y[k], col="blue", lwd=2)
i <- i + 1
}
To embed this project on your website, copy the following code and paste it into your website's HTML: