# 7 node example graph illustrating diffusion of probability based on
# network connectivity.
adj_mat = rbind(c(0,2,1,0,0,0,0), # A
c(2,0,1,0,0,0,0), # B
c(1,0,0,1,0,0,0), # C
c(0,0,1,0,2,0,0), # D
c(0,0,0,2,0,2,1), # E
c(0,0,0,1,2,0,1), # F
c(0,0,0,0,1,1,0) # G
)
rownames(adj_mat) = c("A", "B", "C", "D", "E", "F", "G")
colnames(adj_mat) = c("A", "B", "C", "D", "E", "F", "G")
ig = graph.adjacency(as.matrix(adj_mat),mode="undirected",weighted=TRUE)
G=vector(mode="list", length=7)
G[seq_len(length(G))] = 0
names(G) = c("A", "B", "C", "D", "E", "F", "G")
coords = layout.fruchterman.reingold(ig)
V(ig)$x = coords[,1]
V(ig)$y = coords[,2]
# Uncomment to run
#graph.diffusionSnapShot(adj_mat,G,getwd(),1.0,"A","A",1,coords)
Run the code above in your browser using DataLab