Skip to main content

Dynamic Modular Networks Model Mediated by Confinement


We present a model for network transformation mediated by confinement, as a demonstration of a simple network dynamics that has a direct connection with real world quantities. The model has the capacity of generating complex structures similar to real world networks by the use of two parameters. Starting from an Erdös-Rényi network, nodes are randomly selected to be temporarily confined. Confined nodes form new links among themselves at the same pace they lose connections with the outside nodes. As the network evolves according to the parameters of the model, a series of non trivial network characteristics emerge: the formation of stable heterogeneous degree distributions similar to those of empirical networks, an increasing clustering coefficient, and the emergence of communities outside the confined space. Different from the traditional benchmarks used to create modular networks, there is no arbitrary definition of the number of modules, nor node meta-data defining it as a member of a particular community, nor a tunable parameter directly related with expected modularity. Modules emerge as a result of the dynamics while nodes move among them as connections are rewired. The proposed algorithm has the potential to simulate community dynamics cases in situations where time stamped network data is scarce or absent.


In several fields, there are networks exhibiting complex ordering and heterogeneity features that are not present in strictly random networks. Among these complex features, we can name some of special interest: clustering (Watts and Strogatz 1998), different forms of network centrality (Freeman et al. 1991; Freeman 1977), heterogeneity of degree distribution, and network path length. The presence of such distinct features in real-world systems suggests an underlying ordering, coming from non-linear interactions between network elements, which can only be explained by taking such interactions into account.

In network science, two topics are of great interest nowadays: dynamic networks and structural communities. Complex network data is generally collected as static snapshots, while actual complex systems are naturally dynamic. They may grow or shrink as nodes and connections are created, destroyed, or redirected. Structural communities are based on the general idea that a group of nodes in the network are strongly connected, while they are weakly connected to the rest of the network. This subject is in fact more complex since it includes the possibility of nested, intersected, or multilevel communities (Palla et al. 2005). Communities in networks is also a very active subject (Fortunato 2010), with contributions steadily coming on characterization of communities in real world networks, faster algorithms for detecting such structures in large networks (Yang et al. 2016), and the development of benchmarks (Condon and Karp 2001) for testing those models. The two topics come together in the present contribution, where we study community structures mediated by confinement in dynamic networks.

Several processes in the dynamics of complex networks are mediated by the temporary confinement of agents. Considering imprisonment for instance, while there is some controversy whether high levels of imprisonment actually decrease crime rates, it is common practice worldwide. The idea is, precisely, to keep the criminal in quarantine away from society, either as retribution, or for incapacitation, deterrence, or rehabilitation (Pratt and Cullen 2005). Penal methods vary widely depending on the legal system —from the Pennsylvanian solitary incarceration system, to the day work-night confinement Auburn model, going through the progressive stages, or marking system, where conditions and level of incarceration improve as a result of good behavior, time lapse, or other “marks” (Kerley 2017). Regarding human dynamics, what usually happens in real world prisons is that when someone is sent to jail, a fraction of their relationships are lost due to incarceration, while the closest relationships (family, partner) are weakened but kept. On the other hand, the inmate is likely to make new contacts while serving time in prison, and some of these new relationships may remain after the person is released, possibly resulting in recidivism (Brame et al. 2018).

Nevertheless, confined spaces are not restricted to prisons; they can be a neighborhood, where residents are prone to meet, an on-line group of people connected by a common interest, a school or university where students enter and leave the institution every year, due to enrollments, transferring, and graduation. In such examples, while the structure of the community remains approximately the same, the individuals who form these structures change over time. Two mechanisms can be identified then: the favorable conditions for forming new connections in a subset of a bigger social network, and the flow of agents inside and outside that subgroup; mechanisms that we call “confinement dynamics". Spaces do not have to be defined by physical boundaries, they may be real or virtual spaces where agents tend to connect more easily among themselves than with agents outside of confined space, while remaining there for a finite period of time.

We propose a simple model for capturing and studying the essential aspect of the processes discussed above, based in two parameters with clear meaning: the relative size of the confined space and the rate of exchange in and out of the confinement. In order to study the confinement dynamics we propose a computational model consisting of a graph which represents a network and where the confined space is a subgraph of nodes labeled as confined. There is flux of nodes in and out of the confinement and the connections are rearranged in order to reflect the tendency of the confined subgraph to increase internal connections while losing external connections. We show that the dynamics based on the proposed model provides a simple explanation for the appearance of complex structures observed in social networks, such as high clustering, heterogeneous degree distribution, and hubs. In addition, the results show the emergence of highly connected subgraphs that fit modern definitions of structural communities.

In “Introduction” section we present the methodology, including the description of the numerical simulations. “Methodology” section contains the results on the networks’s dynamics and a discussion about the emergence of communities and other relevant measures. “Results” section is devoted to conclusions.


The confinement mediated dynamic network model

