~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testgraph.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-09-06 04:14:01 UTC
  • mto: (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: aaron.bentley@utoronto.ca-20050906041400-0c6374f33ab472d3
Created yet another longest-patch-picker

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from bzrlib.selftest import TestCase
2
2
from bzrlib.graph import shortest_path
3
3
from bzrlib.graph import farthest_nodes_ab
 
4
from bzrlib.graph import farthest_node
4
5
 
5
6
class TestBase(TestCase):
6
7
    def edge_add(self, *args):
33
34
        self.edge_add('A', 'E', 'F', 'C')
34
35
        self.edge_add('A', 'G', 'H', 'I', 'B')
35
36
        self.edge_add('A', 'J', 'K', 'L', 'M', 'N')
36
 
        self.assertEqual(farthest_nodes_ab(self.graph, 'A')[0], 'D')
 
37
        descendants = {}
 
38
        for node in self.graph:
 
39
            for ancestor in self.graph[node]:
 
40
                if ancestor not in descendants:
 
41
                    descendants[ancestor] = set()
 
42
                descendants[ancestor].add(node)
 
43
        nodes = farthest_node(self.graph, descendants, 'A')
 
44
        self.assertEqual(nodes[0], 'D')
 
45
        assert nodes[1] in ('N', 'C')
 
46
        assert nodes[2] in ('N', 'C')
 
47
        assert nodes[3] in ('B', 'M')
 
48
        assert nodes[4] in ('B', 'M')
 
49
 
37
50