<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> import networkx as nx <EOL> __author__ = "<STR_LIT:\n>" . join ( [ '<STR_LIT>' ] ) <EOL> __all__ = [ '<STR_LIT>' ] <EOL> def harmonic_centrality ( G , distance = None ) : <EOL> r"""<STR_LIT>""" <EOL> if G . is_directed ( ) : <EOL> G = G . reverse ( ) <EOL> sp = nx . shortest_path_length ( G , weight = distance ) <EOL> return { n : sum ( <NUM_LIT:1> / d if d > <NUM_LIT:0> else <NUM_LIT:0> for d in dd . values ( ) ) for n , dd in sp } </s>
