I have an adjacency matrix and I want to obtain a matrix of the minimum paths between the nodes. Thank you Alessandro Ambrosini -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Look at the function geodist in the package sna. David ----- Original Message ----- From: "Ambrosini Alessandro" <klavan at tiscalinet.it> To: <R-help at stat.math.ethz.ch> Sent: Friday, April 12, 2002 3:37 PM Subject: [R] Help> I have an adjacency matrix and I want to obtain a matrix of the minimum > paths between the nodes. Thank you > Alessandro Ambrosini > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-> r-help mailing list -- Readhttp://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html> Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._> >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 12 Apr 2002, Ambrosini Alessandro wrote:> I have an adjacency matrix and I want to obtain a matrix of the minimum > paths between the nodes. Thank you > Alessandro AmbrosiniIn my experience "geodist" in the sna package is rather slow. Compare its system time on a 100x100 adj matrix to a routine that doesn't rely quite so much on loops:> system.time(graph.geod(a) -> result)[1] 0.08 0.00 0.18 0.00 0.00> system.time(geodist(a) -> result2)[1] 78.58 0.00 184.73 0.00 0.00 (this test was done on a G3 iMac running os X/R 1.4.0) here is the 'meat' of graph.geod() graph.geod <- function(dat) { d <- dim(dat) dists <- dat dat2 <- dat for (i in 2:d[1]) { dat2 <- dat2 %*% dat dists2 <- dists + (i*(dat2 != 0) * !dists) if (all(dists==dists2)) break dists <- dists2 } return(dists) } +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |David Richmond It works on a | + Dept. of Sociology complex scientific + |Saint Mary's College principle, known as | + Notre Dame, IN 46556 "pot luck." + |574-284-4517 - The Doctor | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._