Encapsulate neighbors to easily access them by name, know how many there are,
check if an agent is among another's neighbors, or map a function across
all the agents.
Public fields
agents
Get neighbors as list of agents.
n
Number of neighbors
Create a new instance of Neighbors using a list of Agents.
Methods
Arguments
agents
The agents to be included as neighbors.
Get neighbor by name, returning NULL if named agent is not a neighbor.
Arguments
name
Agent name
Wrap purrr::map to apply function to all neighbor agents.
Method map()
Arguments
f
Function to apply to all neighbors.
Returns
the result of the mapping, not self
Check by name if an agent is one of the neighbors.
Method contains()
Arguments
name
Name of the agent to check.
Returns
boolean indicating whether named agent is a neighbor
Method clone()
The objects of this class are cloneable with this method.
Usage
Neighbors$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.