R/dist.neig.R

"dist.neig" <- function (neig) {
    if (!inherits(neig, "neig")) 
        stop("Object of class 'neig' expected")
    res <- neig.util.LtoG(neig)
    n <- nrow(res)
    auxi1 <- res
    auxi2 <- res
    for (itour in 2:n) {
        auxi2 <- auxi2 %*% auxi1
        auxi2[res != 0] <- 0
        diag(auxi2) <- 0
        auxi2 <- (auxi2 > 0) * itour
        if (sum(auxi2) == 0) 
            break
        res <- res + auxi2
    }
    return(as.dist(res))
}

Try the ade4 package in your browser

Any scripts or data that you put into this service are public.

ade4 documentation built on May 2, 2019, 5:50 p.m.