library("hgu95av2.db")
library("RBGL")
set.seed(321)
uniqun <- function(x) unique(unlist(x))
goid <- "GO:0005778"
egIds <- uniqun(mget(uniqun(hgu95av2GO2PROBE[[goid]]),
hgu95av2ENTREZID))
v1 <- randomGraph(egIds, 1:10, .3, weights=FALSE)
## Since v1 is random, it might be disconnected and we need a
## connected graph to guarantee the existence of a path.
c1 <- connComp(v1)
largestComp <- c1[[which.max(sapply(c1, length))]]
v2 <- subGraph(largestComp, v1)
a1 <- shortestPath(v2, goid, chip="hgu95av2.db")
Run the code above in your browser using DataLab