def degree_hist(_degree, filter_zeros=False):
degree = list(_degree.values()) if type(_degree) is dict else _degree
max_c = np.max(degree)
d = np.arange(max_c+1)
dc = np.bincount(degree, minlength=max_c+1)
if len(d) == 0:
return [], []
if dc[0] > 0:
lgg.debug('%d unconnected vertex' % dc[0])
d = d[1:]
dc = dc[1:]
if filter_zeros is True:
#d, dc = zip(*filter(lambda x:x[1] != 0, zip(d, dc)))
nzv = (dc != 0)
d = d[nzv]
dc = dc[nzv]
return d, dc
评论列表
文章目录