Returns the average degree of the graph. Parameters ---------- G : graph A EasyGraph graph Returns ------- average degree : float The average degree of the graph. Notes ----- Self loops are counted twice in the total degree of a node. Examp
(G)
| 4 | |
| 5 | |
| 6 | def average_degree(G) -> float: |
| 7 | """Returns the average degree of the graph. |
| 8 | |
| 9 | Parameters |
| 10 | ---------- |
| 11 | G : graph |
| 12 | A EasyGraph graph |
| 13 | |
| 14 | Returns |
| 15 | ------- |
| 16 | average degree : float |
| 17 | The average degree of the graph. |
| 18 | |
| 19 | Notes |
| 20 | ----- |
| 21 | Self loops are counted twice in the total degree of a node. |
| 22 | |
| 23 | Examples |
| 24 | -------- |
| 25 | >>> G = eg.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc |
| 26 | >>> G.add_edge(1, 2) |
| 27 | >>> G.add_edge(2, 3) |
| 28 | >>> eg.average_degree(G) |
| 29 | 1.3333333333333333 |
| 30 | """ |
| 31 | return G.number_of_edges() / G.number_of_nodes() * 2 |
nothing calls this directly
no test coverage detected