summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexios Polyzos <dragotic.saen@gmail.com>2019-07-28 15:34:10 +0300
committerDan Schult <dschult@colgate.edu>2019-07-28 07:34:09 -0500
commitfa18d789e7c586936906bbff8f5a0c001505a24a (patch)
treeb7f0bf6550dc4fdef3e0cb60aa554a580bbcf821
parent7d96d96b146f7daf788d459ec9ef3d19de72f5ad (diff)
downloadnetworkx-fa18d789e7c586936906bbff8f5a0c001505a24a.tar.gz
Small fix for bug found @ issue #3524 (#3529)
Fixes #3524 Divide by zero replaced with zero simrank value
-rw-r--r--networkx/algorithms/similarity.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/networkx/algorithms/similarity.py b/networkx/algorithms/similarity.py
index 6726fbc6..6e39b569 100644
--- a/networkx/algorithms/similarity.py
+++ b/networkx/algorithms/similarity.py
@@ -1140,7 +1140,7 @@ def simrank_similarity(G, source=None, target=None, importance_factor=0.9,
# These functions compute the update to the similarity value of the nodes
# `u` and `v` with respect to the previous similarity values.
- avg_sim = lambda s: sum(newsim[w][x] for (w, x) in s) / len(s)
+ avg_sim = lambda s: sum(newsim[w][x] for (w, x) in s) / len(s) if s else 0.0
sim = lambda u, v: importance_factor * avg_sim(list(product(G[u], G[v])))
for _ in range(max_iterations):