The model is characterized by an initial network \(\mathcal {N}\) (not necessarily fully connected), where each node is in one of two states: confined or free. Links are unweighted and undirected, without self connections. The initial network is transformed by changing the states of nodes and rewiring of connections, which occurs at every time step, until a steady topological state is eventually reached. The detailed algorithm works as follows:

  • We start with a random network \(\mathcal {N}(\langle k \rangle)\), with N nodes and an average degree 〈k〉, built by the Erdös-Rényi (E-R) algorithm \(\mathcal {N}(p,N)\) (Erdös and Rényi 1959).

  • A subset of Nc nodes is randomly selected and temporarily labeled as confined; we refer to this subset and its links as a confined space or simply a confinement, and we call it \(\mathcal {P}\). During the dynamics, nodes enter and leave the confinement while keeping Nc constant. We define the relative confinement size, ps, as the ratio between Nc and the network size N:

    $$ p_{s} = \frac{N_{c}}{N}\;, $$

    which is one of the model’s key parameters.

  • The algorithm proceeds in discrete time steps, each one composed of two phases: a) the flux phase and b) the rewiring phase. At the flux phase, Nf nodes outside confinement are randomly selected and turned into confined, while Nf confined nodes are randomly selected and set free. Notice that at this phase the topology of the network does not change, only the labels of the nodes. Then, the flux of nodes is governed by a second key parameter, the flux ratio pf:

    $$ p_{f}=\frac{N_{f}}{N}\;. $$
  • Therefore, all the links in the network are of one of three types (in, out, io) identified as follows: in is the number of links among confined nodes or internal links, out is the number of connections between free (external) nodes, and io denotes the number of links between free and confined nodes. These three quantities vary with time but the total number of edges, , is conserved:

    $$ \ell = \ell_{in}(t) + \ell_{out}(t) + \ell_{io}(t). $$
  • The topology changes at the rewiring phase: each one of the Nc randomly selects one of its connections to a free node, redirecting it to a confined one, selected randomly as well. This represents the tendency of the confined nodes to alienate from the non-confined, or “outside”, part of the network, while they increase their links among themselves. Denoting a confined node as \(n_{j}^{c}\), it will have one of its links changed if it has at least one link outside the confinement and if there is a confined node not yet connected to it (multiple links between nodes are not allowed). If both conditions are fulfilled, one of the links to the outside is selected, cut, and replaced by a link to a confined node selected at random among all the possible candidates.

There are two binding conditions between the parameters ps and pf. The influx/outflux can not exceed the size of the confined space, so \(N_{c} \geqslant N_{f}\), i.e.:

$$ p_{s} \geqslant p_{f}. $$

On the other hand, NfNNc must be satisfied, for the number of influx nodes (Nf) has to be less than the number of available free nodes, that is

$$ p_{s} + p_{f} \leqslant 1\;, $$

however, as in any realistic scenario, NcN, from condition Eq. 4, condition Eq. 5 is always satisfied.

As the dynamics progress, the topological characteristics of the network transform, except the number of nodes and edges, until a steady state is eventually reached. At this stage, the roles of individual nodes and edges are in continuous transformation, but the general form of the network remains stable. Hereafter, we use this model to demonstrate the complex behavior that emerges from the described confinement dynamics, as well as the influence of the size and the flux in the resulting networks.

Computational simulations

Unless otherwise stated, all simulations use E-R random networks, with N=104 nodes and average connectivity degree 〈k〉=4 as starting conditions. Different network sizes and link densities may modify the numerical results of the simulations; however, in this research, we focus mainly on the effects of the confinement parameters: ps (relative confinement size) and pf (relative flux). Besides, we restrict the study to networks with a single confined space; afterward, we introduce multiple confined spaces and discuss system size scaling.

Each simulation runs until the network reaches a steady state. One simulation time step is defined as a rewiring phase that sweeps all confined agents, followed by a flux phase. The number of individual time steps m necessary to reach a steady state, depends on the parameters ps and pf; for all results presented here we use 103<m<2×104. In general, both a smaller ps (smaller confined space \(\mathcal {P}\)) and a smaller pf (smaller flux of nodes trough \(\mathcal {P}\)) require longer times to reach a steady state.

During the network evolution we compute the following metrics: the average clustering coefficient C (Watts and Strogatz 1998), the degree distribution P(k), and network fragmentation, i.e. size and stability of the largest connected component. Besides, the dynamics tend to create highly interconnected clusters with lower connectivity between them. In order to find partitions that may define these clusters, we use the “Louvain algorithm” (Blondel et al. 2008), which we also use to follow the time evolution of the modularity.


Clustering Increase

Most empirical networks of interest, particularly social networks, display highly interconnected subgraphs. The concept of a global clustering coefficient C, or transitivity (Holland and Leinhardt 1971), is one of the ways we use to quantify this effect. It is well known that large random networks present very low clustering coefficient compared to real world networks with equal density —in social networks we can find usually C10−1 (Albert and Barabási 2002; Liljeros et al. 2001). This relatively elevated coefficient must be driven by some intentional or plannedmechanism typical of social interactions.

Figure 1 shows the time evolution of the global clustering coefficient, starting from a random network (C≈〈k〉/N=4×10−4), for a fixed ps=0.01 and several values of the parameter pf; it can be seen that C always increases and, after a transient, reaches a stable state. Hence, the confinement dynamics transforms the initial E-R network, gradually increasing the clustering coefficient, depending on the parameters ps and pf, which play a key role in such reshaping. The increase in C occurs inside the confined space, where nodes tend to connect to each other due to the rewiring mechanism. Such behavior, which increases the confinement subgraph density, is typical of a socially driven network. At the same time, the flux dynamics continuously disseminates members of these groups to the outside of the confinement.

