# 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")
S = c("A", "C")
coords = layout.fruchterman.reingold(ig)
# Uncomment to run
#graph.netWalkSnapShot(adj_mat,G,output_dir=getwd(),p1=1.0,
# "A",S,coords,1,TRUE)
Run the code above in your browser using DataLab