igraph - Deleting nodes in R and holding the layout of the graph fixed -


i try create pictures of network layout (to finaly illustrate how network evovles on time). apprach create final network (see net0) , deleting node node (and edges).

how can ensure layout of graph stays same? (and not rescale!) final goal: sequence of graphs different number of nodes exact same layout defined in final graph net0

my approach:

  1. adding same layout reduced network graph gives me same layout deleted node not disapaear
  2. take subset of original layout, graph rescales.

code:

library(igraph) data <- structure(c( "a","a","d","d","f","g","b","b","d","g","d","g","g","f","h","h","g","d","i","i"),.dim = c(10l, 2l), .dimnames = list(null,c("source","target"))) layout <-structure(c(-3.26,-5.50,-2.33,0.48,-3.37,-7.44,-10.00,-8.32,-5.09,-5.19,-3.15,-2.22,-1.9,-4.00),.dim = c(7l, 2l), .dimnames = list(null, c("coordinate.1", "coordinate.2")))   net0 <- graph.edgelist(data, directed=false)  par(pin=c(9, 4.7), mai=c(0.5, 0.1, 0.15, 0.1))  plot(net0, layout=layout)  net <- delete.edges(net0, c(9,10)) net <- delete.vertices(net, c("i"))  plot(net, layout=layout)  net <- delete.edges(net0, c(9,10))  net <- delete.vertices(net, c("i"))  plot(net, layout=layout[1:6,]) 

add layout x , y vertex attributes:

v(net0)$x <- layout[,1] v(net0)$y <- layout[,2] 

these used automatically plot(), see ?layout.auto, default layout.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -