R/radial.ranking.R

Defines functions radial.ranking

Documented in radial.ranking

radial.ranking <- 
    function(object)
{
    if(!is_igraph(object)) 
        stop("'object' must be of class igraph. See package igraph for details")

    mst.matrix.unweighted <- as_adjacency_matrix(object, attr=NULL, sparse=FALSE)
    mst.unweighted <- graph_from_adjacency_matrix(mst.matrix.unweighted, 
        weighted=NULL, mode="undirected")
    sp <- apply(shortest.paths(mst.unweighted), 1, max)
    spw <- apply(shortest.paths(object), 1, max)
    new.sp <- sp + spw/max(spw)
    radius <- min(new.sp)
    center <- which(new.sp == radius)
    if (length(center) > 1) center <- center[1]
    ranktree <- sort(shortest.paths(mst.unweighted)[, center] + 
        (shortest.paths(object)[, center]/max(shortest.paths(object)[, center])),
            decreasing=FALSE, index.return=TRUE)

    radial_ranking <- ranktree$ix
    return(radial_ranking)
}

Try the GSAR package in your browser

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

GSAR documentation built on Nov. 17, 2017, 1:56 p.m.