MCPcopy Index your code
hub / github.com/clips/pattern / betweenness_centrality

Method betweenness_centrality

pattern/graph/__init__.py:465–474  ·  view source on GitHub ↗

Calculates betweenness centrality and returns a node => weight dictionary. Node.centrality is updated in the process. Node.centrality is higher for nodes with a lot of passing traffic.

(self, normalized=True, directed=False)

Source from the content-addressed store, hash-verified

463 return ec
464
465 def betweenness_centrality(self, normalized=True, directed=False):
466 """ Calculates betweenness centrality and returns a node => weight dictionary.
467 Node.centrality is updated in the process.
468 Node.centrality is higher for nodes with a lot of passing traffic.
469 """
470 bc = brandes_betweenness_centrality(self, normalized, directed)
471 bc = nodedict(self, ((self[id], w) for id, w in bc.iteritems()))
472 for n, w in bc.iteritems():
473 n._centrality = w
474 return bc
475
476 def sorted(self, order=WEIGHT, threshold=0.0):
477 """ Returns a list of nodes sorted by WEIGHT or CENTRALITY.

Callers 4

centralityMethod · 0.80
_dataMethod · 0.80
test_cacheMethod · 0.80

Calls 3

nodedictClass · 0.85
iteritemsMethod · 0.80

Tested by 2

test_cacheMethod · 0.64