X <- if(interactive()) chicago[c(20, 39)] else runiflpp(2, simplenet)
P <- shortestpath(X)
if(interactive()) {
plot(X, pch=16, main="shortest path")
## draw the path
plot(P, add=TRUE, col=2, lwd=2)
## draw the vertices on the path
V <- vertices(L)
steps <- attr(P, "steps")
plot(V[steps], add=TRUE, col=3)
}
Run the code above in your browser using DataLab