igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] timestep plotting


From: Gabor Csardi
Subject: Re: [igraph] timestep plotting
Date: Mon, 8 Jan 2007 16:03:17 +0100
User-agent: Mutt/1.5.11

Vincent, 

here is an example, i used it to visualize a growing barabasi.game, might be
useful. The code is for an older version of igraph, it might still work.
With the current version it could be done in a much simpler way.

If you save the (say) PNG files, there are some programs which create a
video of these or an animated GIF, etc.

G.

###################################################

library(igraph)
g <- barabasi.game(100, directed=FALSE)
coords <- layout.kamada.kawai(g)

# use this for corrections
# id <- tkplot(g, layout=coords, vertex.size=3, label.dist=1)
# coords <- tkplot.getcoords(id)

el <- get.edgelist(g)
colors <- sample(3:6, vcount(g), replace=TRUE)
for (idx in seq(vcount(g))-1) {

  el2 <- el[ el[,1] > idx | el[,2] > idx, ]
  color <- colors
  frame <- rep("black", vcount(g))
  size <- rep(3, vcount(g))
  if (idx+2 <= vcount(g)) {
    color [(idx+2):vcount(g)] <- "white"
    frame [(idx+2):vcount(g)] <- "white"
  } 
  size  [idx+1] <- 6
  
  g2 <- delete.edges(g, E(g, P=t(el2)))
  filename <- paste(sep="", "pa-growth-", idx, ".fig")
# use this to save the images. (or png(), jpeg(), etc.)
#  xfig(file=filename, onefile=TRUE)
  plot(g2, layout=coords, vertex.size=size, labels=NA, vertex.color=color,
       vertex.frame.color=frame)
  Sys.sleep(0.1)
#  dev.off()
}

###################################################

On Sat, Jan 06, 2007 at 10:51:02AM +0100, Gabor Csardi wrote:
> Vincent, 
> 
> there is no direct support for this. For some graphs it is easy as you
> know the order of the edges added. Eg. for barabasi.game outgoing edges from
> vertex j were added later than outgoing edges of vertex i if j>i. 
> 
> Each network generation function would need some change to support it. And
> also it is not very easy to implement it. The current graph data structure
> stores edges simply according to the order of their addition but this is not
> part of the specification so you cannot assume it. I'll think about it,
> please remind me in a week or so. :)
> 
> Btw. for which functions do you need this?
> 
> G.
> 

-- 
Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK




reply via email to

[Prev in Thread] Current Thread [Next in Thread]