Skip to content

Instantly share code, notes, and snippets.

@grant
Created July 29, 2014 20:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grant/29afaa91349b1928b05e to your computer and use it in GitHub Desktop.
Save grant/29afaa91349b1928b05e to your computer and use it in GitHub Desktop.
Markov Chain circle
// Circle
var numNodes = 10;
var a = [];
for (var i = 0; i < numNodes; ++i) {
var b = [];
for (var j = 0; j < numNodes; ++j) {
b[j] = (i === (j + numNodes - 1) % numNodes) ? 1 : 0;
}
a[i] = b;
}
console.log(JSON.stringify(a));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment