[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] neighborhood subgraph (python)
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] neighborhood subgraph (python) |
Date: |
Fri, 21 Jun 2013 22:30:18 +0200 |
> The recent stumbling block is related to 'neighborhood' . Below is what is
> working for me in R, but doing this same thing in python has been difficult.
graph.neighborhood in R and Graph.neighborhood in Python are not completely
equivalent: the R version returns a list of induced subgraphs, while the Python
version returns the nodes of the subgraph only and leave the construction of
the induced subgraph up to you. (Note that the R interface also has a function
named "neighborhood" -- that one is equivalent to Graph.neighborhood in
Python). So, first you have to construct your induced subgraph explicitly, and
then calculate the closeness. The final code should look something like this
(untested, but shows the idea):
result = []
for node in gr0.vs:
neis = gr0.neighborhood(node.index)
subgraph = gr0.subgraph(neis)
result.append(subgraph.closeness())
Cheers,
Tamas