I have an igraph program written and running in R (works great - thanks!), but I am struggling porting the code over to python. (I'm also a noob Python coder which isn't helping.)
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.
--------------------------------------------
# this is what I am doing in R:
# building a list of induced subgraphs and
# then, for each subgraph, finding the closeness
gr0.n<-graph.neighborhood(gr0, 2, mode="all")
n0<-c(1:length(gr0.n))
#CLOSENESS
temp<-NULL
for (i in n0) {
temp<-append(temp,temp<-closeness(gr0.n[[i]]))
}
gr0C<-temp
--------------------------------------------
# I would like to do the same thing in python
# which might look something like this
from igraph import *
gr0 = Graph.Erdos_Renyi(n=300, m=250)
colors = ["lightgray", "cyan", "magenta", "yellow", "blue", "green", "red"]
components = gr0.components()
for component in components:
color = colors[min(6, len(component)-1)]
gr0.vs[component]["color"] = color
plot(gr0, layout="fr", vertex_label=None)
for node in gr0.vs:
mr_rogers = gr0.neighborhood(gr0, node.index, mode="ALL")
# This last line is a crude attempt to get a single subgraph; however even this isn't working
# ... and I anticipate having difficulties with 'closeness' so hints there would
# also be appreciated
Many thanks for any suggestions