def test_redge(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) re = tr.ebove(three) tr.redge(re) self.assertTrue(not three in tr.verts)
def test_sedge(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) self.assertTrue(tr.above(three) is two) four = tr.sedge(tr.ebove(three)) self.assertTrue(tr.above(three) is four) self.assertTrue(tr.above(four) is two)
def test_medge(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) self.assertTrue(tr.above(three) is two) tr.medge(two) self.assertTrue(tr.above(three) is tr.root) self.assertTrue(three in tr.below(tr.root))
def test_aedge(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) for e in tr.edges: if e.one is tr.root: self.assertTrue(e.two is one or e.two is two) elif e.one is two: self.assertTrue(e.two is three) else:self.assertTrue(False)
def test_rvert(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) tr.rvert(two) self.assertFalse(two in tr.mask(0, tr.root, None)) self.assertEqual(tr.vcnt(), 2) self.assertEqual(tr.ecnt(), 1) self.assertTrue(2 in tr.vistack) self.assertTrue(3 in tr.vistack)
def test_avert(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) self.assertEqual(tr.below(tr.root),[one,two]) self.assertEqual(tr.above(one),tr.root) self.assertEqual(tr.above(two),tr.root) self.assertEqual(tr.below(one),[]) self.assertEqual(tr.below(two),[three]) self.assertEqual(tr.above(three),two)
def test_ebove(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) re = tr.ebove(three) self.assertTrue(re.one is two) self.assertTrue(re.two is three) re = tr.ebove(one) self.assertTrue(re.one is tr.root) self.assertTrue(re.two is one)
def test_rvert(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) tr.rvert(two) self.assertFalse(two in tr.mask(0,tr.root,None)) self.assertEqual(tr.vcnt(),2) self.assertEqual(tr.ecnt(),1) self.assertTrue(2 in tr.vistack) self.assertTrue(3 in tr.vistack)
def test_avert(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) self.assertEqual(tr.below(tr.root), [one, two]) self.assertEqual(tr.above(one), tr.root) self.assertEqual(tr.above(two), tr.root) self.assertEqual(tr.below(one), []) self.assertEqual(tr.below(two), [three]) self.assertEqual(tr.above(three), two)
def test_aedge(self): tr = dtr.tree() one = tr.avert(tr.root) two = tr.avert(tr.root) three = tr.avert(two) for e in tr.edges: if e.one is tr.root: self.assertTrue(e.two is one or e.two is two) elif e.one is two: self.assertTrue(e.two is three) else: self.assertTrue(False)
def draw(self,ax = None): es,ls = self.branches,self.leaves nps,nes = [],[] for ex in range(len(es)): e1,e2 = es[ex] e1x,e2x = None,None for pdx in range(len(nps)): if e1.isnear(nps[pdx]):e1x = pdx if e2.isnear(nps[pdx]):e2x = pdx if not e1x is None and not e2x is None:break if e1x is None: e1x = len(nps) nps.append(e1) tr = dtr.tree() tr.root.MARK = (e1x,e1) if e2x is None: e2x = len(nps) nps.append(e2) nvrt = tr.avert(tr.verts[e1x]) nvrt.MARK = (e2x,e2) nes.append((e1x,e2x)) lsy.draw(ax) self.topology = (tr,nps,nes)
def draw(self, ax=None): es, ls = self.branches, self.leaves nps, nes = [], [] for ex in range(len(es)): e1, e2 = es[ex] e1x, e2x = None, None for pdx in range(len(nps)): if e1.isnear(nps[pdx]): e1x = pdx if e2.isnear(nps[pdx]): e2x = pdx if not e1x is None and not e2x is None: break if e1x is None: e1x = len(nps) nps.append(e1) tr = dtr.tree() tr.root.MARK = (e1x, e1) if e2x is None: e2x = len(nps) nps.append(e2) nvrt = tr.avert(tr.verts[e1x]) nvrt.MARK = (e2x, e2) nes.append((e1x, e2x)) lsy.draw(ax) self.topology = (tr, nps, nes)
def setUp(self): self.tr = dtr.tree()