Contrarian effects and echo chamber formation in opinion dynamics

The relationship between the topology of a network and specific types of dynamics unfolding on it has been extensively studied in network science. One type of dynamics that has attracted increasing attention because of its several implications is opinion formation. A phenomenon of particular importance that is known to take place in opinion formation is the appearance of echo chambers, also known as social bubbles. In the present work, we approach this phenomenon, with emphasis on the influence of contrarian opinions, by considering an adaptation of the Sznajd dynamics of opinion formation performed on several network models (Watts-Strogatz, Erdos-Renyi, Barabasi-Albert, Random geometric graph, and Stochastic Block Model). In order to take into account real-world social dynamics, we implement a reconnection scheme where agents can reconnect their contacts after changing their opinion. We analyse the relationship between topology and opinion dynamics by considering two measurements: opinion diversity and network modularity. Two specific situations have been considered: (i) the agents can reconnect only with others sharing the same opinion; and (ii) same as in the previous case, but with the agents reconnecting only within a limited neighborhood. Several interesting results have been obtained, including the identification of cases characterized not only by high diversity/high modularity, but also by low diversity/high modularity. We also found that the restricted reconnection case reduced the chances of echo chamber formation and also led to smaller echo chambers.


INTRODUCTION
Several real-world systems can be effectively represented and modeled as complex networks [1]. The verification that these systems can exhibit marked topological differences contributed substantially to establishing the new area of network science [2]. One of the reasons this finding has been so important regards the question of how much such diverse topologies can influence the unfolding of specific dynamics (e.g. disease spreading [3], neuronal activation [4], opinion formation [5], and cultural formation [6]) on the networks.
As human beings are progressively and inexorably interconnected, several important phenomena have been identified, including the formation of echo chambers, also known as social bubbles of opinion [7][8][9][10][11]. More specifically, people sharing the same opinions tend to form relatively isolated communities in social networks. Because of its importance, echo chambers have been extensively studied recently [7][8][9][10][11].
One particularly interesting situation deserving further investigation regards networks in which agents are allowed to change their connections after having modified their opinion [11][12][13][14][15][16]. In particular, a modified version of the Sznajd model of opinion dynamics was employed [11], considering several network topologies, in order to study echo chamber formation when agents are allowed to reconnect, after changing their opinion, to other agents sharing the new opinion. Several interesting results were reported, including the fact that the obtained echo chambers tended to have similar sizes and that the same parameter setting can lead to completely different results.
In the present work, we address further this problem with focus on the effect of contrarian opinions [17][18][19][20]. More specifically, when changing their opinion, some people would tend to adopt the position contrary to the predominant opinion. What would be the effects of this type of dynamics on the underlying network? Could this contribute to a larger diversity of opinions and/or echo chamber formation?
In order to investigate this interesting problem further, we resorted to a modified version of the Sznajd model of opinion formation [11], which was run on several types of network topologies: Watts-Strogatz, Erdős-Rényi, Barabási-Albert, Random geometric graph, and Stochastic Block Model. Emphasis was placed on performing this study as a particular case of topology/dynamics interrelationship. So, while the network topology was characterized in terms of its modularity [21], the opinion distribution was quantified with respect to its diversity [22]. Regarding the reconnections induced as a consequence of changes of opinion, the two following situations have been considered: (i) the agents can reconnect only with others sharing the same opinion; and (ii) same as in the previous case, but with the agents reconnecting only within a limited neighborhood.
Several interesting results have been obtained, including the identification of the great influence of the average degree on the formation of the echo chambers, in both considered situations. In addition, the obtained results were found to exhibit complementary characteristics as far as diversity and modularity are concerned. In particular, regions of the parameter space characterized by a gradual variation of diversity were found to have very similar modularities, and vice versa. Another interesting finding relates to the verification that restricted reconnection reduced the chances of echo chamber formation, which also tended to be smaller. We also found that, for a given set of parameters, two types of topologies can be obtained: with or without echo chambers.
This article is organized as follows. We start by presenting a previous related work [11] on which the current approach builds upon, including the description of the modified Sznajd dynamics, the reconnecting schemes, the definition of diversity and modularity, as well as the adopted network models. The results are then presented and discussed, and prospects for future studies are suggested.

