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=0∀i,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^ij←C^ij+1
    •     else
    •       C^ij←C^ij−1
    •     end if
    •   end for
    •   rep←rep+1
    • untilrep=Nreps
    • returnC^ij/Nreps as Cij correlation matrix