Fig. 1
figure 1

Time evolution of the clustering coefficient C due to the confinement dynamics. Initial network is random with N=104 and 〈k〉=4 with a near zero clustering C=0.0004. The confined space \(\mathcal {P}\) has relative size ps=0.01 for all curves while the flux pf is different. After a transient, C reaches a stable value inversely proportional to pf. C is measured over the largest connected component

Noteworthy, the asymptotic values of C are independent of the initial network; if, for example, we start from a Watts-Strogatz (WS) network, the clustering decreases to the same asymptotic values of Fig. 1, which, for fixed N, seem to depend inversely on parameter pf. The reason different input networks yield the same resulting steady state is the quasi-random nature of the dynamics, in which confined and released nodes, along with the rewiring, are all chosen randomly. Therefore, the initial configuration has no influence in the asymptotic state.

We have previously shown that the clustering coefficient inversely depends on the flux pf; in addition, it weakly depends on the relative confinement size ps. This behavior can be better visualized in the phase diagram of C in the pspf plane (Fig. 2). A smaller flux makes nodes spend more time in confinement, gaining more links and having greater chances of forming new triangles, thus increasing clustering. On the other hand, a bigger confined space \(\mathcal {P}\) increases the chance of forming new triangles, partially because nodes stay longer inside \(\mathcal {P}\), having more time to form new connections, but also because the number of links that can be redirected to the confinement is proportional to the number of nodes inside it. The newly formed triangles eventually go outside the confinement, contributing to the general increase in the value of C.

Fig. 2
figure 2

Map of clustering coefficient (of the connected component) as a function of parameters ps and pf. Smaller flux results in the nodes remaining more time inside \(\mathcal {P}\), increasing the probability to form triangles in the enclosed space. Larger confined spaces increase the chance of forming new triangles, partially because nodes stay longer inside \(\mathcal {P}\), having more time to form new connections, but also because the number of links that can be redirected to the confinement is proportional to the number of nodes inside of it. Initial network is random with N=104 and 〈k〉=4 with a near zero clustering C=0.0004

Nevertheless, if ps is of the size of the system, there is no actual confinement, just pure reshuffling. In such a case, C is not expected to change from its very low initial value. Therefore, a non monotonic behavior for Cvs ps would be exhibited if all possible values of ps were explored, but that is outside the region of practical interest (ps1).

We have to mention that a size dependence of C(ps,pf) is observed and it is discussed in the last two sections, which regard the size scaling of the model.

Community Emergence:

Apart from increasing the global clustering, the proposed confinement dynamics generates highly internally connected clusters, weakly linked between them; the kind of network structures associated with the idea of structural communities. The detection and characterization of communities (or modules) in large networks is a trending topic in network science (Barabási and et al. 2016), and the emergence of community structures is a remarkable result of the proposed network dynamics.

We use a modularity (Newman 2006) maximization algorithm, the “Louvain method” (Blondel et al. 2008), for partitioning the network, measuring the modularity Q, and detecting communities. Moreover, we visually inspect the networks’ configuration by making snapshots using a drawing software (Bastian et al. 2009; Martin et al. 2011) and a force-directed graph drawing algorithm (Jacomy et al. 2014) (see Fig. 3).

Fig. 3
figure 3

From an initial random network of size N=104 and 〈k〉=4, the confinement dynamics creates a stable and more complex network. The figure shows the effect of a single confined space, where the dynamics parameters are ps=0.025 and pf=0.00275. In this visual representation of the resulting network a force algorithm is used for node positioning (Jacomy et al. 2014), resulting in strongly connected nodes being grouped together. Upper panel: nodes are color coded according to the resulting partitioning of the community detection algorithm (Blondel et al. 2008). Lower Panel: With the same node and link disposition, nodes are color coded as confined in red or free in blue. During the dynamics, nodes enter and leave confinement, and links are rewired, but the general characteristics of the network remain the same. There is clear overlap between one of the communities of the upper panel (the gray one on the right side) and the confinement of the lower panel

Unlike known benchmarks for modular networks, the proposed dynamics does not pre-fix the modularity value, and neither the number of modules nor the average size of them; communities emerge naturally during simulation, without the use of any a priori grouping meta-data. While the procedure is not crafted to produce the modular separation of the graph, it is obviously the mechanism behind the emergence of such reordering of the network.

In order to understand how communities emerge during the dynamics, we consider the confined space \(\mathcal {P}\) as being one partition or community, named c, and examine its contribution to the global modularity M, named Mc (Newman 2006):

$$ M_{c} = \frac{1}{2\ell} \sum_{i,j}^{c} \left(A_{ij} - \frac{k_{i} k_{j}}{2\ell}\right)\;. $$

