Skip to main content
. 2022 Nov 10;24(11):1627. doi: 10.3390/e24111627
Algorithm A1 Calculate correlations
  • Require: multiple initial set of opinions {Si}initial and the adjacency matrix of the embedding network Aij. Number of repetitions Nreps

  • Ensure: a correlation matrix Cij that contains the number of times a pair of nodes has the same final opinion in the steady state when running a Metropolis algorithm Nreps times

  •  set C^ij=0i,i

  •  set rep=0

  • repeat
    •   set initial opinion {Si}initial uniformly at random
    •   call a Metropolis algorithm
    •   define correlation value for each pair of nodes
    •   for all Si,Sj{Si}final with i, j 1,...,N do
    •     if Si=Sj then
    •       C^ijC^ij+1
    •     else
    •       C^ijC^ij1
    •     end if
    •   end for
    •   reprep+1
    • untilrep=Nreps
    • returnC^ij/Nreps as Cij correlation matrix