MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / size

Method size

easygraph/classes/graph.py:446–476  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

444 return len(self._node)
445
446 def size(self, weight=None):
447 """Returns the number of edges or total of all edge weights.
448
449 Parameters
450 -----------
451 weight : String or None, optional
452 The weight key. If None, it will calculate the number of
453 edges, instead of total of all edge weights.
454
455 Returns
456 -------
457 size : int or float, optional (default: None)
458 The number of edges or total of all edge weights.
459
460 Examples
461 --------
462
463 Returns the number of edges in G:
464
465 >>> G.size()
466
467 Returns the total of all edge weights in G:
468
469 >>> G.size(weight='weight')
470
471 """
472 if self.cache.get("size") != None:
473 return self.cache["size"]
474 s = sum(d for v, d in self.degree(weight=weight).items())
475 self.cache["size"] = s // 2 if weight is None else s / 2
476 return self.cache["size"]
477
478 # GCN Laplacian smoothing
479 @property

Callers 15

number_of_edgesMethod · 0.95
densityFunction · 0.45
Graph_number_of_nodesFunction · 0.45
index_edgeFunction · 0.45
plain_bfsFunction · 0.45
_pagerankFunction · 0.45
core_decompositionFunction · 0.45
_spfaFunction · 0.45
PrimFunction · 0.45

Calls 1

degreeMethod · 0.95

Tested by

no test coverage detected