Skip to content

Instantly share code, notes, and snippets.

@Mathias-Fuchs
Last active September 25, 2018 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mathias-Fuchs/b3d16d95524cc356fe1b99deb8181ba4 to your computer and use it in GitHub Desktop.
Save Mathias-Fuchs/b3d16d95524cc356fe1b99deb8181ba4 to your computer and use it in GitHub Desktop.
testing some distance computations
require(igraph)
require(RColorBrewer)
require(rgl)
G <- make_lattice(length=10, dim=2)
r <- c()
for (i in 4:6) r <- c(r, (4:6) + 10 * i)
G <- delete_vertices(G, r)
n <- length(V(G))
u0 <- rep(0, n)
u0[1] <- 1
A <- as_adj(G)
# laplacian_matrix(G)
t <- .00001
B <- (diag(n) - t * A)
u <- round(log(solve(B, u0)) / log(t), 0)
m <- length(unique(u))
redblue<-colorRampPalette(c("red","blue"))
plot(G, vertex.color=redblue(m)[u-min(u)+1])
rglplot(G, vertex.color=redblue(n)[u+1])
plot(distances(G)[,1] ~ u)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment