Ejemplo n.º 1
0
def test_not_progressing_enough(temporal_graph):

    rw = TemporalRandomWalk(temporal_graph)
    cw_size = 5  # no valid temporal walks of this size

    with pytest.raises(RuntimeError, match=r".* discarded .*"):
        rw.run(num_cw=1, cw_size=cw_size, max_walk_length=cw_size, seed=None)
Ejemplo n.º 2
0
def test_init_parameters(temporal_graph):

    num_cw = 5
    cw_size = 3
    max_walk_length = 3
    seed = 0

    rw = TemporalRandomWalk(
        temporal_graph, cw_size=cw_size, max_walk_length=max_walk_length, seed=seed
    )
    rw_no_params = TemporalRandomWalk(temporal_graph)

    run_1 = rw.run(num_cw=num_cw)
    run_2 = rw_no_params.run(
        num_cw=num_cw, cw_size=cw_size, max_walk_length=max_walk_length, seed=seed
    )

    assert np.array_equal(run_1, run_2)
def test_init_parameters(temporal_graph):

    num_cw = 5
    cw_size = 3
    max_walk_length = 3
    seed = 0

    rw = TemporalRandomWalk(temporal_graph,
                            cw_size=cw_size,
                            max_walk_length=max_walk_length,
                            seed=seed)
    rw_no_params = TemporalRandomWalk(temporal_graph)

    assert rw.run(num_cw=num_cw) == rw_no_params.run(
        num_cw=num_cw,
        cw_size=cw_size,
        max_walk_length=max_walk_length,
        seed=seed)
Ejemplo n.º 4
0
def test_temporal_walks(temporal_graph):
    """
    valid time respecting walks (node -[time]-> node):

        1 -[2]-> 2 -[10]-> 4
        2 -[10]-> 4 -[12]-> 6
        3 -[2]-> 2 -[10]-> 4
        5 -[4]-> 4 -[12]-> 6
        1 -[2]-> 2 -[10]-> 4 -[12]-> 6
        3 -[2]-> 2 -[10]-> 4 -[12] -> 6
    """
    expected = {(1, 2, 4), (2, 4, 6), (3, 2, 4), (5, 4, 6), (1, 2, 4, 6),
                (3, 2, 4, 6)}

    rw = TemporalRandomWalk(temporal_graph)
    num_cw = 20  # how many walks to be sure we're getting valid temporal walks

    for walk in rw.run(num_cw=num_cw, cw_size=3, max_walk_length=4, seed=None):
        assert tuple(walk) in expected