Reference guide#

Operations on multilayer networks#

See dedicated multilayer guide for these functions.

Class MLNetworkActor#

Implemented in network_diffusion.mln.actor.

class MLNetworkActor(actor_id: str, layers_states: Dict[str, str])#

Dataclass that contain data of actor in the network.

property layers: Tuple[str, ...]#

Get network layers where actor exists.

property states: Dict[str, str]#

Get actor’s states for where actitor exists.

states_as_compartmental_graph() Tuple[str, ...]#

Return actor states in form accepted by CompartmentalGraph.

Returns:

a tuple in form on (‘process_name.state_name’, …), e.g. (‘awareness.UA’, ‘illness.I’, ‘vaccination.V’)

Class MultilayerNetwork#

Implemented in network_diffusion.mln.mlnetwork.

class MultilayerNetwork(layers: Dict[str, Graph])#

Container for multilayer network.

copy() MultilayerNetwork#

Create a deep copy of the network.

classmethod from_mpx(file_path: str) MultilayerNetwork#

Load multilayer network from mpx file.

Note, that is omits some non-important attributes of network defined in the file, i.e. node attributes.

Parameters:

file_path – path to the file

classmethod from_nx_layer(network_layer: Graph, layer_names: List[Any]) MultilayerNetwork#

Create multiplex network from one nx.Graph layer and layers names.

Note that network_layer is replicated through all layers.

Parameters:
  • network_layer – basic layer which is replicated through all ones

  • layer_names – names for layers in multiplex network

classmethod from_nx_layers(network_list: List[Graph], layer_names: List[Any] | None = None) MultilayerNetwork#

Load multilayer network as list of layers and list of its labels.

Parameters:
  • network_list – list of nx networks

  • layer_names – list of layer names. It can be none, then labels are set automatically

get_actor(actor_id: Any) MLNetworkActor#

Get actor data basing on its name.

get_actors(shuffle: bool = False) List[MLNetworkActor]#

Get actors that exist in the network and read their states.

Parameters:

shuffle – a flag that determines whether to shuffle actor list

Returns:

a list with actors that live in the network

get_actors_num() int#

Get number of actors that live in the network.

get_layer_names() List[str]#

Get names of layers in the network.

Returns:

list of layers’ names

Get links connecting all actors from the network regardless layers.

Returns:

a set with edges between actors

get_nodes_num() Dict[str, int]#

Get number of nodes that live in each layer of the network.

is_directed() bool#

Check whether at least one layer is a DirectedGraph.

is_multiplex() bool#

Check if network is multiplex.

subgraph(actors: List[MLNetworkActor]) MultilayerNetwork#

Return a subgraph of the network.

The induced subgraph of the graph contains the nodes in nodes and the edges between those nodes. This is an equivalent of nx.Graph.subgraph.

to_multiplex() MultilayerNetwork#

Convert network to multiplex one by adding missing nodes.

Auxiliary functions for operations on MultilayerNetwork#

Implemented in network_diffusion.mln.functions.

Script with functions of NetworkX extended to multilayer networks.

all_neighbors(net: MultilayerNetwork, actor: MLNetworkActor) Iterator[MLNetworkActor]#

Return all of the neighbors of an actor in the graph.

If the graph is directed returns predecessors as well as successors. Overloads networkx.classes.functions.all_neighbours.

betweenness(net: MultilayerNetwork) Dict[MLNetworkActor, float]#

Return value of mean betweennes centrality for actors layers.

closeness(net: MultilayerNetwork) Dict[MLNetworkActor, float]#

Return value of mean closeness centrality for actors layers.

core_number(net: MultilayerNetwork) Dict[MLNetworkActor, int]#

Return the core number for each actor.

A k-core is a maximal subgraph that contains actors of degree k or more. A core number of a node is the largest value k of a k-core containing that node. Not implemented for graphs with parallel edges or self loops. Overloads networkx.algorithms.core.core_number.

