# Randomness in the choice of neighbours promotes cohesion in mobile animal
groups

Vivek Jadhav<EMAIL_ADDRESS>Center for Ecological Sciences, Indian
Institute of Science, Bengaluru, Karnataka, 560012, India  Danny Raj M
<EMAIL_ADDRESS>Dept of Chemical Engineering, Indian Institute of Science,
Bengaluru, Karnataka, 560012, India  Vishwesha Guttal<EMAIL_ADDRESS>Center for Ecological Sciences, Indian Institute of Science, Bengaluru,
Karnataka, 560012, India

###### Abstract

Classic computational models of collective motion suggest that simple local
averaging rules can promote many observed group level patterns. Recent
studies, however, suggest that rules simpler than local averaging may be at
play in real organisms; for example, fish stochastically align towards only
one randomly chosen neighbour and yet the schools are highly polarised. Here,
we ask—how do organisms maintain group cohesion? Using a spatially-explicit
model, inspired from empirical investigations, we show that group cohesion can
be achieved even when organisms randomly choose only one neighbour to interact
with. Cohesion is maintained even in the absence of local averaging that
requires interactions with many neighbours. Furthermore, we show that choosing
a neighbour randomly is a better way to achieve cohesion than interacting with
just its closest neighbour. To understand how cohesion emerges from these
random pairwise interactions, we turn to a graph-theoretic analysis of the
underlying dynamic interaction networks. We find that randomness in choosing a
neighbour gives rise to well-connected networks that essentially cause the
groups to stay cohesive. We compare our findings with the canonical averaging
models (analogous to the Vicsek model). In summary, we argue that randomness
in the choice of interacting neighbours plays a crucial role in collective
motion.

##  I  Introduction

Organisms that live in social groups often exhibit collective motion, which is
important for achieving functions like foraging, navigation, evasion from
predation, etc. [1, 2, 3, 4]. To explain the highly-coordinated motion of such
animal groups, classic models of collective motion assume that an agent moves
along the average direction of motion of all neighbours that are within a
short metric distance around it [5]. Subsequent models extend on these ideas
to incorporate cohesion [6, 7, 8]; they assume that agents also move towards
an average direction determined by the location of all nearby individuals.
Broadly, theory and computational studies predict that non-trivial group-level
phenomena can emerge even when organisms follow such simple rules that depend
on the states of their neighbours [9, 10, 11, 12, 13, 5, 6, 14, 15].

Surprisingly, recent empirical studies [16, 17, 18, 19, 20] show that
organisms interact through rules that are likely much simpler than averaging
information of several individuals; in fact, each organism may interact with
just a single randomly chosen neighbour (termed stochastic pairwise
interaction) to achieve high levels of group polarisation [18]. This order,
counter-intuitively, can emerge from sampling biases in the interactions due
to the finite size of the group. Consequently, once the group is in a
polarised state, it continues to reside in that state for long [21]. To
maintain group polarisation, group cohesion is a must. However, the mechanisms
that keep the group cohesive–in particular the role of stochastic decision
making—are not as well explored.

Traditionally, to explain group cohesion, computational models assume that
organisms interact with all individuals within a fixed metric distance [6, 22,
23]. However, several empirical investigations [24, 25, 26] have shown that
organisms, in fact, interact with a select few, referred to as topological
neighbours, and are not strictly limited by metric distances (say, 7 nearest
neighbours in the case of starling flocks [24]). They argue that such
topological interactions provide substantially better cohesion than metric
distance-based rules. In some fish schools, interaction with the nearest one
appears to be sufficient in producing the observed cohesion [27]. In another
species [17], fish appear to choose the most influential one among their
neighbours to maintain cohesion. In echolocating organisms like bats, it is
challenging to detect the neighbours as the returning echoes are faint and are
likely masked by the loud calls of their neighbours. Consequently, in large
groups, bats may only detect one neighbour at a time [28]; yet roosting bats
manage to maintain cohesion even in large mobile groups. While we do expect
species-specific behavioural rules at fine scales, one broad question arises
at this point: How does group cohesion depend on the choice of neighbours? In
this context, we note that real organisms’ behaviours are likely stochastic.
While computational models do include an element of randomness for the motion
of organisms, they typically ignore this in the context of choice of
interacting neighbours (but see [29, 30]). Here, we reveal the surprising role
of randomness in the choice of neighbours in maintaining group cohesion.

In this article, we investigate how cohesion emerges from stochastic
attraction interactions using a spatially explicit agent-based model. We
explore a class of interaction models that differ only in the way the organism
chooses its neighbour to interact with—based on randomness in choice of
neighbours. To understand how local interactions lead to cohesion at the group
level, we reconstruct the underlying interaction network and employ a graph-
theoretic analysis to study the properties of the network in light of how it
is linked to the group’s ability to stay cohesive. We compare our findings
with the canonical equivalents of the averaging interactions to explain how
simpler interactions are sufficient in achieving cohesion.

Figure 1: Illustration of how organisms choose their neighbours to interact in
the spatially-explicit agent-based model for mobile organisms (using
schematics of fish schools). A focal individual interacts with the neighbours
it can visually perceive. The visible neighbours are ranked based on their
distances from the focal individual. When $K=1$ and $k=1$, organisms either
align with or move towards their nearest neighbour. When $K=3$ and $k=1$,
organisms interact with one of their $3$ nearest neighbours. When $K=3$ and
$k=3$, organisms interact with all $3$ of their nearest neighbours where they
either align with the average orientation or move towards the centroid of the
three organisms.

##  II  Model and simulation

### Agent-based spatially-explicit model

We develop an agent-based model in two spatial dimensions to study the
dynamics of collective motion. While our model broadly follows the principles
of classic self-propelled particle models of collective motion [31, 13, 6], we
make some key modifications—such as probabilistic interaction rules,
asynchronous updating and variable speed of agents—motivated by recent
empirical studies [32, 27, 16, 18]. In this section, we only outline key model
features and relegate the detailed mathematical descriptions to Appendix A.

Every organism $i$ is described by its position in space ($\mathbf{x}_{i}$),
and velocity (speed $s_{i}$ and direction $\mathbf{e}_{i}$). These are
trivially related by the kinematic equation:
$\dot{\mathbf{x}_{i}}=s_{i}\mathbf{e}_{i}$. In our notation, while
$\mathbf{e}_{i}$ represents the unit orientation vector,
$\angle\mathbf{e}_{i}$ represents the angle of that orientation vector about
the positive x-axis.

