35
38
best = distances[ancestor] + 1
39
42
def node_distances(graph, ancestors, start, root_descendants=None):
40
43
"""Produce a list of nodes, sorted by distance from a start node.
41
44
This is an algorithm devised by Aaron Bentley, because applying Dijkstra