Parameters:

net – multilayer network

Returns:

dictionary keyed by actor to the core number.

degree(net: MultilayerNetwork) Dict[MLNetworkActor, int]#

Return number of connecting links per all actors from the network.

get_toy_network() MultilayerNetwork#

Get threelayered toy network easy to visualise.

k_shell_mln(net: MultilayerNetwork, k: int | None = None, core_number: Dict[MLNetworkActor, int] | None = None) MultilayerNetwork#

Return the k-shell of net with degree computed actorwise.

The k-shell is the subgraph induced by actors with core number k. That is, actors in the k-core that are not in the (k+1)-core. The k-shell is not implemented for graphs with self loops or parallel edges. Overloads networkx.algorithms.core.k_shell.

Parameters:
  • net – A graph or directed graph.

  • k – The order of the shell. If not specified return the outer shell.

  • core_number – Precomputed core numbers keyed by node for the graph net. If not specified, the core numbers will be computed from net.

Returns:

The k-shell subgraph

katz(net: MultilayerNetwork) Dict[MLNetworkActor, float]#

Return value of mean Katz centrality for actors layers.

multiplexing_coefficient(net: MultilayerNetwork) float#

Compute multiplexing coefficient.

Multiplexing coefficient is defined as proportion of number of nodes common to all layers to number of all unique nodes in entire network

Returns:

(float) multiplexing coefficient

neighbourhood_size(net: MultilayerNetwork, connection_hop: int = 1) Dict[MLNetworkActor, int]#

Return n-hop neighbourhood sizes of all actors from the network.

number_of_selfloops(net: MultilayerNetwork) int#

Return the number of selfloop edges in the entire network.

A selfloop edge has the same node at both ends. Overloads networkx.classes. functions.number_of_selfloops.

squeeze_by_neighbourhood(net: MultilayerNetwork) Graph#

Squeeze multilayer network to single layer by neighbourhood of actors.

All actors are preserved, links are produced according to naighbourhood between actors regardless layers.

Parameters:

net – a multilayer network to be squeezed

Returns:

a networkx.Graph representing net

voterank_actorwise(net: MultilayerNetwork, number_of_actors: int | None = None) List[MLNetworkActor]#

Select a list of influential ACTORS in a graph using VoteRank algorithm.

VoteRank computes a ranking of the actors in a graph based on a voting scheme. With VoteRank, all actors vote for each of its neighbours and the actor with the highest votes is elected iteratively. The voting ability of neighbors of elected actors is decreased in subsequent turns. Overloads networkx.algorithms.core.k_shell.

Parameters:
  • net – multilayer network

  • number_of_actors – number of ranked actors to extract (default all).

Returns:

ordered list of computed seeds, only actors with positive number of votes are returned.

Operations on temporal networks#

In the library TemporalNetwork is an ordered sequence of MultilayerNetworks. In base scenario one can obtain classic temporal network by having a chain of one-layered MultilayerNetworks.

Class TemporalNetwork#

Implemented in network_diffusion.tpn.tpnetwork.

class TemporalNetwork(snaps: List[MultilayerNetwork])#

Container for a temporal network.

classmethod from_cogsnet(forgetting_type: str, snapshot_interval: int, edge_lifetime: int, mu: float, theta: float, units: int, path_events: str, delimiter: str) TemporalNetwork#

Load events from a csv file and create CogSNet.

Note, the csv file should be in the form of: SRC DST TIME. The timestamps TIME should be in ascending order. The timestamps are expected to be provided in seconds.

