add: leverage centrality
This commit is contained in:
@@ -8,6 +8,23 @@ from src import centrality
|
||||
from src import plot
|
||||
from src import fitting
|
||||
|
||||
def leverage(g, weight):
|
||||
# VertexPropertyMap
|
||||
vp = g.new_vertex_property("double")
|
||||
for v in g.vertices():
|
||||
li = 0.0
|
||||
neighbours = g.get_all_neighbours(v)
|
||||
ki = len(neighbours)
|
||||
# sum
|
||||
for nv, props in neighbours:
|
||||
other_neighbours = g.get_all_neighbours(nv)
|
||||
kj = len(other_neighbours)
|
||||
li += (ki - kj) / (ki + kj)
|
||||
li /= ki
|
||||
vp[v] = li
|
||||
return vp
|
||||
|
||||
|
||||
def random_graph(n=5000, seed=None):
|
||||
"""
|
||||
Uniformly random point cloud generation.
|
||||
|
||||
Reference in New Issue
Block a user