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