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

Function normalize

pattern/graph/__init__.py:947–951  ·  view source on GitHub ↗
(vector)

Source from the content-addressed store, hash-verified

945 # http://python-networkx.sourcearchive.com/documentation/1.0.1/centrality_8py-source.html
946 # Note: much faster than betweenness centrality (which grows exponentially).
947 def normalize(vector):
948 w = 1.0 / (sum(vector.values()) or 1)
949 for node in vector:
950 vector[node] *= w
951 return vector
952 G = adjacency(graph, directed=True, reversed=reversed)
953 v = normalize(dict([(n, random()) for n in graph])) # Node ID => weight vector.
954 # Eigenvector calculation using the power iteration method: y = Ax.

Callers 1

eigenvector_centralityFunction · 0.70

Calls 2

sumFunction · 0.85
valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…