[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] Re: Calculating measures for a bunch of ego-networks
From: |
Magnus Torfason |
Subject: |
[igraph] Re: Calculating measures for a bunch of ego-networks |
Date: |
Wed, 05 May 2010 18:18:19 -0400 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 |
Hi again,
I just wanted to give an update. It turns out that although
graph.neighborhood() is very slow, neighborhood() is very fast, and I've
managed to get quite a ways using a combination of
- neighborhood()
- get.adjedgelist()
and then using the V() and E() lookup functions, which are also very
fast when using known indexes (that I can look up from the lists
returned by neighborhood() and get.adjedgelist().
One piece that I haven't figured out yet is how I can get a list of edge
IDs, given a pair-wise list of nodes. I tried the following, but none of
them got me where I wanted to go:
- E(g, P=pair.wise.vector)
This errored out because not all the edges existed. The problem is for
each pair, I don't know beforehand if a tie exists between them.
- are.connected(g, v1, v2)
This would allow me to ask E() only for edges that actually exist - but
this function is not vectorized, meaning that I need to loop thousands
of times to check a certain set of vertices.
- E(g)[ left.side.vector %--% right.side.vector ]
This actually does more than E(g, P=...) because it checks all
combinations. That is actually cool, because that is what I need.
However, this actually seems to take orders of longer than doing the
are.connected() loop.
Any thoughts on a good way to solve my particular problem?
And any thoughts on which general low-level edge/vertex lookup functions
are useful for calculating custom network measures of any sort? My idea
for criteria are:
- Very fast
- Returns a set of edge/vertex IDs fulfilling some reasonable criteria
- Returns them in a single list of length vcount(g) and therefore
- Do not need to be called in a loop
- Do not fail easily (see comment on E(g, P=...))
neighborhood() and get.adjedgelist() are clearly such functions, neat
combinations of E()/V() and particular parameters might also be in the set.
On 5/5/2010 12:29 PM, Magnus Torfason wrote:
Hi all,
I have a (relatively sparse) network of 100K nodes in igraph. Each node
has a bunch of attributes, and the edges have some attributes as well.
I've calculated some standard measures on the nodes (degree, constraint,
etc) and this has been pretty fast.
However, now I need to calculate some non-standard measures for each
node, that might theoretically depend on the attributes of:
- The attributes of the focal vertex
- The attributes of the edges of the focal vertex
- The attributes of the vertices in the immediate neighborhood
- The ties between the neighbors
So this can be accomplished by looping through the vertices of the
graph, extracting the graph.neighborhood(g, 1, i) for each, and
manipulating it. However, this takes a long time. Are there any better
ways for doing stuff like this?
I think I'm kind of hoping that there is a way of writing a function
that takes a vertex ID, and that this can be "applied" to all the
vertices of the graph, but in an efficient manner that does not require
generating 100K subgraphs.
I guess an alternative way of phrasing the question would be: If I
wanted to implement the constraint measure in R code in an efficient
manner, could I do it?
Thanks for any help and ideas!
Best,
Magnus
Re: [igraph] Calculating measures for a bunch of ego-networks, Tamas Nepusz, 2010/05/06