Agents update both their speed and direction of motion as they interact with
other agents in their visually perceptible neighbourhood. The stochastic
decision making process of organisms is captured by the way the behavioural
interactions of the organisms are implemented via asynchronous update rules
and the choice of neighbours, as described below.

Each organism asynchronously interacts to perform, i) exactly one behavioural
interaction at a given instant (with a propensity that depends on the rate of
the interactions), ii) at a unique time (sampled from an exponential
distribution).

We assume that behavioural interactions between agents depend on topological
neighbourhood [24]: organisms perceive $K$ nearest neighbours from their
visual zone. They integrate information—of orientation and position—from
randomly chosen $k$ of the $K$ ($k\leq K$) perceived neighbours for both the
alignment and attraction interactions (see Figure 1). Our explorations show
that choosing different neighbourhood sizes for alignment and attraction
interactions do not alter our conclusions.

Four key behavioural rules are:

#### Alignment interaction:

At a rate $r_{p}$, an agent copies the speed and direction of motion of agents
present in its topological neighbourhood.

#### Attraction interaction:

At a rate $r_{c}$, an agent moves towards the centre of mass of its nearby
topological neighbours with speed dependent on how far the organism is from
this neighbourhood.

#### Spontaneous turning:

At a rate $r_{s}$, an agent chooses a new direction $\angle\mathbf{e}_{d}$,
sampled from a (circular) normal distribution with a mean
$\angle\mathbf{e}_{i}$ and a variance $\sigma_{a}^{2}$. The speed of the
individual is sampled from a (truncated) normal distribution with mean $s_{0}$
and a variance $\sigma_{s}^{2}$. When the variances are small, spontaneous
turning leads to a new direction of motion (with a new speed) but close to
that of its previous direction.

#### Collision avoidance:

Agents avoid collision with other agents as they move. We assume they do this
by turning away from the other agent and by slowing down (as reported in
[27]).

### Choice of neighbours and interaction types

Depending on the values of $K$ and $k$, we can achieve a variety of
interaction types. We primarily consider the following ones:

We get a stochastic pairwise-interaction when we set $k=1$; e.g. relevant to
fish [18, 27] and bats [28] where organisms interact with only one randomly
chosen neighbour. This results in the agent copying the direction of
(alignment) or moving towards (attraction), a single but randomly chosen
neighbouring agent. Here, $K$ will determine the extent of the neighbourhood
with which the organisms may interact.

Within the stochastic pairwise interaction models, when $K=1$ an agent
interacts with its nearest neighbour (referred to as nearest-neighbour-type).
At the other extreme, when $K=N-1$ an agent interacts with any agent from the
entire group (where $N$ is the size of the group).

Moving beyond the stochastic pairwise interactions, we also consider the
Vicsek-like local averaging models by setting $k=K$ (with $K>1$). For the
alignment interaction, this corresponds to a topological analogue of the
widely studied Vicsek interaction [5]. For the attraction interactions, it
mimics the topological analogue of the Boids [12] or the Couzin model [6].

The simulation is carried out in a two-dimensional, unbounded (non-periodic)
domain. Further details on initial conditions, parameter values, number of
replicates, etc., are described in Appendix A. More information on the
sensitivity of the collective dynamics to parameter values can be found in
Supplementary Information (SI) section 2.

Remarks comparing our model to some of the earlier models of collective motion
are pertinent here. Most of the models assume that individuals interact with
every other individual within a fixed metric distance. Further, they assume
that all individuals interact and update their locations synchronously, moving
at a constant speed [5, 6, 33]. Following many recent empirical studies, our
model assumptions differ on these aspects. First, we assume a topological
distance for interactions. However, unlike Ballerini et al [24] who propose
that birds interact with a fixed number of nearest neighbours, we assume that
organisms may randomly choose any $k$ of the $K$ ($\geq k$) nearest
neighbours; we show this randomness plays an important role in maintaining
group cohesion. We also assume that individuals move at variable speeds [34,
35, 16, 36] and update their motion asynchronously [29, 30, 37], in line with
many recent empirical studies [32, 27, 16, 18]. Note that the model we present
in this section is a non-trivial extension of the mean-field model discussed
in a previous work from our group [18], which captures the polarisation order-
parameter fluctuations observed in real fish.

#### Variants:

In order to show that the results obtained with this model are generic in
nature and would arise in other contexts as well, we test the validity of our
results with variants of the current model. We relax a key assumption in our
model, asynchronicity, in two different ways to get two variants: i) Each
agent interacts via all interactions simultaneously; however, different agents
update their velocity at different times. ii) All agents interact
simultaneously and update their velocity at the same time. (more information
in section 2 of SI).

### Group cohesivity and quantification

We first provide an intuitive picture of the group dynamics. When an agent is
all by itself, the only interaction it undergoes is spontaneous turning, which
changes its movement direction and speed at discrete points in time, resulting
in random motion. When two or more agents are present, they begin to interact
via alignment and attraction rules. In such a setup, the agents in the front
often behave as though they were isolated since there is a visual field that
limits the organism’s perception. These agents have a greater tendency to
wander away from the group until a spontaneous turn changes its orientation,
allowing it to ‘see’ a neighbour in the group; this may create the possibility
for a successful attraction interaction at a later time that can bring it back
to the group. At the same time, other group members may follow a wandering
agent. When a few such individuals succeed in doing so, it could cause a
cascade of many members leaving and eventually breaking a group into two or
more smaller clusters. Thus, we investigate the interaction rules that
maintain group cohesion. Before we do so, we need to define a way to quantify
the cohesivity of groups.

Cohesivity of a mobile group can be quantified in a number of different ways
that include characterising the average near-neighbour distance [38], area of
the convex hull of the spatial positions of the organisms and average distance
to the barycenter of the group [17]. However, we choose a more stringent
measure for cohesion based on how organisms are positioned in space with
respect to their neighbours. Using a density-based spatial clustering approach
(DBSCAN)[39, 40, 4, 41], we group the organisms into different clusters. Here,
a cluster is defined as the set of all organisms, where every organism in the
set is less than $\epsilon$ distance away from at least one other organism in
the set. Then, we define a cohesion parameter (denoted as $\mathcal{C}$) as
the average size (in number of organisms) of the largest cluster in the group
normalised by the total size of the group (averaged over time of the
simulation and over multiple realisations). Hence, the value of $\mathcal{C}$
denotes the average fraction of organisms in the largest cluster in the group.
A value of $1$ means that the organisms were always cohesive, with no break-up
events.

