|
| 1 | + |
| 2 | +library(igraph) |
| 3 | +library(ggraph) |
| 4 | +library(dplyr) |
| 5 | +library(viridis) |
| 6 | +library(animation) |
| 7 | + |
| 8 | +graph <- igraph::barabasi.game(n=6, power=5) |
| 9 | + |
| 10 | +V(graph)$color <- ovl[2] |
| 11 | +V(graph)[[1]]$color <-ovl[12] |
| 12 | +g1 <- ggraph(graph) + |
| 13 | + geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") + |
| 14 | + geom_node_point(color=V(graph)$color, size=25) + |
| 15 | + theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black') |
| 16 | + |
| 17 | +V(graph)$color <- ovl[3] |
| 18 | +V(graph)[[1]]$color <-ovl[11] |
| 19 | +g2 <- ggraph(graph) + |
| 20 | + geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") + |
| 21 | + geom_node_point(color=V(graph)$color, size=25) + |
| 22 | + theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black') |
| 23 | +V(graph)$color <- ovl[4] |
| 24 | +V(graph)[[1]]$color <-ovl[10] |
| 25 | +g3 <- ggraph(graph) + |
| 26 | + geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") + |
| 27 | + geom_node_point(color=V(graph)$color, size=25) + |
| 28 | + theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black') |
| 29 | +V(graph)$color <- ovl[5] |
| 30 | +V(graph)[[1]]$color <-ovl[9] |
| 31 | +g4 <- ggraph(graph) + |
| 32 | + geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") + |
| 33 | + geom_node_point(color=V(graph)$color, size=25) + |
| 34 | + theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black') |
| 35 | +V(graph)$color <- ovl[6] |
| 36 | +V(graph)[[1]]$color <-ovl[8] |
| 37 | +g5 <- ggraph(graph) + |
| 38 | + geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE, width=2, colour="white") + |
| 39 | + geom_node_point(color=V(graph)$color, size=25) + |
| 40 | + theme_graph(foreground = 'steelblue', fg_text_colour = 'white', background = 'black') |
| 41 | + |
| 42 | + |
| 43 | +gif <- function() { |
| 44 | + lapply(list(g1, g2, g3, g4, g5), function(i) { |
| 45 | + print(i) |
| 46 | + }) |
| 47 | + } |
| 48 | +saveGIF(gif(), interval = .8, movie.name="diffusion.gif") |
0 commit comments