[feature requrest] Rich-club coefficient
@count0 I was wondering if you ever got around to implementing the rich-club coefficient algorithm as discussed in this thread: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Rich-club-td4025697.html
Just for reference this is the algorithm I would love to see in graph-tool: https://networkx.github.io/documentation/stable/reference/algorithms/generated/networkx.algorithms.richclub.rich_club_coefficient.html#networkx.algorithms.richclub.rich_club_coefficient
I made a small start but I am not quiet sure how to implement the normalization with graph-tool.
def rich_club_coefficient(g):
deghist = gt.vertex_hist(g, 'total')[0]
total = sum(deghist)
rc = {}
# Compute the number of nodes with degree greater than `k`, for each
# degree `k` (omitting the last entry, which is zero).
nks = (total - cs for cs in np.cumsum(deghist) if total - cs > 1)
deg = g.degree_property_map('total')
for k, nk in enumerate(nks):
if nk == 0:
continue
sub_g = gt.GraphView(g, vfilt=lambda v: deg[v] > k)
ek = sub_g.num_edges()
rc[k] = 2 * ek / (nk * (nk - 1))
return rc