In Eq. 6, is the number of edges in the entire network, so \(\sum _{i=1}^{N} k_{i} = 2\ell \), Aij is the adjacency matrix, \(\frac {k_{i} k_{j}}{2 \ell }\) is the expected number of connections between nodes i and j for a random network, and the sum \(\sum _{i,j}^{c}\) is computed over the nodes inside the partition c with Nc nodes. This expression for Mc can be written in a simple form as

$$ M_{c} = \frac{\ell_{c}}{\ell} - \left(\frac{k_{c}}{2\ell}\right)^{2} $$

where \(\ell _{c} = 1/2\sum _{i,j}^{c} A_{ij}\) and \(k_{c} = \sum ^{c}_{i} k_{i}\) are the number of links and the total degree of partition c, respectively. As nodes inside \(\mathcal {P}\) receive new connections, the connectivity matrix gets additional Aij=1 terms. For each node rewired, both c and kc increase by 1, and as usually kc, then Mc is increased by

$$ \Delta M_{c} \approx \frac{1}{\ell}\;. $$

The above increase in the local contribution to the modularity is for each node that is rewired; in order to estimate the effective initial increase in modularity, all nodes that participate in the rewiring have to be considered:

$$ \Delta M_{t} \approx p_{s} N \times \frac{1}{\ell} \;, $$

and as =〈kN/2, we end up with

$$ \Delta M_{t} \approx \frac{2 p_{s}} {\langle k \rangle}\;. $$

This mean field estimation of the modularity increase rate is restricted to the condition pspf and even so, it represents an upper estimation, as fluctuations and correlations are not taken into account. Moreover, it is valid at the beginning of the dynamics, when the distribution of links is uniform, so modularity is at the random value M(0)=0.5. With the increase of internal connections after the transient, some nodes may no longer have connections to the outside, thus less rewiring occurs.

Similar arguments can be applied to explain how clusters survive outside the confinement using Eq. 6. Now consider that partition c is a cluster that has left \(\mathcal {P}\) some time ago. This newly formed cluster is rich with internal connections and is well connected to the confined space, then it may be detected as a single community. As time goes on, internal connections are preserved so the sum \(\sum ^{c}_{ij} A_{ij}\) remains the same, but the second (negative) term of the summation becomes less significant as the average connectivity 〈kc〉 decreases —due to rewiring of edges between the confined space and the cluster outside— resulting in an increased modularity Mc. Then, with less connections to the confined space, the structure eventually separates from it. Summarizing, there is a constant process of community creation inside the confined space and its neighborhood, leaving and separating from the confinement. These structures eventually may disappear as new communities are formed by the continuous process of confinement and flux; this dual mechanism results in stable modularity, number of communities, and average community size, while the nodes that form them change all the time.

The detection and evolution of communities in dynamic networks is still a debating task (Palla et al. 2007; Delvenne et al. 2010), so we limit our investigation to taking snapshots of the structures at each time step, measuring the modularity, and observing the stability of other proposed quantities. Figure 3 shows one selected snapshot of the network, using a force-directed algorithm for the visual representation in two different ways: the upper panel colors the eight identified communities at the time of the snapshot, while the lower panel colors the confined nodes (red) and outside confinement nodes (blue).

Figure 4 shows the time evolution of modularity for selected sets of relative confinement sizes, ps, and relative flux parameter, pf, along with the phase diagram of modularity in a region of interest of these two parameters. Partitioning of the network was achieved using the Louvain algorithm. It is shown in the left panel that modularity reaches a stable state after a transient that depends on the input network. The right panel shows a partial phase diagram of the key parameters of the model, showing a higher modularity in the darker blue region, associated with a smaller flux and intermediate confinement size. This sufficiently large confinement and small flux is consistent with the formation of highly connected clusters inside the confinement and their slow separation, forming an independent community.

Fig. 4
figure 4

Modularity associated with the partitioning of the resulting networks given different values of ps and pf. Left panel: time evolution from initial random network, Right Panel: modularity map as a function of ps and pf. In both figures initial networks are random with N=104 and 〈k〉=4

While modularity is useful in evaluating the quality of a given partition and the detected community structures seem to agree with graphical visualization, community detection algorithms have limitations regarding detection resolution in situations such as the merging of two communities into a single one, the partitioning of a single community, or ignoring nested communities. Another example of limitation is the finding of multiple communities with modularity superior to zero, when the Louvain algorithm is applied to a completely random network. This is due to local fluctuations in big networks, in which possible community partitions may arise from the modularity maximization algorithm. Nevertheless, as long as their limitations are taken into account (Fortunato 2010; Lancichinetti et al. 2008), these detection algorithms remain very useful.

As explained at the beginning of this section, communities are not predetermined, but emerge as an indirect result of the confinement dynamics. Therefore, we propose a second parameter to measure the existence and quality of the modules partition. We define the parameter ϕ(c) of a given partition c of size Nc as the ratio between the numbers of external and total links of that partition, so that for a node j of the partition c, \(k_{j}^{ext}\) is the number of external links and kj the degree of node j. Then,

$$ \phi(c) = \frac{\sum_{j=1}^{N_{c}} k_{j}^{ext}}{\sum_{j=1}^{N_{c}} k_{j}}. $$

