~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/graph.py

  • Committer: Aaron Bentley
  • Date: 2005-09-10 22:55:35 UTC
  • mto: (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: aaron.bentley@utoronto.ca-20050910225535-3660c70bf335c618
Handled ancestors that are missing when finding a base

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
    if node in distances:
154
154
        best = distances[node]
155
155
    for ancestor in ancestors[node]:
 
156
        if ancestor not in ancestors:
 
157
            print ancestor
 
158
            continue
156
159
        if ancestor not in distances:
157
160
            return None
158
161
        if best is None or distances[ancestor] > best:
161
164
 
162
165
    
163
166
def farthest_node(graph, ancestors, start):
 
167
    assert 'A' in graph
164
168
    distances = {start: 0}
165
169
    lines = set([start])
166
170
    while len(lines) > 0:
179
183
        return distances[n]
180
184
    node_list = distances.keys()
181
185
    node_list.sort(key=by_distance, reverse=True)
182
 
    assert len(node_list) == len(graph), "%d nodes missing" % \
183
 
        (len(graph) - len(node_list)) 
184
186
    return node_list