R/distSumConnectMatrix.R

Defines functions distSumConnectMatrix

Documented in distSumConnectMatrix

distSumConnectMatrix <- function(g, dist=NULL) {
  if (class(g)[1] != "graphNEL")
    stop("'g' has to be a 'graphNEL' object")
  stopifnot(.validateGraph(g))
  
  if (is.null(dist))
    dist <- distanceMatrix(g)

  distdeg <- rowSums(dist)

  e <- edges(g)
  m <- matrix(0, nrow=numNodes(g), ncol=numNodes(g),
              dimnames=list(nodes(g), nodes(g)))
  for (i in names(e))
    for (j in e[[i]])
      m[[i, j]] <- 1 / sqrt(distdeg[[i]] * distdeg[[j]])

  m
}

Try the QuACN package in your browser

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

QuACN documentation built on May 2, 2019, 5:46 p.m.