Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/networkx/algorithms/smetric.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import networkx as nx | |
2 | |
3 | |
4 def s_metric(G, normalized=True): | |
5 """Returns the s-metric of graph. | |
6 | |
7 The s-metric is defined as the sum of the products deg(u)*deg(v) | |
8 for every edge (u,v) in G. If norm is provided construct the | |
9 s-max graph and compute it's s_metric, and return the normalized | |
10 s value | |
11 | |
12 Parameters | |
13 ---------- | |
14 G : graph | |
15 The graph used to compute the s-metric. | |
16 normalized : bool (optional) | |
17 Normalize the value. | |
18 | |
19 Returns | |
20 ------- | |
21 s : float | |
22 The s-metric of the graph. | |
23 | |
24 References | |
25 ---------- | |
26 .. [1] Lun Li, David Alderson, John C. Doyle, and Walter Willinger, | |
27 Towards a Theory of Scale-Free Graphs: | |
28 Definition, Properties, and Implications (Extended Version), 2005. | |
29 https://arxiv.org/abs/cond-mat/0501169 | |
30 """ | |
31 if normalized: | |
32 raise nx.NetworkXError("Normalization not implemented") | |
33 # Gmax = li_smax_graph(list(G.degree().values())) | |
34 # return s_metric(G,normalized=False)/s_metric(Gmax,normalized=False) | |
35 # else: | |
36 return float(sum([G.degree(u) * G.degree(v) for (u, v) in G.edges()])) |