Parameters:
  • forgetting_type (str) – The forgetting function used to decrease the weight of edges over time. Allowed values are ‘exponential’, ‘power’, or ‘linear’.

  • snapshot_interval (int) – The interval for taking snapshots (0 or larger) expressed in units param (seconds, minutes, hours). A value of 0 means taking a snapshot after each event.

  • edge_lifetime (int) – The lifetime of an edge after which the edge will disappear if no new event occurs (greater than 0).

  • mu (float) – The value of increasing the weight of an edge for each new event (greater than 0 and less than or equal to 1).

  • theta (float) – The cutoff point (between 0 and mu). If the weight falls below theta, the edge will disappear.

  • units (int) – The time units (1 for seconds, 60 for minutes, or 3600 for hours). For the power forgetting function, this parameter also determines the minimum interval between events to prevent them from being skipped when calculating the weight.

  • path_events (str) – The path to the CSV file with events.

  • delimiter (str) – The delimiter for the CSV file (allowed values are ‘,’, ‘;’, or ‘\t’).

classmethod from_nx_layers(network_list: List[Graph], snap_ids: List[Any] | None = None) TemporalNetwork#

Load a temporal network from a list of networks and their snapshot ids.

Parameters:
  • network_list – a list of nx networks

  • snap_ids – list of snapshot ids. It can be none, then ids are set automatically, if not, then snapshots will be sorted according to snap_ids list

classmethod from_txt(file_path: str, time_window: int, directed: bool = True) TemporalNetwork#

Load a temporal network from a txt file.

Note, the txt file should be in the form of: SRC DST UNIXTS. The timestamps UNIXTS should be in ascending order. The timestamps are expected to be provided in seconds.

Parameters:
  • file_path – path to the file

  • time_window – the time window size for each snapshot

  • directed – indicate if the graph is directed

get_actors(shuffle: bool = False) List[MLNetworkActor]#

Get actors that from the first snapshot of network.

Parameters:

shuffle – a flag that determines whether to shuffle actor list

get_actors_from_snap(snapshot_id: int, shuffle: bool = False) List[MLNetworkActor]#

Get actors that exist in the network at given snapshot.

Parameters:
  • snapshot_id – snapshot for which to take actors, starts from 0

  • shuffle – a flag that determines whether to shuffle actor list

get_actors_num() int#

Get number of actors that live in the network.

Propagation models#

See dedicated propagation model guide for these functions.

Base structures for concrete models#

class BaseModel(compartmental_graph: CompartmentalGraph, seed_selector: BaseSeedSelector)#

Base abstract propagation model.

abstract agent_evaluation_step(agent: Any, layer_name: str, net: MultilayerNetwork) str#

Try to change state of given node of the network according to model.

Parameters:
  • agent – id of the node or the actor to evaluate

  • layer_name – a layer where the node exists

  • net – a network where the node exists

Returns:

state of the model after evaluation

property compartments: CompartmentalGraph#

Return defined compartments and allowed transitions.