Figure 2: High levels of cohesion are achieved in mobile groups even when
organisms interact with just one neighbour (pairwise interaction) randomly
chosen from a nearby neighbourhood of size $K$. (A) Number of clusters $N_{c}$
a group breaks into, as a function of the neighbourhood of the organism $K$,
for different group sizes. As $K$ increases, $N_{c}\to 1$. Inset: snapshots
from simulation for size $N=30$ and $K=\\{1,10\\}$. (B) Cohesion parameter
$\mathcal{C}$ increases with neighbourhood size (K); Inset shows that cohesion
reaches the maximum value when the neighbourhood is around 30% of the group
size across groups of several sizes. The hashed region is $\frac{K}{N}<0.3$
where the change in $\mathcal{C}$ is significant.

### Simulations and sensitivity analysis

We simulate mobile groups of size ranging from $N\in[5,50]$ and investigate
the effect of the size of the neighbourhood an organism interacts with
($K\in{1,...,N-1}$). We first investigate the stochastic-pairwise
interactions, where an organism interacts with only one randomly chosen
neighbour, i.e. $k=1$ and then compare the findings with the canonical
averaging interactions, by setting $k=K$.

The parameters used for the study are motivated by the empirical results from
Jhawar et al [18]. We analyse how sensitive our findings are to these
parameters and metrics chosen for the study. We find that the qualitative
features of group cohesion and its dependence on $K$ are insensitive to, i) a
broad range of the parameters used in the spatially explicit agent based
model, ii) the parameters in calculating $\mathcal{C}$ and alternate
definitions for the cohesion parameter, and iii) the several variants of the
spatial model. More information on this can be found in SI (Section 2).

##  III  Results and discussion

### Random choice of interacting neighbour, even with one individual, promotes
group cohesion

When the number of individuals are small, which correspond to group sizes in
many simple experiments of collective motion [32, 27, 16], individuals form
groups and remain reasonably cohesive even when the interaction is of the
near-neighbour-type, i.e. organisms align and attract with only the nearest
neighbour ($K=1,k=1$; see Figure 2A for $N=3,5$). However, as the size of the
group increases, interacting with just the nearest neighbour is no longer
sufficient. Groups begin to break into smaller clusters of size $2$ or $3$
where the interactions between the organisms are confined to within the
cluster. These clusters eventually drift away (see inset corresponding to
$K=1$ of Figure 2 A).

With increasing size of the topological neighbourhood while still interacting
with only one random neighbour, i.e. larger $K$ but still with $k=1$,
cohesivity of the groups ($\mathcal{C}$) increases, taking values close to
$1$. This indicates that organisms reside in one tightly knit cluster stably
throughout all time (see Figure 2 B). This is likely because the number of
unique individuals the organisms interact with increases with $K$. In
contrast, when organisms interact only with their nearest neighbour, it is
likely that they are interacting with the same neighbour repeatedly (for more
information, see SI Section 3).

We find the number of neighbours $K$ required to achieve the same level of
cohesion scale with group size $N$. Simply put, the proportion of the
topological neighbours required to achieve a given level of group cohesion is
independent of the group size $N$. We find the cohesion parameter to saturate
when the ratio of the topological neighbourhood to the total group size
reaches a threshold of approximately $0.3$ (hashed region in Figure 2 B). We
find that this threshold ratio reduces when organisms’ speed ($s_{0}$)
reduces, or with increasing rates of attraction ($r_{a}$) and alignment
($r_{p}$) (see SI section 2).

Figure 3: Analysing the interaction network helps in understanding the
emergence of cohesion in mobile groups (illustrated with the schematics of
fish schools). (A) Schematic outlining how an attraction interaction network
is constructed, over a time window of $t_{w}$, with the knowledge of when an
interaction occurred, between which of the organisms and at what time. (B) The
interaction network is analysed to identify the sub-groups based on the
connectivity $\tilde{\mathcal{A}}$. In the example shown, there are two sub-
groups (1-3-2) and (4-5) (marked with different colours). The dotted line
extending between the two sub-groups only connects them one way. (C)
$\mathcal{C}$ and $\mathbf{N}_{p}$ are plotted as a function of $K$ for the
group of size $N=30$. Inset: $\mathbf{N}_{p}$ is plotted as function of
$\mathbf{C}$ for different group sizes. The Black dotted line marks the
diagonal.

### Attraction interaction network reveals why cohesion emerges

To understand how cohesion emerges even from simple stochastic pairwise
interactions, we turn to a graph-theoretic analysis of the underlying
attraction interaction network between organisms in a group. We emphasise that
we focus on attraction interactions rather than alignment interactions since
our study is centred around how organisms maintain cohesion. While it is true
that local directional alignment alone can also cause some degree of
attraction, a major determining cause of group cohesion is the local
attraction (see SI Section 4).

In our analysis, individual organisms can be considered as nodes, and a
directed edge can be constructed from organisms $i$ to $j$, whenever $i$
exhibits an attraction interaction towards $j$. Since organisms interact
asynchronously in our model, these edges are formed at distinct instants of
time. Hence, to construct a graph that faithfully represents the underlying
interaction network, we observe the different connections that arise between
individuals over a time window $t_{w}$. To choose an appropriate time scale
$t_{w}$ for the analysis, we use the length and velocity scales in the system
corresponding to the motion of organism required to break free from its
associated cluster: $\epsilon$ (maximum distance between organisms belonging
to the same cluster) and $s_{0}$ (desired speed of an individual). The time
scale is then defined as,

$t_{w}=\frac{\epsilon}{s_{0}}$ (1)

Notice that if $t_{w}\gg 1$, then we would (at least in some cases) expect a
network that is dense or fully connected since each organism would have
interacted many numbers of times and if $t_{w}\ll 1$, the network would be
sparse. Both these extremes would not represent the ‘correct’ interaction
network responsible for cohesion in a mobile group.

Figure 3 A, illustrates how the attraction interaction network is constructed
over a time period $t_{w}$. The network that emerges due to the interactions
is directed in nature; i.e. $i\to j$ does not imply $j\to i$ since each
individual randomly and asynchronously chooses a neighbour to interact. We
argue that this underlying directed–network encodes information pertaining to
the group’s cohesiveness. Although there are studies that investigate network
properties in collective motion models [42, 43, 44], as far as we know, there
are no off-the-shelf measures to characterise the interaction network to probe
into why a group stays cohesive or breaks apart. In this section, we explore
the correspondence between the properties of the network and the emergence of
cohesion.

