function [CIJio,ord] = randomizeCIJiop(CIJ,H) % inputs: % CIJ connection matrix % H total number of swaps of % two connections % outputs: % CIJio randomized CIJ matrix, with preserved in- and % out-degree % ord permutation order chosen at the beginning % of the randomization % % This function randomizes a CIJ matrix by swapping connections while % maintaining a constant in-degree and out-degree distribution. No % connections are made on the main diagonal. Main diagonal swaps are % excluded by making unique choices for all 4 positions. The total number % of swaps is given by H. Vertices are randomly permuted at the start to % generate random initial conditions - at the end, vertices are placed back % into their original positions. Follows the approach by Maslov and Sneppen % (2002) and Milo et al. (2002). % % Use only for binary directed matrices % % Olaf Sporns, Indiana University, 2005/2007 % ========================================================================= N = length(CIJ); h = 0; pow2 = [8 4 2 1]; h = 0; % begin by permuting the order of the vertices CIJorig = CIJ; ord = randperm(N); CIJ = CIJorig(ord,ord); while h