Skip to content

Commit

Permalink
Change dumping format
Browse files Browse the repository at this point in the history
  • Loading branch information
Hung-Hsuan Chen committed Aug 20, 2013
1 parent a3df531 commit a97dbac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion similarity/simrank.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# BSD license.
# NetworkX:http://networkx.lanl.gov/.
import copy
import sys
import networkx as nx
from collections import defaultdict
__author__ = """Hung-Hsuan Chen (hhchen@psu.edu)"""
Expand Down Expand Up @@ -74,7 +75,7 @@ def simrank(G, c=0.9, max_iter=100, remove_neighbors=False, remove_self=False, d
sim_old = copy.deepcopy(sim)
for i, u in enumerate(G.nodes()):
if dump_process:
print iter_ctr, ':', i, '/', G.number_of_nodes()
sys.stdout.write("\r%d : % d / %d" % (iter_ctr, i, G.number_of_nodes()))
for v in G.nodes():
if u == v:
continue
Expand All @@ -84,6 +85,7 @@ def simrank(G, c=0.9, max_iter=100, remove_neighbors=False, remove_self=False, d
s_uv += sim_old[n_u][n_v]
sim[u][v] = (c * s_uv / (len(G.neighbors(u)) * len(G.neighbors(v)))) \
if len(G.neighbors(u)) * len(G.neighbors(v)) > 0 else 0
print ''

if remove_self:
for m in G.nodes():
Expand Down

0 comments on commit a97dbac

Please sign in to comment.