Esempio n. 1
0
 def test_add_parent_and_child(self):
     parent = Node()
     child = Node()
     
     parent.add_child(child)
     child.add_parent(parent)
     
     assert parent.is_parent_of(child)
     assert child.is_child_of(parent)
     
     assert parent.name() in child.edges()
     assert child.name() in parent.edges()
     
     assert parent.degree() == 2L
     assert child.degree() == 2L
     
     parent = Node()
     child = Node()
     parent.add_child(child)
     
     assert parent.degree() == 1L
     assert child.degree() == 1L
     
     assert child.is_child_of(parent)
     assert parent.is_parent_of(child)
Esempio n. 2
0
 def test_transmission_probability(self):
     parent = Node()
     child = Node()
     child2 = Node()
     child3 = Node()
     
     parent.add_child(child)
     child.add_parent(parent)
     
     assert child.is_child_of(parent)
     assert parent.is_parent_of(child)
     
     assert child.transmission_probability(parent) == 1.0, "Expected 1.0, got %s" % child.transmission_probability(parent)
     assert parent.transmission_probability(child) == 1.0, "Expected 1.0, got %s" % parent.transmission_probability(child)
     
     parent.add_child(child2)
     parent.add_child(child3)
     
     assert child.degree() == 2L
     assert child2.degree() == 1L
     assert child3.degree() == 1L
     assert parent.degree() == 4L
     
     assert parent.transmission_probability(child) == 1.0/2.0, "Expected 1/2, got %s" % parent.transmission_probability(child)
     assert parent.transmission_probability(child2) == 1.0/4.0, "Expected 1/4, got %s" % parent.transmission_probability(child2)
     assert parent.transmission_probability(child3) == 1.0/4.0, "Expected 1/4, got %s" % parent.transmission_probability(child3)