network#
The network module contains the Network class
- class pyseldonlib.network.Network(model_string: str = None, n_agents: int = None, agents: int = None, neighbour_list: list[int] = [], weight_list: list[float] = [], direction: str = 'Incoming')[source]#
Bases:
object
- property clear#
Clears the network.
- property get_direction#
The direction of the network.
- get_neighbours(index: int)[source]#
The neighbours of the node/agent in the network.
- Parameters:
index (int) – The index of the agent.
- get_weights(index: int)[source]#
The weights of the agent.
- Parameters:
index (int) – The index of the agent.
- property n_agents#
The number of nodes/agents in the network.
- n_edges(agent_idx: int)[source]#
The number of edges going out/coming in at agent_idx in the network.
- Parameters:
agent_idx (int) – The index of the agent. If not provided, the total number of edges in the network is returned.
- push_back_neighbour_and_weight(agent_idx_i: int, agent_idx_j: int, weight: float)[source]#
Adds an edge between agent_idx_i and agent_idx_j with weight w
- Parameters:
agent_idx_i (int) – The index of the agent.
agent_idx_j (int) – The index of the agent.
weight (float) – The weight of the agent.
- property remove_double_counting#
Sorts the neighbours by index and removes doubly counted edges by summing the weights of the corresponding edges.
- set_neighbours_and_weights(agent_idx: int, buffer_neighbours: list[int], weight: float)[source]#
Sets the neighbour indices and sets the weight to a constant value at agent_idx in the network.
- Parameters:
agent_idx (int) – The index of the agent.
buffer_neighbours (list[int]) – The list of neighbours.
weight (float) – The weight of the agent.
- set_weights(agent_idx: int, weights: list)[source]#
Set the weights of the agent.
- Parameters:
index (int) – The index of the agent.
weights (list[float]) – The weights of the agent.
- property strongly_connected_components#
The strongly connected components of the network.
- Returns
list: The strongly connected components of the network.
- property switch_direction_flag#
Only switches the direction flag. This effectively transposes the network and, simultaneously, changes its representation.
- property toggle_incoming_outgoing#
Switches the direction flag without transposing the network (expensive)
- property transpose#
Transposes the network, without switching the direction flag (expensive).