Alisa,
 
Indeed, the classic transportation literature has yet to be fully
recreated in R, but it is very suitable for this purpose.  I wrote a
total connectivity function in script form (see below) that works on a
matrix object.  The script is simple but effective (I've compared manual
and digital results many times and found no difference other than time
spent).  Feedback will be appreciated.
 
All the best,
Scott Drzyzga
 
 
 
 
connectivity <- function(cm) {
 error = 0
 checkrow <- rowSums(cm)
 checkcol <- colSums(cm)
 check <- checkrow - checkcol
 if (min(check) > 0) 
  { 
  cat("Input matrix is not symmetrical.")
  error = error + 1
  }
 if (min(checkrow) < 1 ) 
  { 
  cat("Row", which.min(checkrow), "has no connections.\n")
  error = error + 2 
  }
 if (min(checkcol) < 1 ) 
  { 
  cat("Column", which.min(checkcol), "has no connections.\n")
  error = error + 4
  }
 if (min(cm) > 0) 
  {
  cat("Input matrix has total connectivity.\n")
  error = error + 8
  }
 if (error > 0)
  { 
  cat("Processing stopped.\n")
  }
 else
 {
 cp = cm%*%cm
 power = 2
 ct = cm + cp
 zero = min(ct)
 while(zero==0) 
 {
  cp <- cm%*%cp
  ct <- ct + cp
  power = power + 1
  zero <- min(ct)
 }
 RTotal <- rowSums(ct)
 rmin <- which.min(RTotal)
 rmax <- which.max(RTotal)
 cat("Number of nodes =", ncol(cm), "\n")
 cat("Minimum connectivity =", round(2 / ncol(cm), digits = 4), "\n")
 cat("Diameter of network =", power, "\n")
 cat("The least accessible node is node", rmin, "with", min(RTotal),
"connections.\n")
 cat("The most accessible node is node", rmax, "with", max(RTotal),
"connections.\n")
 ct <- cbind(ct,RTotal)
 CTotal <- colSums(ct)
 ct <- rbind(ct,CTotal)
 write.table(ct,file="total.csv", append=FALSE, sep=",")
 }
}
 
Prof. Scott A. Drzyzga
Geography & Earth Science
Shippensburg University
 

	[[alternative HTML version deleted]]