It is reasonable to expect a well-connected network to represent a cohesive
group and a sparsely-connected one to represent a non-cohesive group. The
simplest measure that characterises how well a network is connected is an
adjacency matrix $\mathcal{A}$, where each element $(i,j)$ takes the value $1$
when there is an edge connecting $i$ to $j$. Note here that the directed
nature of the graph results in a $\mathcal{A}$ that is asymmetric. From
$\mathcal{A}$, the average connections for a node can be computed—which is
simply the average number of neighbours an organism interacts with within time
$t_{w}$. However, for cohesion to emerge, organisms need not necessarily
interact with every other organism in the group. An organism interacting with
just a few of its immediate neighbours could result in a chain of events that
lead to cohesion. To include this feature that arises not just from primary
(or immediate) but from connections that are secondary, tertiary, etc., we
compute the reachability matrix $\tilde{\mathcal{A}}$, where an element takes
the value $1$ when there is a path from $i$ to $j$, in the directed graph. To
connect this property of the network to the group cohesivity, we divide a
group into sub-groups based on $\tilde{\mathcal{A}}$. A sub-group, in this
context, is defined as a set of all organisms that have a path from and to
every other organism in that sub-group. Then, we compute a network parameter
$\mathcal{N}_{p}$ that is the size of the largest sub-group (normalised by the
size of the group), averaged over time and several realisations (see Figure 3
B for illustration; see Appendix B for details on numerical computation).

We find that $\mathcal{N}_{p}$ increases with the neighbourhood size $K$, in a
manner qualitatively similar to the cohesion parameter $\mathcal{C}$ (see
Figure 3 C; also see SI section 5, where the network parameter is shown to
describe the qualitative trends in $\mathcal{C}\text{ vs }K$ consistently for
different levels of group cohesion). When $K$ increases, interactions between
organisms result in a network that is well-connected, i.e. there is a path
from every organism to almost every other in the sub-group, even when $K\simeq
0.3\times N$. This informs us that when organisms select individuals to
interact with at random from a considerable topological neighbourhood, an
opportunity is created for the group to stay cohesive.

However, an interaction network created need not always materialise into a
cohesive group. An organism can, in principle, interact with another organism
in a cluster far away (in space) to create a well-connected network since the
interactions in our model are topological. But other interactions like
spontaneous turning, alignment or collisions, can break the network before it
can cause the two clusters to come together. For this reason, we find
$\mathcal{N}_{p}$ to reach a high value ($\simeq 1$) faster than $\mathcal{C}$
for most cases (points over the diagonal in the inset of Figure 3 C). However,
when group sizes are small ($N\leq 5$) or when organisms break into small
clusters (for the case of $K=1$), we find $\mathcal{N}_{p}$ to be lower than
$\mathcal{C}$ (points under the diagonal in the inset of Figure 3 C). These
points refer to cases where the organisms are cohesive, but interactions are
sparse, giving rise to a not fully connected network. Here, a considerable
number of organisms reside in the periphery of the clusters that do not have
visible neighbours to interact with and hence get isolated from the rest of
their neighbours in the calculation of the network parameter. Hence, these
clusters have a lower value for $\mathcal{N}_{p}$ even though they are
spatially in proximity to their local neighbours (SI Section 5).

### Cohesion due to averaging interactions

In canonical models for flocking, like the Vicsek model for alignment, an
agent often averages the information from a neighbourhood to find its
direction of movement. Here we compare the group cohesivity achieved through
stochastic pairwise interactions with that of the averaging-type interactions.
We recall that while stochastic pairwise interactions are achieved by setting
$k=1$ and $K>1$, we obtain the topological averaging interaction (like the
Vicsek model for alignment) by setting $k=K$.

We find averaging interactions also achieve cohesion, with cohesion parameter
$\mathcal{C}$ increasing rapidly with the size of the neighbourhood, $K$ (see
Figure 4). We emphasise that while focal agents interact with all neighbours
$K$ in the averaging-type interactions (because $k=K$), stochastic pairwise
interactions permit interaction with only one neighbour ($k=1$). Averaging
interaction, by definition, consumes information from all the interacting $K$
neighbours, while a pairwise interaction only takes-in information from only
one of its $K$ neighbours at a time. Thus, it is not surprising that cohesion
is achieved more rapidly in the local-averaging type interaction.

Figure 4: Emergence of cohesion due to pairwise interactions ($k=1$) compared
to averaging-type interactions ($k=K$) for a group of size $N=30$. When $K$ is
large, both interactions lead to cohesive mobile groups: hashed region. To
achieve the same level of cohesion, a group interacting pairwise should have
$K=K_{p}$ neighbours while a group interacting via averaging-interactions need
only $K=K_{a}<K_{p}$ neighbours (horizontal line at $\mathcal{C}=0.75$).

Interestingly, beyond a certain value of neighbourhood size $K$, both the
averaging and the pairwise interactions produce similar (maximum) cohesion.
Hence, organisms interacting via these two different interaction types will
not have any additional advantage with regards to cohesivity. However, if we
compared the neighbourhood sizes required to achieve a given value of cohesion
(say, $0.75$), then we observe that the averaging interaction can achieve that
level of cohesion with less number of neighbours $K_{a}$ than a pairwise
interaction $K_{p}$ (see horizontal line at $\mathcal{C}=0.75$ in Figure 4).
From the viewpoint of the organism’s cognitive capacity, the choice is
between: i) assimilating information from all neighbours in a small
neighbourhood of size $K_{a}$ and averaging them or ii) assimilating
information of one neighbour from a larger set of $K_{p}$ neighbours. While it
is known that the cognitive load required to track a large number of
neighbours is high [45, 46, 47]; we do not yet know, which of these two
processes have a smaller cognitive load.

However, one could safely assume that an organism capable of integrating
information from multiple sources and limited by its ability to observe only a
small part of its neighbourhood would prefer method–4 over method–4, while a
different organism that finds integrating information together difficult would
choose 4 to achieve the same level of cohesion.

##  IV Concluding remarks

In this study, using a spatially-explicit agent-based model, we show that
group-level cohesion can emerge when organisms move towards just one other
randomly chosen nearby organism. We show that a random choice of the
neighbour, rather than a fixed neighbour such as the nearest individual,
considerably improves the group cohesion. Cohesion emerges even with such
simple stochastic pairwise interactions because choosing a neighbour randomly
creates a well-connected long-ranged interaction network. We show that the
connectedness of the interaction network correlates well with the cohesivity
of the mobile group.