abstract determine_initial_states(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Determine initial states in the network according to seed selector.

Parameters:

net – network to initialise seeds for

Returns:

list of nodes with their states

abstract get_allowed_states(net: MultilayerNetwork) Dict[str, Tuple[str, ...]]#

Return dict with allowed states in each layer of net if applied model.

Parameters:

net – a network to determine allowed nodes’ states for

static get_states_num(net: MultilayerNetwork) Dict[str, Tuple[Tuple[Any, int], ...]]#

Return states in the network with number of agents that adopted them.

It is the most basic function which assumes that field “status” in the network is self explaining and there is no need to decode it (e.g. to separate hidden state from public one).

Returns:

dictionary with items representing each of layers and with summary of nodes states in values

abstract network_evaluation_step(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Evaluate the network at one time stamp according to the model.

Parameters:

network – a network to evaluate

Returns:

list of nodes that changed state after the evaluation

static update_network(net: MultilayerNetwork, activated_nodes: List[NetworkUpdateBuffer]) List[Dict[str, str]]#

Update the network global state by list of already activated nodes.

Parameters:
  • net – network to update

  • activated_nodes – already activated nodes

class CompartmentalGraph#

Class which encapsulates model of processes speared in network.

add(process_name: str, states: List[str]) None#

Add process with allowed states to the compartmental graph.

Parameters:
  • layer – name of process, e.g. “Illness”

  • type – names of states like [‘s’, ‘i’, ‘r’]

compile(background_weight: float = 0.0, track_changes: bool = False) None#

Create transition matrices for models of propagation in each layer.

All transition probabilities are set to 0. To be more specific, transitions matrices are stored as a networkx one-directional graph. After compilation user is able to set certain transitions in model.

Parameters:
  • background_weight – [0,1] describes default weight of transition to make propagation more realistic by default it is set to 0

  • track_changes – a flag to track progress of matrices creation

describe() str#

Print out parameters of the compartmental model.

Returns:

returns string describing object,

get_compartments() Dict[str, Tuple[str, ...]]#

Get model parameters, i.e. names of layers and states in each layer.

Returns:

dictionary keyed by names of layer, valued by tuples of states labels

get_possible_transitions(state: Tuple[str, ...], layer: str) Dict[str, float]#

Return possible transitions from given state in given layer of model.

Note that possible transition is a transition with weight > 0.

Parameters:
  • state – state of the propagation model, i.e. (‘awareness.UA’, ‘illness.I’, ‘vaccination.V’)

  • layer – name of the layer of propagation model from which possible transitions are being returned

Returns:

dict with possible transitions in shape of: {possible different state in given layer: weight}

get_seeding_budget_for_network(net: MultilayerNetwork, actorwise: bool = False) Dict[str, Dict[Any, int]]#

Transform seeding budget from %s to numbers according to nodes/actors.

Parameters:
  • net – input network to convert seeding budget for

  • actorwise – compute seeding budget for actors, else for nodes

Returns:

dictionary in form as e.g.: {“ill”: {“suspected”: 45, “infected”: 4, “recovered”: 1}, “vacc”: {“unvaccinated”: 35, “vaccinated”: 15}} for seeding_budget dict: {“ill”: (90, 8, 2), “vacc”: (70, 30)} and 50 nodes in each layer and nodewise mode.

property seeding_budget: Dict[str, Tuple[int | float | number, ...]]#

Get seeding budget as % of the nodes in form of compartments as a dict.

E.g. something like that: {“ill”: (90, 8, 2), “aware”: (60, 40), “vacc”: (70, 30)} for compartments such as: “ill”: [s, i, r], “aware”: [u, a], “vacc”: [n, v]

set_transition_canonical(layer: str, transition: EdgeView, weight: float) None#

Set weight of certain transition in propagation model.

Parameters:
  • layer – name of the later in model

  • transition – name of transition to be activated, edge in propagation model graph

  • weight – in range (number [0, 1]) of activation

set_transition_fast(initial_layer_attribute: str, final_layer_attribute: str, constraint_attributes: Tuple[str, ...], weight: float) None#

Set weight of certain transition in propagation model.

Parameters:
  • initial_layer_attribute – value of initial attribute which is being transited

  • final_layer_attribute – value of final attribute which is being transition

  • constraint_attributes – other attributes available in the propagation model

  • weight – weight (in range [0, 1]) of activation

set_transitions_in_random_edges(weights: List[List[float]]) None#

Set out random transitions in propagation model using given weights.

Parameters:

weights – list of weights to be set in random nodes e.g. for model of 3 layers that list [[0.1, 0.2], [0.03, 0.45], [0.55]] will change 2 weights in first layer, 2, i second and 1 in third

Concrete propagation models#

Import from network_diffusion.models.

class DSAAModel(compartmental_graph: CompartmentalGraph)#

Bases: BaseModel

This model implements algorithm presented at DSAA 2022.

agent_evaluation_step(agent: Any, layer_name: str, net: MultilayerNetwork) str#

Try to change state of given node of the network according to model.

Parameters:
  • agent – id of the node (here agent) to evaluate

  • layer_name – a layer where the node exists

  • network – a network where the node exists

Returns:

state of the model after evaluation

determine_initial_states(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Set initial states in the network according to seed selection method.

Parameters:

net – network to initialise seeds for

Returns:

a list of state of the network after initialisation

get_allowed_states(net: MultilayerNetwork) Dict[str, Tuple[str, ...]]#

Return dict with allowed states in each layer of net if applied model.

In this model each process is binded with network’s layer, hence we return just the compartments and allowed states.

Parameters:

net – a network to determine allowed nodes’ states for

network_evaluation_step(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Evaluate the network at one time stamp according to the model.

We ae updating nodes ‘on the fly’, hence the activated_nodes list is empty. This behaviour is due to intention to very reflect te algorithm presented at DSAA

Parameters:

network – a network to evaluate

Returns:

list of nodes that changed state after the evaluation

class MLTModel(seeding_budget: Tuple[int | float | number, int | float | number], seed_selector: BaseSeedSelector, protocol: str, mi_value: float)#

Bases: BaseModel

This model implements Multilayer Linear Threshold Model.

The model has been presented in paper: “Influence Spread in the Heterogeneous Multiplex Linear Threshold Model” by Yaofeng Desmond Zhong, Vaibhav Srivastava, and Naomi Ehrich Leonard. This implementation extends it to multilayer cases.

agent_evaluation_step(agent: MLNetworkActor, layer_name: str, net: MultilayerNetwork) str#

Try to change state of given actor of the network according to model.

Parameters:
  • agent – actor to evaluate in given layer

  • layer_name – a layer where the actor exists

  • net – a network where the actor exists

Returns:

state of the actor in particular layer to be set after epoch

determine_initial_states(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Determine initial states in the net according to seed selection method.

Parameters:

net – network to initialise seeds for

Returns:

a list of nodes with their initial states

get_allowed_states(net: MultilayerNetwork) Dict[str, Tuple[str, ...]]#

Return dict with allowed states in each layer of net if applied model.

Parameters:

net – a network to determine allowed nodes’ states for

network_evaluation_step(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Evaluate the network at one time stamp with MLTModel.

Parameters:

network – a network to evaluate

Returns:

list of nodes that changed state after the evaluation

class MICModel(seeding_budget: Tuple[int | float | number, int | float | number, int | float | number], seed_selector: BaseSeedSelector, protocol: str, probability: float)#

Bases: BaseModel

This model implements Multilayer Independent Cascade Model.

agent_evaluation_step(agent: MLNetworkActor, layer_name: str, net: MultilayerNetwork) str#

Try to change state of given actor of the network according to model.

Parameters:
  • agent – actor to evaluate in given layer

  • layer_name – a layer where the actor exists

  • net – a network where the actor exists

Returns:

state of the actor in particular layer to be set after epoch

determine_initial_states(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Set initial states in the network according to seed selection method.

Parameters:

net – network to initialise seeds for

Returns:

a list of state of the network after initialisation

get_allowed_states(net: MultilayerNetwork) Dict[str, Tuple[str, ...]]#

Return dict with allowed states in each layer of net if applied model.

Parameters:

net – a network to determine allowed nodes’ states for

network_evaluation_step(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Evaluate the network at one time stamp with MICModel.

Parameters:

net – a network to evaluate

Returns:

list of nodes that changed state after the evaluation

class TemporalNetworkEpistemologyModel(seeding_budget: Tuple[int | float | number, int | float | number], seed_selector: BaseSeedSelector, trials_nr: int, epsilon: float)#

Bases: BaseModel

Generalized version of Temporal Network Epistemology Model.

agent_evaluation_step(agent: MLNetworkActor, layer_name: str, net: MultilayerNetwork) str#

Try to change state of given actor of the network according to model.

Parameters:
  • agent – actor to evaluate in given layer

  • net – a network where the actor exists

  • snapshot_id – currently processed snapshot

Returns:

state of the actor to be set in the next snapshot

static decode_actor_status(encoded_status: str) Tuple[str, float, int]#

Decode agent features from str form.

Parameters:

encoded_status – a string representation of agent status

Returns:

a tuple with agent state, belief level and evidence

determine_initial_states(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Set initial states in the network according to seed selection method.

Parameters:

net – network to initialise seeds for

Returns:

a list of state of the network after initialisation

static encode_actor_status(state: str, belief: float, evidence: int) str#

Encode agent features to str form.

Parameters:
  • state – state of an actor

  • belief – level of agent’s belief

  • evidence – nr of successes drawn from binomial distribution in an experiment

Returns:

a string representation of agent status

get_allowed_states(net: MultilayerNetwork) Dict[str, Tuple[str, ...]]#

Return dict with allowed states of net if applied model.

Parameters:

net – a network to determine allowed nodes’ states for

static get_states_num(net: MultilayerNetwork) Dict[str, Tuple[Tuple[Any, int], ...]]#

Return states in the network with number of agents that adopted them.

Vector of state for each agent is following:

<state of an actor><agent’s belief><evidence>

And we are interested only in the state attribute.

Returns:

dictionary with items representing each of layers and with summary of nodes states in values

network_evaluation_step(net: MultilayerNetwork) List[NetworkUpdateBuffer]#

Evaluate the given snapshot of the network.

Parameters:

net – a network to evaluate

Returns:

list of nodes that changed state after the evaluation

Performing experiments#

See dedicated simulator guide for these functions.

Functions for logging experiments.

class Logger(model_description: str, network_description: str)#

Store and processes logs acquired during performing Simulator.

add_global_stat(log: Dict[str, Any]) None#

Add raw log from single epoch to the object.

Parameters:

log – raw log (i.e. a single call of MultiplexNetwork.get_states_num())

add_local_stat(epoch: int, stats: List[Dict[str, str]]) None#

Add local log from single epoch to the object.

convert_logs(model_parameters: Dict[str, Tuple[str, ...]]) None#

Convert raw logs into pandas dataframe.

Used after finishing aggregation of logs. It fulfills self._stats.

Parameters:

model_parameters – parameters of the propagation model to store

plot(to_file: bool = False, path: str | None = None) None#

Plot out visualisation of performed experiment.

Parameters:
  • to_file – flag, if true save figure to file, otherwise it is plotted on screen

  • path – path to save figure

report(visualisation: bool = False, path: str | None = None) None#

Create report of experiment.

It consists of report of the network, report of the model, record of propagation progress and optionally visualisation of the progress.

Parameters:
  • visualisation – (bool) a flag, if true visualisation is being plotted

  • path – (str) path to folder where report will be saved if not provided logs are printed out on the screen

Functions for the phenomena spreading definition.

class Simulator(model: BaseModel, network: MultilayerNetwork | TemporalNetwork)#

Perform experiment defined by PropagationModel on MultiLayerNetwork.

perform_propagation(n_epochs: int, patience: int | None = None) Logger#

Perform experiment on given network and given model.

It saves logs in Logger object which can be used for further analysis.

Parameters:
  • n_epochs – number of epochs to do experiment

  • patience – if provided experiment will be stopped when in “patience” (e.g. 4) consecutive epoch there was no propagation

Returns:

logs of experiment stored in special object

Seed selection classes for propagation models#

See dedicated propagation model guide for these functions.

Base structures for concrete seed selectors#

class BaseSeedSelector(**kwargs: Any)#

Bases: ABC

Base abstract class for seed selectors.

abstract static _calculate_ranking_list(graph: Graph) List[Any]#

Create a ranking of nodes based on concrete metric/heuristic.

Parameters:

graph – single layer graph to compute ranking for

Returns:

list of node-ids ordered descending by their ranking position

abstract actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Create actorwise ranking.

nodewise(net: MultilayerNetwork) Dict[str, List[Any]]#

Create nodewise ranking.

Concrete seed selectors#

A definition of the seed selector based on degree centrality.

class DegreeCentralitySelector(**kwargs: Any)#

Bases: BaseSeedSelector

Degree Centrality seed selector.

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Get ranking for actors using Degree Centrality metric.

A definition of the seed selectors based on k-shell algorithm.

class KShellMLNSeedSelector(**kwargs: Any)#

Bases: BaseSeedSelector

Selector for MLTModel based on k-shell algorithm.

In contrary to KShellSeedSelector it utilises k-shell decomposition defined as in network_diffusion.mln.functions.k_shell_mln()

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Compute ranking for actors.

class KShellSeedSelector(**kwargs: Any)#

Bases: BaseSeedSelector

Selector for MLTModel based on k-shell algorithm.

According to “Seed selection for information cascade in multilayer networks” by Fredrik Erlandsson, Piotr Bródka, and Anton Borg we have extended k-shell ranking by combining it with degree of the node in each layer, so that ranking is better ordered (nodes in shells can be ordered).

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Compute ranking for actors.

A definition of “selector” that returns aprioiry provided actors.

class MockyActorSelector(preselected_actors: List[MLNetworkActor])#

Bases: BaseSeedSelector

Mocky seed selector - returns a ranking provided as argument to init.

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Get ranking for actors.

A definition of the seed selector based on neighbourhood size.

class NeighbourhoodSizeSelector(connection_hop: int = 1)#

Bases: BaseSeedSelector

Neighbourhood Size seed selector.

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Get ranking for actors using Neighbourhood Size metric.

A definition of the seed selectors based on Page Rank algorithm.

class PageRankMLNSeedSelector(**kwargs: Any)#

Bases: PageRankSeedSelector

Selector for MLTModel based on Page Rank algorithm.

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Compute ranking for actors.

class PageRankSeedSelector(**kwargs: Any)#

Bases: BaseSeedSelector

Selector for MLTModel based on Page Rank algorithm.

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Compute ranking for actors.

Randomised seed selector.

class RandomSeedSelector(**kwargs: Any)#

Bases: BaseSeedSelector

Randomised seed selector prepared mainly for DSAA algorithm.

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Get actors randomly.

A definition of the seed selectors based on Vote Rank algorithm.

class VoteRankMLNSeedSelector(**kwargs: Any)#

Bases: BaseSeedSelector

Selector for MLTModel based on Vote Rank algorithm.

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Compute ranking for actors.

class VoteRankSeedSelector(**kwargs: Any)#

Bases: BaseSeedSelector

Selector for MLTModel based on Vote Rank algorithm.

actorwise(net: MultilayerNetwork) List[MLNetworkActor]#

Compute ranking for actors.

Auxiliary methods#

Functions for the auxiliary operations.

create_directory(dest_path: str) None#

Check out if given directory exists and if doesn’t it creates it.

Parameters:

dest_path – absolute path to create folder

get_absolute_path() str#

Get absolute path of library.

get_nx_snapshot(graph: DynGraph | DynDiGraph, snap_id: int, min_timestamp: int, time_window: int) Graph | DiGraph#

Get an nxGraph typed snapshot for the given snapshot id.

Parameters:
  • graph – the dynamic graph

  • snap_id – the snapshot id

  • min_timestamp – the minimum timestamp in the graph

  • time_window – the size of the time window

Returns:

a snapshot graph of the given id

read_mpx(file_path: str) Dict[str, List[Any]]#

Handle MPX file for the MultilayerNetwork class.

Parameters:

file_path – path to file

Returns:

a dictionary with network to create class

read_tpn(file_path: str, time_window: int, directed: bool = True) Dict[int, Graph | DiGraph]#

Read temporal network from a text file for the TemporalNetwork class.

Parameters:

file_path – path to file

Returns:

a dictionary keyed by snapshot ID and valued by NetworkX Graph