Esempio n. 1
0
    def test_set_recovery(self):
        edges = []
        for i in range(1, 100):
            for j in range(1, 100):
                if i == j:
                    continue
                else:
                    edges.append((i, j))

        g = Graph(edges)

        recovered = []

        def recovery_function(n):
            recovered.append(n)

        g.set_recovery(recovery_function)

        g.infect_seeds([g.get_node_by_name(i) for i in range(1, 100)])

        assert not recovered

        before = g.infected()
        g.recover()
        after = g.infected()

        assert not not recovered

        assert len(after) < len(before)
Esempio n. 2
0
    def test_set_recovery(self):
        edges = []
        for i in range(1,100):
            for j in range(1,100):
                if i == j:
                    continue
                else:
                    edges.append((i,j))
                    
        g = Graph(edges)        

        recovered = []
        def recovery_function(n):
            recovered.append(n)
        
        g.set_recovery(recovery_function)

        g.infect_seeds([g.get_node_by_name(i) for i in range(1,100)])

        assert not recovered

        before = g.infected()
        g.recover()
        after = g.infected()
        
        assert not not recovered
        
        assert len(after) < len(before)        
        
        
Esempio n. 3
0
    def test_set_infection(self):
        g = Graph([(1, 2), (1, 3), (1, 4), (1, 5)])
        infected = []

        def callback(n):
            infected.append(n)

        g.set_infection(callback)

        one = g.get_node_by_name(1)
        two = g.get_node_by_name(2)
        three = g.get_node_by_name(3)

        g.infect_seeds([one, two, three])

        assert one in infected
        assert two in infected
        assert three in infected

        assert one in g.infected()
        assert two in g.infected()
        assert three in g.infected()
Esempio n. 4
0
 def test_set_infection(self):
     g = Graph([(1,2),(1,3),(1,4),(1,5)])
     infected = []
     
     def callback(n):
         infected.append(n)
         
     g.set_infection(callback)
     
     one = g.get_node_by_name(1)
     two = g.get_node_by_name(2)
     three = g.get_node_by_name(3)
     
     g.infect_seeds([one, two, three])
     
     assert one in infected
     assert two in infected
     assert three in infected
     
     assert one in g.infected()
     assert two in g.infected()
     assert three in g.infected()