Part of bzrlib
| Line # | Kind | Name | Docs |
|---|---|---|---|
| 18 | Function | max_distance | Calculate the max distance to an ancestor. |
| 39 | Function | node_distances | Produce a list of nodes, sorted by distance from a start node. |
| 70 | Function | nodes_by_distance | Return a list of nodes sorted by distance |
| 79 | Function | select_farthest | Return the farthest common node, or None if no node qualifies. |
| 86 | Function | all_descendants | Produce a set of all descendants of the start node. |
| 107 | Class | Graph | A graph object which can memoise and cache results for performance. |
For each node, we walk its descendants. If all the descendant's ancestors have a max-distance-to-start, (excluding ones that can never reach start), we calculate their max-distance-to-start, and schedule their descendants.
So when a node's last parent acquires a distance, it will acquire a distance on the next iteration.
Once we know the max distances for all nodes, we can return a list sorted by distance, farthest first.