Constructing the interaction network was possible because we had complete
access to all information pertaining to the interactions, their time-stamps
and organisms-indices, due to the theoretical nature of the work. In an
experimental setting, it would be challenging to estimate the underlying
network structure from data of organismal motion. In a recent study, a ray
casting approach was used to identify a network based on the vision of
individual fish [48]. This network had an edge connecting an organism to every
other organism in its perceivable neighbourhood; not specific to attraction
interactions (or any other). We believe that re-constructing the hidden
interaction networks from movement data would be an exciting future direction
for research.

#### However, do organisms really choose a random neighbour to interact with?

A random neighbour could be chosen in many ways. For instance, an organism
could prefer a faster-moving individual to interact with, over other slower-
moving ones. And since, organisms may move at different speeds during the
course of their motion, which change continuously due to spontaneous activity
and collisions, this ‘faster-individual’ may be found anywhere within a
neighbourhood of a certain size. Lei and coworkers argue that fish choose to
interact with a few of their most-influential neighbours [17]. However, since
the ‘influence’ a neighbour has on a fish is a function of its proximity,
relative positions and orientations, which change continuously as fish move in
a school [16], the most-influential fish could essentially take any position
within the school at a given time: from the nearest neighbour to the farthest
one. We speculate that choosing the most influential neighbour could be
similar to choosing a fish randomly from a neighbourhood of size $K$.

In summary, our study shows that when an organism randomly chooses another to
interact with, irrespective of specific mechanisms, it results in an
interaction network that is well-connected, giving rise to considerable group
cohesion in small to intermediate group sizes. However, we expect large
systems of collective motion to exhibit dynamic fission and fusion; since the
topological neighbourhood an organism should perceive to maintain group
cohesion will be much larger than what is biologically feasible. We welcome
further research on empirically motivated and parameterised models of
collective motion that account for stochastic decision making of organisms
with an emphasis on group cohesion, fission-fusion group dynamics and explore
the functional significance of the role of heterogeneity between individuals
in the group.

##  V Data and code availability

All codes are available via an open access repository: https://github.com/tee-
lab/cohesion-in-collective-motion.git

##  VI Author contributions

VJ, VG and DRM conceptualised the study. VJ and DRM designed model and
conducted the analysis. DRM and VJ wrote the manuscript with significant
inputs from VG. All authors contributed to discussions and interpretations of
results.

##  VII Acknowledgements

We thank Arshed Nabeel for his comments on the manuscript. VJ is supported by
a MHRD fellowship. DRM is supported by DST INSPIRE faculty fellowship program.
VG acknowledges DBT-IISc partnership program and infrastructure support from
DST-FIST.

