I have an $N \times N$ adjacency matrix $A_{ij}$ for nodes $i$ and $j$, numbered 1 through $N$. Each node $i$ starts with a scalar value $x_i(0)$ between 0 and 1. At each non-negative integral time $k$, node $i$ receives from some of the other nodes $j$ a message with the value of $x_j(k)$, and updates its value according to
$X_i(k+1)= X_i(k)+ \sum_{j\in N_i} A_{ij}(X_j(k)-X_i(k))$
How can I can write the MATLAB code for this algorithm? I have randomly initialized the adjacency matrix and initial values of each node.
For more information see http://www.eecs.harvard.edu/~rad/courses/cs266-fall07/papers/reza-tac07.pdf