II. ADAPTIVE SZNAJD MODEL
The proposed model is based on the Adaptive Sznajd Model (ASM) [11], which is a version of the more traditional Sznajd Model [5]. This new version can give rise to echo chambers, as described as follows.
Before starting the dynamics, each network node, i, is assigned to an opinion, The case O i = 0 corresponds to nodes with null opinion. The rules applied at each interaction are presented in Figure 1.
An additional probability w (0 ≤ w ≤ 1) can also be employed, representing the dynamic's temperature. In the case of opinion dynamics, this parameter corresponds to the probability of a node randomly changing its opinion. In order to simplify our analysis, we henceforth adopt w = 0.

III. CONTRARIAN-DRIVEN SZNAJD MODEL
This dynamics simulates the case in which people influenced by their neighbors tend to adopt the contrary opinion. Here, we considered the ASM and added a rule that incorporates the contrarian idea, which consists of allowing an agent to have an opinion that is different from the majoritarian (the less frequent opinion). Differently from the previous study [11], here we considered the starting number of opinions as four. The new rules are presented in Figure 2.

IV. CONTEXT-BASED RECONNECTION
Taking into account that the probability of a person i to become a friend of some other person j is influenced by the neighbors of j, we incorporated a new rule in the above described algorithm. More specifically, we included a parameter h, which controls the maximum topological distance between i and j allowing a change of opinion by i. So, we limit the reconnections to happen only between nodes that are within a distance lower or equal to h. If there is no possibility of reconnection, the rewiring does not happen. For the sake of simplicity, here we adopt h = 2, which means that the reconnections happen only between the selected node i and the friends of friends of i.

V. DIVERSITY
In order to quantify how diverse the opinions are, we employ a respective measurement. There are many possible ways to define diversity [22]. Here we consider the measurement based of information theory [23], defined as follows where H is the Shannon entropy, which is defined as where N o is the number of possible opinions and ρ o is the proportion of the opinion o on network. The value of diversity, limited within the range 1 ≤ D ≤ N o + 1, can be understood as the effective number of states, also known as Hill number of order q = 1 [24,25].

VI. MODULARITY
Because diversity only accounts for the variety of opinions, we also consider a measurement of topological modularity [21] that quantifies the tendency of nodes to form communities. These communities are defined as groups of nodes highly interconnected while being weakly linked to the remaining network [21].
More specifically, the adopted modularity measurement is calculated as where m is the number of edges, A is the adjacency matrix, and c i , c j are the communities of the nodes i and j, respectively. The value of modularity gauges the structures of clusters of a network. In this study, we considered the opinions being the communities of the nodes.