## References

  * Camazine  _et al._ [2020] S. Camazine, J.-L. Deneubourg, N. R. Franks, J. Sneyd, G. Theraula, and E. Bonabeau,  _Self-organization in biological systems_ (Princeton university press, 2020).
  * Sumpter [2010] D. J. Sumpter,  _Collective animal behavior_ (Princeton University Press, 2010).
  * Parrish and Edelstein-Keshet [1999] J. K. Parrish and L. Edelstein-Keshet, Complexity, pattern, and evolutionary trade-offs in animal aggregation, Science 284, 99 (1999).
  * Ioannou  _et al._ [2012] C. C. Ioannou, V. Guttal, and I. D. Couzin, Predatory fish select for coordinated collective motion in virtual prey, Science 337, 1212 (2012).
  * Vicsek  _et al._ [1995] T. Vicsek, A. Czirók, E. Ben-Jacob, I. Cohen, and O. Shochet, Novel type of phase transition in a system of self-driven particles, Physical review letters 75, 1226 (1995).
  * Couzin  _et al._ [2002] I. D. Couzin, J. Krause, R. James, G. D. Ruxton, and N. R. Franks, Collective memory and spatial sorting in animal groups, Journal of theoretical biology 218, 1 (2002).
  * Hemelrijk and Kunz [2005] C. K. Hemelrijk and H. Kunz, Density distribution and size sorting in fish schools: an individual-based model, Behavioral Ecology 16, 178 (2005).
  * Strömbom [2011] D. Strömbom, Collective motion from local attraction, Journal of theoretical biology 283, 145 (2011).
  * Czirók  _et al._ [1999] A. Czirók, A.-L. Barabási, and T. Vicsek, Collective motion of self-propelled particles: Kinetic phase transition in one dimension, Physical Review Letters 82, 209 (1999).
  * Toner and Tu [1995] J. Toner and Y. Tu, Long-range order in a two-dimensional dynamical xy model: how birds fly together, Physical review letters 75, 4326 (1995).
  * Jhawar  _et al._ [2019] J. Jhawar, R. G. Morris, and V. Guttal, Deriving mesoscopic models of collective behavior for finite populations, in  _Handbook of Statistics_ , Vol. 40 (Elsevier, 2019) pp. 551–594.
  * Reynolds [1987] C. W. Reynolds, Flocks, herds and schools: A distributed behavioral model, in  _Proceedings of the 14th annual conference on Computer graphics and interactive techniques_ (1987) pp. 25–34.
  * Huth and Wissel [1992] A. Huth and C. Wissel, The simulation of the movement of fish schools, Journal of theoretical biology 156, 365 (1992).
  * Parrish  _et al._ [2002] J. K. Parrish, S. V. Viscido, and D. Grunbaum, Self-organized fish schools: an examination of emergent properties, The biological bulletin 202, 296 (2002).
  * Hildenbrandt  _et al._ [2010] H. Hildenbrandt, C. Carere, and C. K. Hemelrijk, Self-organized aerial displays of thousands of starlings: a model, Behavioral Ecology 21, 1349 (2010).
  * Calovi  _et al._ [2018] D. S. Calovi, A. Litchinko, V. Lecheval, U. Lopez, A. Pérez Escudero, H. Chaté, C. Sire, and G. Theraulaz, Disentangling and modeling interactions in fish with burst-and-coast swimming reveal distinct alignment and attraction behaviors, PLoS computational biology 14, e1005933 (2018).
  * Lei  _et al._ [2020] L. Lei, R. Escobedo, C. Sire, and G. Theraulaz, Computational and robotic modeling reveal parsimonious combinations of interactions between individuals in schooling fish, PLoS computational biology 16, e1007194 (2020).
  * Jhawar  _et al._ [2020] J. Jhawar, R. G. Morris, U. Amith-Kumar, M. D. Raj, T. Rogers, H. Rajendran, and V. Guttal, Noise-induced schooling of fish, Nature Physics 16, 488 (2020).
  * Biancalani  _et al._ [2014] T. Biancalani, L. Dyson, and A. J. McKane, Noise-induced bistable states and their mean switching time in foraging colonies, Physical review letters 112, 038101 (2014).
  * Dyson  _et al._ [2015] L. Dyson, C. A. Yates, J. Buhl, and A. J. McKane, Onset of collective motion in locusts is captured by a minimal model, Physical Review E 92, 052708 (2015).
  * Jhawar and Guttal [2020] J. Jhawar and V. Guttal, Noise-induced effects in collective dynamics and inferring local interactions from data, Philosophical Transactions of the Royal Society B 375, 20190381 (2020).
  * Chaté  _et al._ [2008] H. Chaté, F. Ginelli, G. Grégoire, F. Peruani, and F. Raynaud, Modeling collective motion: variations on the vicsek model, The European Physical Journal B 64, 451 (2008).
  * Grégoire and Chaté [2004] G. Grégoire and H. Chaté, Onset of collective and cohesive motion, Physical review letters 92, 025702 (2004).
  * Ballerini  _et al._ [2008] M. Ballerini, N. Cabibbo, R. Candelier, A. Cavagna, E. Cisbani, I. Giardina, V. Lecomte, A. Orlandi, G. Parisi, A. Procaccini, _et al._ , Interaction ruling animal collective behavior depends on topological rather than metric distance: Evidence from a field study, Proceedings of the national academy of sciences 105, 1232 (2008).
  * Camperi  _et al._ [2012] M. Camperi, A. Cavagna, I. Giardina, G. Parisi, and E. Silvestri, Spatially balanced topological interaction grants optimal cohesion in flocking models, Interface focus 2, 715 (2012).
  * Gautrais  _et al._ [2012] J. Gautrais, F. Ginelli, R. Fournier, S. Blanco, M. Soria, H. Chaté, and G. Theraulaz, Deciphering interactions in moving animal groups, PLOS Computational Biology 8, 1 (2012).
  * Herbert-Read  _et al._ [2011] J. E. Herbert-Read, A. Perna, R. P. Mann, T. M. Schaerf, D. J. Sumpter, and A. J. Ward, Inferring the rules of interaction of shoaling fish, Proceedings of the National Academy of Sciences 108, 18726 (2011).
  * Beleyur and Goerlitz [2019] T. Beleyur and H. R. Goerlitz, Modeling active sensing reveals echo detection even in large groups of bats, Proceedings of the National Academy of Sciences 116, 26662 (2019).
  * Bode  _et al._ [2010a] N. W. Bode, D. W. Franks, and A. J. Wood, Making noise: emergent stochasticity in collective motion, Journal of theoretical biology 267, 292 (2010a).
  * Bode  _et al._ [2011] N. W. Bode, D. W. Franks, and A. J. Wood, Limited interactions in flocks: relating model simulations to empirical data, Journal of The Royal Society Interface 8, 301 (2011).
  * Aoki [1982] I. Aoki, A simulation study on the schooling mechanism in fish., Bull. Jpn. Soc. Sci. Fish 48, 1081 (1982).
  * Katz  _et al._ [2011] Y. Katz, K. Tunstrøm, C. C. Ioannou, C. Huepe, and I. D. Couzin, Inferring the structure and dynamics of interactions in schooling fish, Proceedings of the National Academy of Sciences 108, 18720 (2011).
  * Lopez  _et al._ [2012] U. Lopez, J. Gautrais, I. D. Couzin, and G. Theraulaz, From behavioural analyses to models of collective motion in fish schools, Interface focus 2, 693 (2012).
  * Hemelrijk and Hildenbrandt [2008] C. K. Hemelrijk and H. Hildenbrandt, Self-organized shape and frontal density of fish schools, Ethology 114, 245 (2008).
  * Mishra  _et al._ [2012] S. Mishra, K. Tunstrøm, I. D. Couzin, and C. Huepe, Collective dynamics of self-propelled particles with variable speed, Physical Review E 86, 011901 (2012).
  * Klamser  _et al._ [2021] P. P. Klamser, L. Gómez-Nava, T. Landgraf, J. W. Jolles, D. Bierbach, and P. Romanczuk, Impact of variable speed on collective movement of animal groups, Frontiers in Physics 9, 516 (2021).
  * Strömbom  _et al._ [2019] D. Strömbom, T. Hassan, W. Hunter Greis, and A. Antia, Asynchrony induces polarization in attraction-based models of collective motion, Royal Society open science 6, 190381 (2019).
  * Ward  _et al._ [2018] A. J. Ward, T. Schaerf, A. Burns, J. Lizier, E. Crosato, M. Prokopenko, and M. M. Webster, Cohesion, order and information flow in the collective motion of mixed-species shoals, Royal Society open science 5, 181132 (2018).
  * Ester  _et al._ [1996] M. Ester, H.-P. Kriegel, J. Sander, X. Xu, _et al._ , A density-based algorithm for discovering clusters in large spatial databases with noise., in  _kdd_ , Vol. 96 (1996) pp. 226–231.
  * Kalami Heris [2015] M. Kalami Heris, Dbscan clustering in matlab, Yarpiz, URL: https://yarpiz.com/255/ypml110-dbscan-clustering (2015).
  * Guttal and Couzin [2010] V. Guttal and I. D. Couzin, Social interactions, information use, and the evolution of collective migration, Proceedings of the national academy of sciences 107, 16172 (2010).
  * Aldana and Huepe [2003] M. Aldana and C. Huepe, Phase transitions in self-driven many-particle systems and related non-equilibrium models: a network approach, Journal of Statistical Physics 112, 135 (2003).
  * Aldana  _et al._ [2007] M. Aldana, V. Dossetti, C. Huepe, V. Kenkre, and H. Larralde, Phase transitions in systems of self-propelled agents and related network models, Physical review letters 98, 095702 (2007).
  * Turgut  _et al._ [2020] A. E. Turgut, İ. C. Boz, İ. E. Okay, E. Ferrante, and C. Huepe, Interaction network effects on position-and velocity-based models of collective motion, Journal of the Royal Society Interface 17, 20200165 (2020).
  * Lemasson  _et al._ [2009] B. H. Lemasson, J. J. Anderson, and R. A. Goodwin, Collective motion in animal groups from a neurobiological perspective: the adaptive benefits of dynamic sensory loads and selective attention, Journal of theoretical biology 261, 501 (2009).
  * Lemasson  _et al._ [2013] B. H. Lemasson, J. J. Anderson, and R. A. Goodwin, Motion-guided attention promotes adaptive communications during social navigation, Proceedings of the Royal Society B: Biological Sciences 280, 20122003 (2013).
  * Calvao and Brigatti [2014] A. M. Calvao and E. Brigatti, The role of neighbours selection on cohesion and order of swarms, PLoS One 9, e94221 (2014).
  * Rosenthal  _et al._ [2015] S. B. Rosenthal, C. R. Twomey, A. T. Hartnett, H. S. Wu, and I. D. Couzin, Revealing the hidden networks of interaction in mobile animal groups allows prediction of complex behavioral contagion, Proceedings of the National Academy of Sciences 112, 4690 (2015).
  * Aoki [1980] I. Aoki, An analysis of the schooling behavior of fish: internal organization and communication process, Bull. Ocean. Res. Inst. Univ. Tokyo 12, 1 (1980).
  * Bode  _et al._ [2010b] N. W. Bode, J. J. Faria, D. W. Franks, J. Krause, and A. J. Wood, How perceived threat increases synchronization in collectively moving animal groups, Proceedings of the Royal Society B: Biological Sciences 277, 3065 (2010b).
  * MAT [2021] _MATLAB version 9.11.0.1769968 (R2021b)_ , The Mathworks, Inc., Natick, Massachusetts (2021).
  * Cormen  _et al._ [2009] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to algorithms (3-rd edition), MIT Press and McGraw-Hill (2009).

