[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] neighborhood subgraph (python)
From: |
David Robinson |
Subject: |
Re: [igraph] neighborhood subgraph (python) |
Date: |
Sun, 23 Jun 2013 19:52:50 -0600 |
Thanks Tamas!
I'm certain I would not have figured that out. Your answer seems to come
close, but how do I set the path length for inducing the subgraph?
And finally (I think): are there similar differences for other graph such as
betweenness?
Thanks again!
>> 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
>