So, for a partition with only internal connections, i.e. a completely closed community, ϕ(c)=0, while in a random partition of a random network we expect ϕ=0.5. We are interested in the average ratio for all partitions, thus, we define a global ratio \(\Phi (\mathcal {N})\) as a complementary way to follow the emergence and stability of the community structures:

$$ \Phi(\mathcal{N}) = \frac{\sum_{j=1}^{N} k_{j}^{ext,N_{c}}}{\sum_{j=1}^{N} k_{j}}. $$

Where \(k_{j}^{ext,N_c}\) is the number of external links of node j in partition Nc, with the sums made over the entire network. Figure 5 shows a clear correspondence with modularity data of Fig. 4; using the same sets of parameters ps and pf, we see that the curve with the lower asymptotic modularity has the higher asymptotic Φ(N).

Fig. 5
figure 5

Left Panel: time evolution of Φ for some choice parameters, the same ones used in Fig. 4, initial network is random with N=104 and 〈k〉=4 with ratio very close to Φ=0.5, with the detection algorithm bias giving slightly reduced values. Φ decreases with time in all cases where pspf, reaching a stable state. Right panel: phase diagram showing the ratio Φ in relation with the parameters ps and pf, all points originate from an initial random network with N=104 and 〈k〉=4

Degree Distribution

Starting from the initial network, the dynamics change the degrees of individual nodes. Eventually, the degree distribution P(k) reaches a stationary state, while the degree of individual nodes continue to change over time. The stable asymptotic form of P(k) depends on the network size N, the average degree 〈k〉, and the parameters ps and pf of the dynamics. Figure 6 shows the final stable distributions obtained from simulations using some sets of the parameters ps and pf. Increased degree heterogeneity results for smaller pf and bigger ps, (i.e. bigger confinement and/or smaller flux).

Fig. 6
figure 6

From an initial random network with N=104 and 〈k〉=4 with a Poisson degree distribution, P(k) changes to become more heterogeneous until a stable state is reached. This figure tries to isolate the effects of the parameters ps and pf in the heterogeneity. Left panel: Using a fixed flux rate pf=0.003 three curves are shown, each corresponding to the final stable P(k) of a different confinement size ps. Right panel: using a fixed confinement size ps=0.03 another three distributions are shown, each using a different value of pf

The distributions P(k) presented in Fig. 6 are some examples of the many different distributions that can be generated, each one corresponding to a distinct set of parameters. If ps=pf the network stabilizes and displays Poisson’s degree distribution like a random network of the same size and average degree. As the confinement increases and/or the flux decreases the resulting degree distributions shift to longer tails type with increasing heterogeneity. Among the P(k) distributions found in the simulations we encounter curves that could be better fitted either with Poisson or Gaussian distributions. However, log normal and power law distributions are ubiquitous, mostly in the lower region of pf, and to a less significant effect, in bigger confinement sizes, as can be seen in Fig. 7-left.

Fig. 7
figure 7

Different dynamic parameters generate distinct forms of degree distributions. Left Panel: For a fixed value of confined space, ps=0.035, two distributions are shown, one with higher pf (red triangles) juxtaposed to a fitted log normal (black dotted line), and the other with a smaller pf (purple circles) fitted to a power law. Lower pf, means nodes spend more time inside \(\mathcal {P}\), which allows for more in-confinement connections, then increasing degree heterogeneity. Both curves emerge from initial random networks with N=104 and 〈k〉=4. Right panel: Comparison with a real network obtained from the Brazilian Federal Police (see text for details of the data) (da Cunha and Gonçalves 2018). As the real data has M=0.96 and C=0.43, the degree distribution obtained from the model corresponds to the parameters that give the largest M and C. Even when they are not as large as the real ones, the similarity between both distributions is remarkable

Through the rewiring mechanism, confined nodes tend to increase connectivity, while free nodes tend to lose connections. By the flux mechanism, nodes are confined at random, and will also leave confinement at random. This means that the time spent in the confinement for t is similar for every node, so the heterogeneity of node degree must come from confinement during the last time steps. Assuming that a node j is confined at time t=t, the probability \(P_{f}^{j}(t=t^{\prime }+1)\) that the same node is released at the next flux step is:

$$ P_{f}^{j}(t=t^{\prime}+1) = \frac{p_{f}}{p_{s}}. $$

Since pspf, such probability is well defined, where a lower ratio means less chance of release. Since all nodes are picked at random, some pass quickly trough the confinement, while others might linger. The probability that a node stays in the confinement for a certain period Δt, (1−pf/ps)Δt, decreases exponentially with time. Nodes tend to gain connections while confined due to the rewiring dynamics, so those confined for a longer time tend to become more connected. From the exponentially decaying probability of confinement time, its average can be estimated as τps/pf, which explains why degree heterogeneity increases if ps increases (pf fixed, Fig. 6-left) and/or pf decreases (ps fixed, Fig. 6-right).