##  Appendix A  Variable speed model for mobile groups

###  A.1 Agent based simulations

We employ a two dimensional model to simulate the collective motion of a
mobile group of organisms. Motion of an organism depends on its instantaneous
velocity (given by its direction of heading and speed), which evolves in time
as it undergoes various interactions or encounters any obstacle for motion.
Equations 2 and 3 describe how an organism’s heading and speed evolve in time.

$\tau_{\theta}\frac{d\angle\mathbf{e}_{i}}{dt}=\angle\mathbf{e}_{d,i}-\angle\mathbf{e}_{i}+\Delta\theta_{r,i}$
(2)

$\tau\frac{ds_{i}}{dt}=s_{d,i}-s_{i}+\Delta s_{r,i}$ (3)

Every time an organism interacts, it gets a new desired direction
$\mathbf{e}_{d,i}$ of motion and a new desired speed $s_{d,i}$ and the
organism tries to achieve its new desired velocity in a time scale
corresponding to $\tau$. The value of $\tau$ is related to its body mass and
ability to turn/move quickly. Each organism aligns, attracts or turns
spontaneously with rates $r_{p}$, $r_{c}$ and $r_{s}$ respectively. The time
of the interaction is chosen stochastically: sampled from an exponential
distribution with mean corresponding to the rate of the interaction.
$\Delta\theta_{r,i}$ and $\Delta s_{r,i}$ in Eqs 2 and 3 correspond to the
changes in speed and direction of an organism due to the presence of an
obstacle; which could be another organism or a boundary.

Note: an organism moves continuously in space and time, making continuous
adjustments to its trajectory when approaching an obstacle. Changes to its
desired velocity due to interaction events occur only at discrete points in
time.

###  A.2 Behavioural interactions of the organisms

In our simulations, we assume that organisms undergo three different types of
interactions: spontaneous turning, alignment and attraction. In what follows
we describe the mathematical details of these interactions.

#### Spontaneous turning:

As an organisms moves, it spontaneously turns at a mean rate $r_{s}$,
independent of its own state and the states of its neighbours. The angle they
wish to turn to, is sampled from a (circular) normal distribution with mean
zero and variance $\sigma_{a}$ as in Eq 4.

$\angle\mathbf{e}_{d,i}=\angle\mathbf{e}_{i}+\mathcal{N}(0,\sigma_{a})$ (4)

The speed of the individual is sampled from a normal distribution with mean
$s_{0}$, which is the desired velocity for movement of the organism and a
variance $\sigma_{s}$ which quantifies the spread of the speeds of the
individuals as observed in typical empirical data [49, 50].

$s_{d,i}=\mathcal{N}(s_{0},\sigma_{s})$ (5)

#### Alignment:

Every organism $i$, at an average rate $r_{p}$, aligns with its neighbour $j$
by copying its direction of movement $\mathbf{e}_{j}$ and speed $s_{j}$, over
a time scale $\tau$ (see eqs 6 and 7).

$\angle\mathbf{e}_{d,i}=\angle\mathbf{e}_{j}$ (6) $s_{d,i}=s_{j}$ (7)

The Equations 6 and 7 correspond to the case where the organism interacts with
just one of its nearby neighbour. For the general case, where an organism
interacts with $k$ of its $K$ nearby, visible neighbours the interactions take
the following form.

$\angle\mathbf{e}_{d,i}=\frac{1}{k}\sum_{j=1}^{k}\angle\mathbf{e}_{j}$ (8)
$s_{d,i}=\frac{1}{k}\sum_{j=1}^{k}s_{j}$ (9)

#### Attraction:

An organism $i$ moves towards another $l$, at an average rate, $r_{c}$, to
stay cohesive. It is reasonable to expect $i$ to change its current trajectory
to move towards $l$ only when it is considerably far away from $l$. This
feature is brought into the interaction term by using a distance based
weighting $f_{a,l}$, as shown in Eq 10.

$\angle\mathbf{e}_{d,i}=\angle\big{[}\mathbf{e}_{i}+f_{a,l}\mathbf{r}_{il}\big{]}$
(10)

We can also model the change in speed experienced by $i$ in a similar fashion:
when $i$ is far away from $k$, it moves faster (see eq 11).

$s_{d,i}=s_{0}+\kappa_{a}f_{a,l}$ (11)

Again Eq 10 and 11 correspond to pairwise interactions where $k=1$. For the
generic case, the interactions take the following form.

$\angle\mathbf{e}_{d,i}=\angle\big{[}\mathbf{e}_{i}+\frac{1}{k}\sum_{l=1}^{k}f_{a,l}\mathbf{r}_{il}\big{]}$
(12) $s_{d,i}=s_{0}+\kappa_{a}\frac{1}{k}\sum_{l=1}^{k}f_{a,l}$ (13)

The weighting function selected for use in our model has the form shown in eq
14. When $\gamma$ is $>2$, it softens the effect of the attractive interaction
within distance $l$ around the organism $l$. Only when
$(\|\mathbf{r}_{ik}\|-2R)>l$, the attractive interaction has a significant
effect.

$f_{a,l}=\Bigg{(}\frac{\|\mathbf{r}_{il}\|-2R}{l}\Bigg{)}^{\gamma}$ (14)

