-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathigraph_impl.py
51 lines (43 loc) · 1.22 KB
/
igraph_impl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def overall_reciprocity(G):
return G.reciprocity()
def pagerank(
G,
alpha=0.85,
personalization=None,
max_iter=100,
tol=1e-06,
nstart=None,
weight="weight",
dangling=None,
*,
vertices=None,
directed=True,
arpack_options=None,
implementation="prpack",
):
if personalization is not None:
raise NotImplementedError
if nstart is not None:
raise NotImplementedError
if dangling is not None:
raise NotImplementedError
rv = G.pagerank(
vertices=vertices,
directed=directed,
damping=alpha,
weights=weight,
arpack_options=arpack_options,
implementation=implementation,
)
return rv
def transitivity(G):
return G.transitivity_undirected()
def average_clustering(G, nodes=None, weight=None, count_zeros=True):
if nodes is not None:
raise NotImplementedError
# TODO: check results when `count_zeros=False`
mode = "zero" if count_zeros else "nan"
return G.transitivity_avglocal_undirected(mode=mode, weights=weight)
def clustering(G, nodes=None, weight=None):
mode = "zero" # or "nan"
return G.transitivity_local_undirected(vertices=nodes, mode=mode, weights=weight)