~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/deprecated_graph.py

  • Committer: Benoît Pierre
  • Date: 2009-02-24 00:25:32 UTC
  • mfrom: (4035 +trunk)
  • mto: (4056.1.1 trunk2)
  • mto: This revision was merged to the branch mainline in revision 4058.
  • Revision ID: benoit.pierre@gmail.com-20090224002532-i2f64ou15pa7if2y
Merge with upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
def max_distance(node, ancestors, distances, root_descendants):
19
 
    """Calculate the max distance to an ancestor.  
 
19
    """Calculate the max distance to an ancestor.
20
20
    Return None if not all possible ancestors have known distances"""
21
21
    best = None
22
22
    if node in distances:
35
35
            best = distances[ancestor] + 1
36
36
    return best
37
37
 
38
 
    
 
38
 
39
39
def node_distances(graph, ancestors, start, root_descendants=None):
40
40
    """Produce a list of nodes, sorted by distance from a start node.
41
41
    This is an algorithm devised by Aaron Bentley, because applying Dijkstra
128
128
        for parent in parent_ids:
129
129
            self._ensure_descendant(parent)
130
130
            self._graph_descendants[parent][node_id] = 1
131
 
        
 
131
 
132
132
    def _ensure_descendant(self, node_id):
133
133
        """Ensure that a descendant lookup for node_id will work."""
134
134
        if not node_id in self._graph_descendants: