def getNearestUnvisited(self, currentNode):
shortestLength = self.farAway
for node in self.g.nodes():
if self.g.degree(node) < node.nbPathsOut + 1:
length = nx.shortest_path_length(self.g, currentNode, node, weight = 'weight')
print "Length to node ", node.uid, ": ", length
if length < shortestLength:
nearestUnvisited = node
shortestLength = length
print "Distance to nearest node with unvisited paths: ", shortestLength
return nearestUnvisited
评论列表
文章目录