Neighbor selector (simulation component)

This component is concerned with selecting the neighbor of the focal agent (i.e. the agent who receives the focal agent’s attribute value) at each timestep in the simulation run.

The following methods are available:

neighbor_selector_sim module

defSim.neighbor_selector_sim.neighbor_selector_sim.select_neighbors(network: networkx.classes.graph.Graph, realization: str, focal_agent: int, regime: str, **kwargs) → Iterable[int]

This function works as a factory method for the neighborSelector component. It calls the select_neighbors function of the specific neighborSelector and passes to it the index of the focal agent and the communication regime.

Parameters
  • network – The network from which the agents are selected.

  • realization – The specific implementation of the neighborSelector. Options are “random”, “similar”

  • focal_agent – An integer that represents the index of the focal agent in the network.

  • regime – Either “many_to_one”, “one_to_many” or “one_to_one”.

  • kwargs – Additional parameters specific to the implementation of the neighborSelector.

Returns

A list with the indices of the selected other agents.


Abstract Base Class (ABC)

class defSim.neighbor_selector_sim.neighbor_selector_sim.NeighborSelector(**kwargs)

Bases: abc.ABC

The NeighborSelector is responsible for picking certain agents from the environment of the focal agent. These agents are then either the source or the target in the following influence step. Possible ways to select neighbors is either by picking all other agents, i.e. global influence (simulation influence from news and polls), all neighbors in the immediate neighborhood, or only single neighbors.

__init__(**kwargs)

Initialize self. See help(type(self)) for accurate signature.

abstract select_neighbors(network: networkx.classes.graph.Graph, focal_agent: int, regime: str, **kwargs) → Iterable[int]

This method selects a subset of agents from the network that are in some way relevant for the influence process regarding the focal agent. This subset could be e.g. a single agent from the direct neighborhood, the whole neighborhood, or all agents, excluding the focal agent.

Parameters
  • network – the network from which the agent shall be selected.

  • focal_agent – the index of the focal agent, who is either the source or target of influence.

  • regime – Whether the focal agent interacts with only one or many agents from his or her neighborhood. If “one-to-one”: One neighbor to which the focal agent has an outgoing tie is selected. If “one-to-many”: All neighbors to which the focal agent has an outgoing tie are selected. If “many-to-one”: All neighbors from which the focal agent has an incoming tie are selected.

  • kwargs – Additional parameters specific to the implementation of the neighborSelector.

Returns

a list of the indices of the relevant other agents.