Induced graph of specific coreness

107 Views Asked by At

Is there a better way of having the induced sub-graph of a specific coreness than this code:

g= Graph.Erdos_Renyi(50, 0.3)
g.vs["coreness"]= g.coreness(mode=ALL)

def get_inducedGraph(g,k):
    ids=[]
    for v in g.vs:
        if v["coreness"] >= k:
            ids.append(v["id"])
    return g.induced_subgraph(ids)

The problem with this code is that it is slow for large graphs.

0

There are 0 best solutions below