R/mstree.R

Defines functions mstree

Documented in mstree

mstree <- function(xdist, ngmax=1) { 
    if(!inherits (xdist,"dist")) stop ("Object of class 'dist' expected")
    xdist <- as.matrix(xdist)
    nlig=nrow(xdist)
    xdist <- as.double(xdist)
    if (ngmax<=1) ngmax=1
    if (ngmax>=nlig) ngmax=1
    ngmax=as.integer(ngmax)
    voisi=as.double(matrix(0,nlig,nlig))
    #MSTgraph (double *distances, int *nlig, int *ngmax, double *voisi)
    mst = .C("MSTgraph", distances = xdist, nlig = nlig, ngmax = ngmax, voisi = voisi,PACKAGE="ade4")$voisi
    mst = matrix(mst, nlig, nlig)
    mst = neig (mat01=mst)
    return(mst)
}

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.