Reputation: 3
I have an adjacency matrix10x10, I use graph.adjacency(matrix) from igraph library and I plot the graph. Now, I want to update the plot and add some edges from another matrix10x10. I need a function like points or lines that can draw new edges on the existing plot with an edge list or with a new adjacency matrix. thanks in advance and sorry for my bad english
library(igraph)
g<-barabasi.game(p,directed=F)
m<-as.matrix(get.adjacency(g)) # example of main matrix
plot(graph.adjacency(m,mode="undirected"))
Upvotes: 0
Views: 258
Reputation: 54287
The easiest would be to re-plot. You could save the layout coordinates like this:
library(igraph)
set.seed(1)
m <- as.matrix(get.adjacency(barabasi.game(10,directed=F))) # example of main matrix
g <- graph.adjacency(m, mode="undirected")
coords <- layout.fruchterman.reingold(g)
par(mfrow = c(1, 2))
plot.igraph(g, layout = coords)
plot.igraph(g + edge(3, 9), layout = coords)
Upvotes: 1