In order to check if the present model makes sense, we compare its results with a real network case. The data appeared in the paper “Topology, robustness, and structural controllability of the Brazilian Federal Police criminal intelligence network” (da Cunha and Gonçalves 2018), which consists of the network representation and topological analysis of data, obtained after several Brazilian Federal Police investigations in 2013. The network, designated BFP2013, shows very high modularity (M=0.96) and high clustering coefficient (C=0.4), higher than the maximum values of the present simulations (M=0.88 and C=0.14) obtained with N=104, 〈k〉 = 4, ps=0.035, and pf=0.005. Taking the stable state of the network that corresponds to the above parameters, we compute the normalized degree distribution P(k) and compare it with the normalized P(k) of the BFP2013 network (Fig. 7-right). Considering that the real network is much more modular structured, the qualitative agreement is remarkable. We must notice that the real network is only a small part of a much bigger social network (all Brazilian inhabitants) while in the simulation we consider the whole population, scaled down. If we restrict ourselves to nodes recently released from confinement, we would probably observe values even closer to those of the real criminal network. Given this practical case, we can say that the model has the potential for representing real case scenarios.

Network Fragmentation

The rewiring phase increases the link density inside the confined space. As the number of links is conserved in the whole network, nodes outside \(\mathcal {P}\) tend to have their connectivity degree reduced, eventually reaching k=0. Therefore, the outside confinement sub-graph may eventually fragment, decreasing the size of the largest connected component (LCC). This fragmentation is counterbalanced by the constant influx and outflux of random nodes, so an orphaned node or a separated cluster may be reconnected to other nodes, when confined to \(\mathcal {P}\). In order to follow and characterize the level of fragmentation of the network, we measure the time evolution and stable states of the LCC and show the results in Fig. 8.

Fig. 8
figure 8

Left panel: time evolution of the largest connected component for an initial random network with N=104 and 〈k〉=4. The size of the component is given in relation to the size N of the network, with N →1, and curves for different sets of parameters are shown. After a transient state, the giant component stabilizes, while nodes leave and reenter the connected component. Right panel: phase diagram showing the size of the largest connected component as a function of parameters ps and pf. The size of the component is given in relation to the size N of the network. Dark blue regions representing a larger component. Larger confinement spaces result in increased reduction of connectivity degree of the nodes outside \(\left.\mathcal {P}\right)\), resulting in more disconnections. Likewise, with a smaller flux, less detached clusters and nodes are reattached. Initial network is random with size N=104 and 〈k〉=4

Figure 8, left panel, shows that after a time transient those two effects, fragmentation by rewiring and reconnection by flux, balance each other and a stable size of the LCC is reached. The size of the LCC depends, apart obviously from network size and link density, on the two parameters of the dynamics, ps and pf. The phase diagram of ps and pf in the right panel of Fig. 8 shows increasing fragmentation for bigger relative size of confinement ps, which is an expected result since the number of links rewired to subgraph \(\mathcal {P}\) is proportional to psN, resulting in decreased connectivity degree outside of \(\mathcal {P}\). Likewise, when pf decreases, nodes outside \(\mathcal {P}\) are less likely to be confined and reconnected to other clusters. The average degree outside \(\mathcal {P}\) also decreases with lower flux as the connectivity of nodes outside depends only on the link sets io and out, which are created only trough outflux of nodes.

Size scaling with multiple confined spaces

The single confinement dynamics is useful to introduce and illustrate the mechanism that results in increased clustering, community forming, and degree heterogeneity, in relative small sized network. However, we briefly noticed, in previous sections, that, for a fixed confinement size ps and flux pf, different network sizes and densities yield networks with different metrics and a degree distribution which does not scale with size. In other words, the single confinement space does not scale with network size. Nonetheless, in the real world, we expect the number of confined spaces to pace with the size of the population.

It can be shown that introducing multiple confined spaces inside the same network makes the model to scale with size. We start with a small network, N=1000. With ps=0.05 and pf=0.005 we have a confined space of size 50 with 5 nodes changing during flux phase. When the network size doubles (N=2000), instead of increasing the confinement to 100 nodes and the flux to 10 nodes, we add a second confined space of the same size than the first one. We repeat the process as the network grows, keeping the confinement size and flux rate, but increasing the number of confined spaces so the network still has a fixed relative number of confined nodes ps and relative flux pf, but divided among independent confined spaces. Each confined space operates only with the free nodes (apprehending, releasing, and rewiring as previously described); once a node is released, it can be re-apprehended by other confined space or even the same one.

In this multiple confinement scenario, the clustering and the relative size of the giant component have size invariance, as can be seen in Fig. 9-left. Meanwhile, modularity, as well as community size, exhibits a weak dependence with network size (N), both increasing slowly with N (Fig. 9-left). As we mention before, community detection algorithms have limitations, particularly concerning resolution. The “true” community structure that emerge from our proposed model is not known a priori. It is an emerging, dynamic, and indirect consequence of the key parameters of the model. Therefore, partitions sizes and modularity are good indicators of the observed structure but not the exact ones.

Fig. 9
figure 9

Size invariance comes from multiple confined spaces. Left panel: network size dependence of some of the measures for a fixed confinement absolute size (number of confined nodes is Nc=50 and flux node number is Nf=5). The number of confined spaces for each network size N is \(\mathcal {P}=N/1000\). Right panel: different network sizes result in different degree distribution, but with the proposed method of size scaling there is a family of distributions similar but for a multiplicative factor (or a vertical translation on the log scale)