#### Collision avoidance:

Organisms avoid collision with each other during collective motion. They turn
towards a direction that is perpendicular to that connecting the organisms as
shown in eq 15, to prevent collision events.

$\Delta\theta_{r}=\angle\Bigg{[}\frac{1}{n_{r}}\sum_{o=1}^{n_{r}}\lambda_{a}\lambda_{p}\big{[}r_{io,\perp}\big{]}\Bigg{]}$
(15)

Here, $n_{r}$ is the number of individuals that are within the zone of
repulsion $(zor)$: which is the critical distance between organisms below
which they begin to respond to the proximity of their neighbours. In addition
to turning, they also slow down as they approach an obstacle, as shown in eq
16. The rate of slowing down is inversely proportional to the distance between
the fish and directly proportional to the rate of approach.

$\Delta
s_{r}=\frac{\kappa_{r}}{n_{r}}\sum_{o=1}^{n_{r}}\lambda_{a}\lambda_{p}\Bigg{[}\frac{s_{i}\mathbf{e}_{i}.\mathbf{r}_{io}+s_{o}\mathbf{e}_{o}.\mathbf{r}_{oi}}{\big{(}\|\mathbf{r}_{io}\|-2R\big{)}^{\beta}}\Bigg{]}$
(16)

The parameters $\lambda_{a}$ and $\lambda_{p}$ are binary variables that take
the value $1$ only when the fish $i$ moves towards fish $o$ and the distance
between the two fish is decreasing in time. They are defined using a Heaviside
functions as shown in eqs 17 and 18.

$\displaystyle\lambda_{a}=\mathcal{H}[e_{i}.r_{io}]$ (17)
$\displaystyle\lambda_{p}=\mathcal{H}[e_{i}.r_{io}+e_{o}.r_{oi}]$ (18)

#### Remark: bounds on speed:

The speed $s_{i}$ of an organism, is bound between $0$ and $s_{max}$, which is
set to $10$\mathrm{c}\mathrm{m}\mathrm{s}^{-1}$$ in our study. This is
enforced in both the spontaneous turning and attraction interactions.

#### Remark: local state-dependent behaviour:

We model organismal–movement using agents that interact with each other at a
rate, intrinsic of the agent, i.e. independent of the local state of the
group. Simply put, a fish aligns with a neighbouring fish, irrespective of
whether the local neighbourhood is ordered or not. Similarly, a fish does not
move towards its neighbour in response to its perception of the less cohesive
neighbourhood. However, interestingly, the implementation of the alignment and
attraction rules, bring an indirect local-state dependent behaviour. An
organism aligning with a neighbour does not change the local order
significantly when the local neighbourhood is sufficiently ordered. While,
this change is significant when the neighbourhood is disordered. The weighting
function $f_{a,l}$ as described in eq 14, makes sure that the effect of the
attraction interaction is significant only when the organism is away from the
local neighbour it is interacting with. Even though organisms interact in a
manner, independent of the local state of the system, the interaction events
themselves cause significant change in the local group-properties only when
the local state is away from that the fish desires to achieve.

#### Numerical simulations:

The codes for the agent based model were developed in-house and the numerical
simulations are carried out in MATLAB ©. We ran simulations for T = 3500s with
integration time of dt = 0.05s for 24 realisations. Codes have been made
available (see code availability).

Model parameter values used for the results in the main text are given in
(Table 1).

Parameter |  Unit |  Symbol |  Value
---|---|---|---
Spontaneous rate |  $\mathrm{s}^{-1}$ |  $r_{s}$ |  1
Alignment rate |  $\mathrm{s}^{-1}$ |  $r_{p}$ |  1.5
Attraction rate |  $\mathrm{s}^{-1}$ |  $r_{a}$ |  1
Visual field |  Degree |  $\theta_{s}$ |  $270^{0}$
Desired Speed |  $\mathrm{c}\mathrm{m}~{}\mathrm{s}^{-1}$ |  $s_{0}$ |  0.2
Maximum Speed |  $\mathrm{c}\mathrm{m}~{}\mathrm{s}^{-1}$ |  $s_{max}$ |  $5\times s_{0}$
Agent size |  cm |  $R$ |  0.2
Variance of angular displacement (spontaneous turn) |  $\text{rad}^{2}$ |  $\sigma_{a}$ |  $\frac{\theta_{s}\times\pi}{2\times 180}$
Variance of speed (spontaneous turn) |  $\mathrm{c}\mathrm{m}^{2}~{}\mathrm{s}^{-2}$ |  $\sigma_{s}$ |  $v_{0}$
Relaxation time for speed |  s |  $\tau$ |  0.2
Relaxation time for angular speed |  s |  $\tau_{\theta}$ |  0.5
Distance-dependent attraction (coefficient) |  $\mathrm{c}\mathrm{m}~{}\mathrm{s}^{-1}$ |  $\kappa_{a}$ |  $10^{-2}$
Distance-dependent attraction (order) |  1 |  $\gamma$ |  3
Zone of repulsion |  cm |  $zor$ |  1.2
Distance-dependent repulsion (coefficient) |  $\mathrm{c}\mathrm{m}^{\beta}$ |  $\kappa_{r}$ |  $-10^{-3}$
Distance-dependent repulsion (order) |  1 |  $\beta$ |  3
Maximum distance between agents to belong to the same cluster |  cm |  $\epsilon$ |  2.4
Table 1: Summary of model parameters.

##  Appendix B  Analysing the interaction networks

We begin by constructing an adjacency matrix $\mathcal{A}$ where
$\mathcal{A}_{ij}=1$ whenever an organism $i$ (represented by node $i$ in the
graph) interacts with organism $j$ (node $j$) through an attraction
interaction. This process is continued for all the similar interactions during
the time window $t_{w}$. Irrespective of how many times $i$ and $j$ interact,
only a single edge is constructed between the two.

We use this adjacency matrix $\mathcal{A}$ to construct a directed graph,
$\mathcal{G}$. We use a MATLAB [51] function `digraph` to construct the
directed graph, $\mathcal{G}$. Once we construct $\mathcal{G}$, we use another
function in MATLAB, `conncomp` to analyse the connectivity of the graph.
`conncomp` groups the nodes based on their connectivity. Node $i$ and $j$
belong to the same group if there is path from $i$ to $j$ and from $j$ to $i$
[52]. We then define the network parameter $\mathcal{N}_{p}$ as the average
size of the largest group divide by total number of nodes (organisms).