VII. NETWORK TOPOLOGIES
In order to account for different network topologies, we perform the dynamics considering five different models as follows: A node, i, is randomly chosen, then: • if Oi = 0 the iteration ends; • if Oi = 0, a random i neighbor, j, is selected. By considering the opinion Oj, the next action is determined as: if Oj = 0, the node j changes its opinion to agree with the node i (Oj = Oi); if Oj = Oi, the iteration ends; if Oj = Oi, each of the i neighbors can change their opinions to Oi, with probability 1/ki, where ki is the degree of node i. The same procedure is applied to the neighbors of j, but with probability 1/kj; -When the opinion Oi, of given node i, changes, one of the following three rules are applied with probability q. * If the new opinion Oi is unique on the network, nothing happens; * If all of the i neighbors agree with your new opinion, nothing happens; * If the above two rules are not applied, i loses a connection with an aleatory neighbor that has a different opinion, and connects to some other random node having the same opinion as i. A node, i, is randomly chosen, then: • if Oi = 0 the iteration ends; • if Oi = 0, a random i neighbor, j, is selected. By considering the opinion Oj, the next action is determined as: if Oj = 0, the node j changes its opinion to agree with the node i (Oj = Oi); if Oj = Oi, the iteration ends; -if Oj = Oi: * Each of the i neighbors can change their opinions to Oi, with probability 1/ki. For each i neighbor that does not replace its opinion, the neighbor can change to the contrarian with probability g; * Each of the j neighbors can change their opinions to Oi, with probability 1/kj.
-When the opinion Oi, of given node i, changes, one of the following three rules are applied with probability q. * If the new opinion Oi is unique on the network, nothing happens; * If all of the i neighbors agree with your new opinion, nothing happens; * If the above two rules are not applied, i loses a connection with an aleatory neighbor that has a different opinion, and connects to some other random node having the same opinion as i. • Watts-Strogatz (WS) [26]: departing from a 2D toroidal lattice; • Erdős-Rényi (ER) [27]: having uniformly random connections with probability p; • Barabási-Albert (BA) [28]: yielding scale free degree distributions; • Random geometric graph (GEO) [29]: the positions of the nodes were initially set as a 2D lattice; • Stochastic Block Model (SBM) [30]: we configured the model concerning four well-defined communities with the same size.
In all the above cases, the parameters were chosen so as to yield the same expected average degree k .
For all these adopted networks, we considered the number of nodes as being approximately 1000. Furthermore, we employed three different average degrees ( k = 4, 8,12). However, in the case of the GEO model, we considered only k = 8, 12 since it is difficult to achieve a single connected component with a lower average degree. More information regarding several of the adopted network models can be found in [2].
Here, we present the results according to two respective subsections considering the no-reconnection constraint and context-based reconnections. In both cases, we analyze the opinions diversity and opinions modularity.

A. No reconnection constraint
First, we analyzed the diversity (D) behavior in terms of the reconnection probability (q) and contrarian probability (g) for all considered topologies and three average degrees ( k = 4, 8,12). For most of the dynamics, we executed 1,000,000 of iterations, except for GEO which was performed 100 million (for average degree 8) and 25 million (for average degree 12). For all of the considered topologies, we calculated D by varying q and g. An example regarding the WS network is shown in Figures 3(a) (b) and (c), in which well-defined regions can be observed. For almost all network models, the results were found to be similar. The lower diversity values were observed for lower values of q and g. Interestingly, even when we consider q = 0 (no reconnections), some values of g lead the dynamics to converge to high values of opinion diversity, D. In other words, we verified that the employed parameter configuration strongly affects the diversity (D).
In order to better understand the variation of the diversity with the parameters, we flattened the obtained values of D and calculated the respective PCA (Principal Component Analysis) projection [31,32] (see Figure 4). An interesting result concerns the separation of the cases into three regions in terms of the average degree, identified by respective ellipses in Figure 4. For the two highest values of average degree, the samples were found to be more tightly clustered. Furthermore, for k = 4, the group is more widely scattered. This result suggests that the average degree plays a particularly important role in defining the characteristics of the opinion dynamics in the considered cases.
Next, we analyzed how the opinions modularity (Q) changes according to the model parameters. We compute Q for all network variations, and for k = 4, 8, 12 using the same set of parameters we employed in the previous case. Figures 3(d) (e) and (f) illustrate examples of Q for WS networks, in which well-defined regions can also be found. For the highest of the considered values of g and q, high values of Q were obtained, except for k = 12. This result can be understood as an indication of the existence of echo-chambers. The other parameter configurations led to networks without well-defined communities. Similar results were also observed for the other models.
It is known that the average degree of the network also influences Q [33], with a higher average degree tending to imply lower values of Q. So, for higher average degrees, Q tends to be lower for all possibilities of parameters (g and q). Another critical aspect involved in interpreting the Q measurement is setting the limit of detection [34]. For example, in the cases in which D > 4, there are disconnected nodes that have a null opinion. Now, we proceed to discussing the results obtained for diversity and modularity in an integrated way. The modularity analysis reveals a pattern not evidenced by the diversity analysis (see Figure 3). More specifically, for the highest values of diversity D, the modularity Q was found to be more sensitive for grasping the variations. In a complementary fashion, for the lowest values of modularity, the diversity was also found to be particularly responsive (as can be seen in Figure 3). In general, both measurements are equally important to describe the presented dynamics behavior. Furthermore, the formation of echo chamber can happen only for high values of D and Q. In other words, D describes the effective number of opinions and Q is a quantification of the communities organization. Figure 5 illustrates the resulting topologies when starting with BA networks. More specifically, we present a heatmap of Q values and some respective examples of the resulting networks. In the well-defined region with Q next to zero, the dynamics converge to a single opinion (see Figure 5(a)). Figures 5(b) and (c) were obtained in regions with intermediate values of Q. In this case, the communities are not well-defined. Even so, in both cases there is a high level of diversity, indicated by the visualization colors. Networks with distinct communities were characteristic of the regions in Figures 5(d) and (e). The network shown in Figure 5(e) has communities that are disconnected among themselves. For some configurations, both behaviors, with and without community structure, can be found for the same parameter configurations (see Figures 5(f) and (g)). This situation was also identified for another opinion dynamics (ASM), reported in [11].

