def find_path(self, source, target, value):
"""
find path between source and target
the shortest path is found based on
- the number of hops
- the imbalance it adds or reduces in the accounts
"""
try:
path = dijkstra_path(self.graph, source, target, self._get_path_cost_function(value))
except (nx.NetworkXNoPath, KeyError): # key error for if source or target is not in graph
path = []
return path
评论列表
文章目录