Exemplo n.º 1
0
if use_stop_nodes:
    stop_nodes = out_inds
else:
    stop_nodes = []
cascade_kws = {
    "n_init": n_init,
    "max_hops": max_hops,
    "stop_nodes": stop_nodes,
    "allow_loops": False,
    "simultaneous": simultaneous,
}

basename = f"-p={p}-n_init={n_init}-max_hops={max_hops}-simult={simultaneous}-stopnodes={use_stop_nodes}"

np.random.seed(seed)
transition_probs = to_transmission_matrix(adj, p)


def hist_from_cascade(
    transition_probs,
    start_nodes,
    stop_nodes=[],
    allow_loops=False,
    n_init=100,
    simultaneous=True,
    max_hops=10,
):
    dispatcher = TraverseDispatcher(
        Cascade,
        transition_probs,
        allow_loops=allow_loops,
Exemplo n.º 2
0
np.random.seed(8888)
rw.start(0)
print(rw.traversal_)  # this one no longer revisits node 26
print()

np.random.seed(2222)
rw.start(0)
print(rw.traversal_)  # this one was unaffected

# %% [markdown]
# # Demonstrate the simplest cascade

from src.traverse import Cascade, to_transmission_matrix

p = 0.2
transition_probs = to_transmission_matrix(A, p)
casc = Cascade(transition_probs)

np.random.seed(88)
casc.start(0)
print(casc.traversal_)
print()

np.random.seed(22)
casc.start(0)
print(casc.traversal_)
# rather than a path, this now is a list of "levels" of the cascade, where each level
# is an array of potentially multiple nodes active at that hop

# %% [markdown]
# ## Note we can also start at a set of nodes at the same time