igraph-help
[Top][All Lists]
Advanced

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

[igraph] compute and assign attributes to graphs in a list


From: Yannick Rochat
Subject: [igraph] compute and assign attributes to graphs in a list
Date: Mon, 11 Mar 2013 12:28:49 +0100

Dear all,


I have lists in which elements are graphs, like :

graphs <- lapply(c(100,1000), graph.atlas)


In order to plot them, I would like to compute sizes of vertices depending on degree, color, labels, etc. Idem with edges and layouts. I have found a way to do that with the apply family, but it is not elegant and I'm not confident about it :

graphs <- lapply(graphs, function(x) {V(x)$size <- degree(x) ; x})


Finally, I've decided to use 'for', but found myself with a problem I don't understand. Why this

for (i in 1:length(graphs)) V(graphs[[i]])$size <- degree(graphs[[i]])

works is clear to me, but why that

for (g in graphs) V(g)$size <- degree(g)

doesn't isn't (in print(graphs) the size attribute is missing).


Thanks a lot for your time and for the great work on igraph !


Yannick


my config :
igraph 0.6-3
R 2.15.1

reply via email to

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