igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Calculating measures for a bunch of ego-networks


From: Tamas Nepusz
Subject: Re: [igraph] Calculating measures for a bunch of ego-networks
Date: Thu, 6 May 2010 11:59:42 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

Hi Magnus,

> 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?
The optimal way would be not to extract the subgraph explicitly. A
subgraph operation is relatively expensive right now in igraph: with
each operation, the original graph is copied and the unneeded vertices
are deleted. igraph 0.6 will probably include a more clever solution for
taking a subgraph, I'm working on it right now.

> 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,
Definitely there is a way to do it, but working out the internal details
of that function is left up to you as I don't know what exactly you are
planning to do with the subgraphs. You can definitely obtain the list of
neighbours for any focal vertex by calling neighbors(graph, vertex_id).
You can also get the list of edges in the subgraph spanned by vertex_id
and its neighbors as follows:

vids <- c(vertex_id, neighbors(graph, vertex_id))
eids <- E(g)[vids %--% vids]

>From this point, it is up to you what you do with vids and eids of
course.

-- 
Tamas




reply via email to

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