Dear all,
I am using the following code to extract for a node of a graph the induced subgraph containing the node and her neighbors (aka, the ego-netwkork).
Can I make it more efficiently? In particular, is there a way to avoid using python to create the neighbor list (or at least avoid the type casting).
If not, could I use some code in C/C++ for doing this an embedded in graph_tool?
Thanks a lot,
Panos
def egoNetwork(inGraph, node):
'''
Compute the ego-network subgraph of the -inGraph- where the ego is the -node-.
Precondition: inGraph is undirected
'''
neighbors = [int(n) for n in node.out_neighbours()]
neighborhood = inGraph.new_vertex_property("bool")
neighborhood.a[neighbors] = 1
neighborhood.a[int(node)] = 1
return GraphView(inGraph, vfilt = neighborhood)
attachment.html (2.32 KB)