Skip to content

Commit

Permalink
symmetrize graph distance
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Mar 14, 2019
1 parent 04bec15 commit e6e1f60
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions graphtools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ def shortest_path(self, method='auto', distance=None):
"Got {}".format(distance))

P = graph_shortest_path(D, method=method)
# symmetrize for numerical error
P = (P + P.T) / 2
# sklearn returns 0 if no path exists
P[np.where(P == 0)] = np.inf
# diagonal should actually be zero
Expand Down

0 comments on commit e6e1f60

Please sign in to comment.