In the left panel of Fig. 9 we present the resulting degree distributions for different sizes showing a nice size invariance, except for a normalization and a weak but expected tail dependence on size.

Finally, we want to point out that while multiple confinements is a whole new venue for further research (for example multilevel confined spaces or intersecting confinements), it was considered here just for scaling matters.

Final considerations

In “Degree Distribution” section (degree distributions), we pointed out that hubs are formed inside the confinement: while the rewiring is random, only the nodes inside the confinement receive new links. In real social networks the mechanism of preferential attachment is not always explicit, and the reason for a node to form connections can be as subtle as one remaining in a limited place while other nodes go through that place.

The main difference from standard growing models with preferential attachment is the dynamic nature of the hubs inside the structure. Older nodes of the network are not necessarily hubs, but rather the older confined nodes. We can scale the network size up (adding nodes, edges, or confined spaces) or down. As long as the dynamics have sufficient time to reach the steady state, the networks preserve their form and the measured metrics. In this sense, our results differ from the temporal growth model proposed by Bagrow and Brockmann (2013) in which new nodes attach to older ones with an initial attractiveness proportional to the clustering coefficient of each node. This model gives rise to several interesting features, including community formation. However, Bagrow and Brockmann model evolves adding new nodes on the system, while our research focuses on the dynamic of topologically confined subsets (of fixed size) of nodes.

The proposed model also produces nodes with degrees of variable timespan, a feature that most social networks exhibit. When a perturbation is applied to the network structure, after a short transient, the network reaches an equivalent stable state.


In the present contribution we have introduced a simple model for dynamic networks, which we call confinement dynamics. The proposed model and the parameters that control it bear similarities with complex phenomena of real networks, particularly social networks, and so do the resulting structures. The size and number of confined spaces can be associated with real world organizations: individuals of a commercial firm, inmates of a prison, or social media groups. As for the flux, it can be associated with the time scale dynamics.

We have shown that the model gives rise to the appearance and stability of complex phenomena observed in empirical networks, such as high clustering, heterogeneous degree distributions (scalable with network size), and formation of communities. Size scalability is verified using multiple confined spaces, and the stability of the general network form is observed while the components are in continuous flux —an important characteristic often manifested in real systems. Remarkably, all those features emerge from just two parameters (ps and pf) and from any input network; indeed the self organization of the resulting networks becomes evident due to the choice of random networks –which lack all the complex structures developed during the dynamics– as starting configurations. The key element for such independence from the initial conditions is the random criteria for confinement, release, and rewiring of individual nodes, with no memory of the initial state —except, naturally for the transient behavior— in addition to network size and number of links.

The incarceration example is of particular interest when analyzing criminal dynamics. Criminal network detection and dismantling models are of great utility in generating public welfare and in reducing personal and patrimonial damages. Most models assume that an inmate is removed from the network while incarcerated (Duijn et al. 2014; Gordon et al. 2009; Gambra and Frey 2011; Schneider et al. 2014). This assumption may overestimate the incarceration system’s ability to remove the agent from criminal dynamics, and, at the same time, overlooks the capacity of the confinement systems to generate new contacts and reorganize criminal networks.

Future research could aim to further develop this model by considering simulations with more realistic initial conditions, such as seed networks, and more complex wiring dynamics, such as the configuration model or non-Markovian wiring.

Characterizing the time evolution of communities, as they born or dye out, merge, or split, is a difficult task that involves dealing with huge sets of time-stamped data, and tracking individual modules of the network (Palla et al. 2007; Hopcroft et al. 2004). Although the model we introduce represents a simplified view of a complex phenomenon, we believe it can help to understand, in a simple way, the underlying modular characteristic of real complex networks and, more importantly, how communities can emerge and evolve.



Brazilian federal police network available in ref (da Cunha and Gonçalves 2018)


Erdös Rényi networks


Largest connected component


