Returns the number of edges or total of all edge weights. Parameters ----------- weight : String or None, optional The weight key. If None, it will calculate the number of edges, instead of total of all edge weights. Returns -------
(self, weight=None)
| 253 | return degree |
| 254 | |
| 255 | def size(self, weight=None): |
| 256 | """Returns the number of edges or total of all edge weights. |
| 257 | |
| 258 | Parameters |
| 259 | ----------- |
| 260 | weight : String or None, optional |
| 261 | The weight key. If None, it will calculate the number of |
| 262 | edges, instead of total of all edge weights. |
| 263 | |
| 264 | Returns |
| 265 | ------- |
| 266 | size : int or float, optional (default: None) |
| 267 | The number of edges or total of all edge weights. |
| 268 | |
| 269 | Examples |
| 270 | -------- |
| 271 | |
| 272 | Returns the number of edges in G: |
| 273 | |
| 274 | >>> G.size() |
| 275 | |
| 276 | Returns the total of all edge weights in G: |
| 277 | |
| 278 | >>> G.size(weight='weight') |
| 279 | |
| 280 | """ |
| 281 | s = sum(d for v, d in self.out_degree(weight=weight).items()) |
| 282 | return int(s) if weight is None else s |
| 283 | |
| 284 | def number_of_edges(self, u=None, v=None): |
| 285 | """Returns the number of edges between two nodes. |
no test coverage detected