B. Context-based reconnection
In this subsection, we explore the effects of the proposed dynamics when the interactions are restricted. This constraint simulates the fact that people tend to become a friend of a friend (h = 2). In this case, we considered only the SBM and GEO networks because these networks have higher diameters than the other considered models. So, the effect of the context-based reconnection is more visible.
By considering the diversity, the results were found to be similar to the no-reconnection constraint dynamics (see Figure 6(a) (b) and (c)). However, the regions with lower values of D are found only for smaller regions defined by specific combinations of parameters. Also, comparing with the previous model, the modularity values were found to be different. In this case, the region in which Q tends to zero is considerably ampler.  As in the previous result, isolated nodes can also be found. In summary, by considering this restriction (h = 2), we found that it is much easier to have parameters that give rise to high diversity. However, there is a lower range of possibilities to obtain high modularity.

IX. CONCLUSIONS
The relationship between topology and dynamics in complex networks constitutes one of the main topics of current interest in network science [2]. One related topic of particular interest consists in the study of opinion formation, and in particular echo chamber formation, in social networks [7][8][9][10][11].
In the present work, we approached the problem of echo chamber formation in several types of complex networks, as modeled by a modified Sznajd model. In particular, we focused attention on the effects of contrarian opinions. Two situations were studied: (i) the agents can reconnect only with others sharing the same opinion; and (ii) same as in the previous case, but with the agents reconnecting only within a limited neighborhood.
Several interesting results have been obtained and discussed. Regarding the analysis based on diversity and modularity, the obtained results were found to exhibit complementary characteristics. More specifically, we found that some regions of the parameter space are characterized by a gradual variation of diversity while displaying very similar modularities, and vice versa. For specific parameter configurations, two types of topologies can be observed: with or without echo chambers. Furthermore, one of the factors that strongly influences the dynamics was found to be the average degree, which is related to the formation of the echo chambers. This result means that the number of friends plays an essential role in the dynamics. In the case of the context-based reconnections, it reduced the chances of echo chamber formation, which also tended to be smaller.
The findings reported in this article motivate several further investigations. In particular, it would be interesting to study the effect of the Sznajd model temperature parameter (spontaneous opinion changes). Another possibility is to consider weighted and/or directed complex networks.   The employed dynamics is based on the context-based reconnection (h = 2). Each of the computed points was calculated for 100 network samples. These network visualization were created using the software implemented in [35].