Watts-Strogatz networks


  • Albert, R, Barabási A-L (2002) Statistical mechanics of complex networks. Rev Mod Phys 74(1):47.

    Article  MathSciNet  Google Scholar 

  • Bagrow, JP, Brockmann D (2013) Natural emergence of clusters and bursts in network evolution. Phys Rev X 3(2):021016.

    Google Scholar 

  • Barabási, A-L, et al. (2016) Network Science. Cambridge university press, Cambridge, UK.

    MATH  Google Scholar 

  • Bastian, M, Heymann S, Jacomy M, et al. (2009) Gephi: an open source software for exploring and manipulating networks. Icwsm 8(2009):361–362.

    Google Scholar 

  • Blondel, VD, Guillaume J-L, Lambiotte R, Lefebvre E (2008) Fast unfolding of communities in large networks. J Stat Mech: Theory Exp 2008(10):10008.

    Article  Google Scholar 

  • Condon, A, Karp RM (2001) Algorithms for graph partitioning on the planted partition model. Random Struct & Algoritm 18(2):116–140.

    Article  MathSciNet  Google Scholar 

  • da Cunha, BR, Gonçalves S (2018) Topology, robustness, and structural controllability of the brazilian federal police criminal intelligence network. Appl Netw Sci 3(1):36.

    Article  Google Scholar 

  • Delvenne, J-C, Yaliraki SN, Barahona M (2010) Stability of graph communities across time scales. Proc Natl Acad Sci 107(29):12755–12760.

    Article  Google Scholar 

  • Duijn, PA, Kashirin V, Sloot PM (2014) The relative ineffectiveness of criminal network disruption. Sci Rep 4:4238.

    Article  Google Scholar 

  • Erdös, P, Rényi A (1959) On random graphs, i. Publ Math (Debr) 6:290–297.

    MATH  Google Scholar 

  • Freeman, LC (1977) A set of measures of centrality based on betweenness. Sociometry 40(1):35–41.

    Article  Google Scholar 

  • Freeman, LC, Borgatti SP, White DR (1991) Centrality in valued graphs: A measure of betweenness based on network flow. Social Networks 13(2):141–154.

    Article  MathSciNet  Google Scholar 

  • Fortunato, S (2010) Community detection in graphs. Phys Rep 486(3-5):75–174.

    Article  MathSciNet  Google Scholar 

  • Gambra, MB, Frey E (2011) Social dynamics with peer support on heterogeneous networks. Euro Phys J B 83(4):507–518.

    Article  Google Scholar 

  • Gordon, MB, Iglesias JR, Semeshenko V, Nadal J-P (2009) Crime and punishment: the economic burden of impunity. Euro Phys J B 68(1):133–144.

    Article  Google Scholar 

  • Holland, PW, Leinhardt S (1971) Transitivity in structural models of small groups. Comp Group Stud 2(2):107–124.

    Article  Google Scholar 

  • Hopcroft, J, Khan O, Kulis B, Selman B (2004) Tracking evolving communities in large linked networks. Proc Natl Acad Sci 101(suppl 1):5249–5253.

    Article  Google Scholar 

  • Jacomy, M, Venturini T, Heymann S, Bastian M (2014) Forceatlas2, a continuous graph layout algorithm for handy network visualization designed for the gephi software. PloS one 9(6):98679.

    Article  Google Scholar 

  • Lancichinetti, A, Fortunato S, Radicchi F (2008) Benchmark graphs for testing community detection algorithms. Phys Rev E 78(4):046110.

    Article  Google Scholar 

  • Liljeros, F, Edling CR, Amaral LAN, Stanley HE, Åberg Y (2001) The web of human sexual contacts. Nature 411(6840):907.

    Article  Google Scholar 

  • Martin, S, Brown WM, Klavans R, Boyack KW (2011) OpenOrd: an open-source toolbox for large graph layout In: Proc. SPIE 7868, Visualization and Data Analysis 2011, 786806 (24 January 2011).

  • Newman, ME (2006) Modularity and community structure in networks. Proc Natl Acad Sci 103(23):8577–8582.

    Article  Google Scholar 

  • Palla, G, Derényi I, Farkas I, Vicsek T (2005) Uncovering the overlapping community structure of complex networks in nature and society. Nature 435(7043):814.

    Article  Google Scholar 

  • Palla, G, Barabási A-L, Vicsek T (2007) Quantifying social group evolution. Nature 446(7136):664.

    Article  Google Scholar 

  • Pratt, TC, Cullen FT (2005) Assessing macro-level predictors and theories of crime: A meta-analysis. Crime Justice 32:373–450.

    Article  Google Scholar 

  • Kerley, KR (2017) The Encyclopedia of Corrections.

  • Brame, R, Mulvey EP, Schubert CA, Piquero AR (2018) Recidivism in a sample of serious adolescent offenders. J Quant Criminol 34(1):167–187.

    Article  Google Scholar 

  • Schneider, ÉM, Iglesias JR, Hallberg K, Kuperman MN (2014) Crimes against humanity: the role of international courts. PloS one 9(6):99064.

    Article  Google Scholar 

  • Watts, DJ, Strogatz SH (1998) Collective dynamics of ’small-world’networks. Nature 393(6684):440–442.

    Article  Google Scholar 

  • Yang, Z, Algesheimer R, Tessone CJ (2016) A comparative analysis of community detection algorithms on artificial networks. Sci Rep 6:30750.

    Article  Google Scholar 

Download references


See Funding.


EMS acknowledges financial support from Conselho Nacional de Desenvolvimento Científico e Tecnológico (CNPq) and CAPES #1. BRC acknowledges the Science Foundation Ireland (Grant No. 16/IA/4470) for partial financial support.

Availability of data and material

The datasets generated during the current study are available from the corresponding author on request.

Author information

Authors and Affiliations



EMS design, simulation, data, discussion and writing; SG design, discussion and writing; JRI and BRC discussion and writing. All authors revised and approved the manuscript.

Corresponding author

Correspondence to Sebastián Gonçalves.

Ethics declarations

Ethics approval and consent to participate

Not applicable.

Consent for publication

The authors consent for publication.

Competing interests

The authors declare that they have no competing interests.

Publisher’s Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (, which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Schneider, É., Gonçalves, S., Iglesias, J. et al. Dynamic Modular Networks Model Mediated by Confinement. Appl Netw Sci 4, 30 (2019).

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI: