Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/networkx/algorithms/smetric.py: 80%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

5 statements  

1import networkx as nx 

2 

3__all__ = ["s_metric"] 

4 

5 

6@nx._dispatchable 

7def s_metric(G): 

8 """Returns the s-metric [1]_ of graph. 

9 

10 The s-metric is defined as the sum of the products ``deg(u) * deg(v)`` 

11 for every edge ``(u, v)`` in `G`. 

12 

13 Parameters 

14 ---------- 

15 G : graph 

16 The graph used to compute the s-metric. 

17 

18 Returns 

19 ------- 

20 s : float 

21 The s-metric of the graph. 

22 

23 References 

24 ---------- 

25 .. [1] Lun Li, David Alderson, John C. Doyle, and Walter Willinger, 

26 Towards a Theory of Scale-Free Graphs: 

27 Definition, Properties, and Implications (Extended Version), 2005. 

28 https://arxiv.org/abs/cond-mat/0501169 

29 """ 

30 return float(sum(G.degree(u) * G.degree(v) for (u, v) in G.edges()))