diff options
author | Alexios Polyzos <dragotic.saen@gmail.com> | 2019-07-28 15:34:10 +0300 |
---|---|---|
committer | Dan Schult <dschult@colgate.edu> | 2019-07-28 07:34:09 -0500 |
commit | fa18d789e7c586936906bbff8f5a0c001505a24a (patch) | |
tree | b7f0bf6550dc4fdef3e0cb60aa554a580bbcf821 | |
parent | 7d96d96b146f7daf788d459ec9ef3d19de72f5ad (diff) | |
download | networkx-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.py | 2 |
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): |