Skip to content Skip to sidebar Skip to footer

Identity Of Nodes In The Giant Component, In Igraph With Python

I'm trying to label which nodes are in the giant component of a network, and which are not. I am NOT trying to simply grab the giant component. This is what I have so far: def in_g

Solution 1:

I'm not sure if I understand your question correctly, but it seems like you simply need a binary list (i.e. a list containing True and False only) such that the item at index i in the list is true iff the corresponding vertex is in the giant component. Your solution is fine, but since it depends on NumPy, I thought I'd add an alternative that does not depend on it:

def in_giant(G):
    cl = G.components()
    cl_sizes = cl.sizes()
    giant_component_index = cl_sizes.index(max(cl_sizes))
    return [x == giant_component_index for x in cl.membership]

Solution 2:

Looks like the answer is:

vc = G.components() ##Get VertexClustering object
array(vc.membership)==argmax(vc.sizes) ##argmax(vc.sizes) may always return 0; not sure.

Post a Comment for "Identity Of Nodes In The Giant Component, In Igraph With Python"