Example #1
0
def test_doIncomingInfectionsByNode_weight_given():
    graph = nx.DiGraph()
    graph.add_node("r1")
    graph.add_node("r2")
    graph.add_edge("r1", "r2", weight=0.5)

    state = {
        "r1": {
            ("m", "S"): 90.0,
            ("m", "E"): 0.0,
            ("m", "A"): 5.0,
            ("m", "I"): 5.0
        },
        "r2": {
            ("m", "S"): 80.0,
            ("m", "E"): 0.0,
            ("m", "A"): 10.0,
            ("m", "I"): 10.0
        },
    }

    totalIncomingInfectionsByNode = np.getIncomingInfectiousContactsByNode(
        graph, state, 1.0, ["I", "A"], False, None)

    assert totalIncomingInfectionsByNode == {"r1": 0.0, "r2": 0.5 * 0.1 * 0.8}
Example #2
0
def test_doIncomingInfectionsByNode_weight_multiplier():
    graph = nx.DiGraph()
    graph.add_node("r1")
    graph.add_node("r2")
    graph.add_edge("r1", "r2", weight=10, delta_adjustment=1.0)

    state = {
        "r1": {
            ("m", "S"): 90.0,
            ("m", "E"): 0.0,
            ("m", "A"): 5.0,
            ("m", "I"): 5.0
        },
        "r2": {
            ("m", "S"): 80.0,
            ("m", "E"): 0.0,
            ("m", "A"): 10.0,
            ("m", "I"): 10.0
        },
    }

    totalIncomingInfectionsByNode = np.getIncomingInfectiousContactsByNode(
        graph, state, 0.3, ["I", "A"], False, None)

    assert totalIncomingInfectionsByNode == {
        "r1": 0.0,
        "r2": 10 * 0.3 * 0.1 * 0.8
    }
Example #3
0
def test_doIncomingInfectionsByNode_no_susceptibles():
    graph = nx.DiGraph()
    graph.add_node("r1")
    graph.add_node("r2")
    graph.add_edge("r1", "r2")

    state = {
        "r1": {
            ("m", "S"): 0.0,
            ("m", "E"): 0.0,
            ("m", "A"): 10.0,
            ("m", "I"): 5.0
        },
        "r2": {
            ("m", "S"): 0.0,
            ("m", "E"): 0.0,
            ("m", "A"): 10.0,
            ("m", "I"): 5.0
        },
    }

    totalIncomingInfectionsByNode = np.getIncomingInfectiousContactsByNode(
        graph, state, 1.0, ["I", "A"], False, None)

    assert totalIncomingInfectionsByNode == {"r1": 0.0, "r2": 0.0}