Пример #1
0
    def test_generalisedthreshold_model(self):
        g = nx.erdos_renyi_graph(1000, 0.1)
        model = epd.GeneralisedThresholdModel(g)
        config = mc.Configuration()
        config.add_model_parameter('fraction_infected', 0.1)
        config.add_model_parameter('tau', 5)
        config.add_model_parameter('mu', 5)

        threshold = 0.2
        for i in g.nodes():
            config.add_node_configuration("threshold", i, threshold)
        model.set_initial_status(config)

        iterations = model.iteration_bunch(50)
        self.assertEqual(len(iterations), 50)
        iterations = model.iteration_bunch(50, node_status=False)
        self.assertEqual(len(iterations), 50)
Пример #2
0
    def test_generalisedthreshold_model(self):
        for g in get_graph(True):
            model = epd.GeneralisedThresholdModel(g)
            config = mc.Configuration()
            config.add_model_parameter('fraction_infected', 0.1)
            config.add_model_parameter('tau', 5)
            config.add_model_parameter('mu', 5)

            threshold = 0.2
            if isinstance(g, nx.Graph):
                nodes = g.nodes
            else:
                nodes = g.vs['name']
            for i in nodes:
                config.add_node_configuration("threshold", i, threshold)
            model.set_initial_status(config)

            iterations = model.iteration_bunch(50)
            self.assertEqual(len(iterations), 50)
            iterations = model.iteration_bunch(50, node_status=False)
            self.assertEqual(len(iterations), 50)