Last active
August 9, 2019 13:15
-
-
Save bkj/6a7b9db8408d27da255bec6438de655b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: `@` refers to matrix-matrix or matrix-vector multiplication. `*` refers to elementwise multiplication. | |
degrees = // vector s.t. degree[i] is the degree of the i'th node in graph G | |
D = // diagonal matrix s.t. D[i, i] = degrees[i] | |
D_inv = // diagonal matrix s.t. D_inv[i, i] = 1 / sqrt(degrees[i]) | |
q = // zero matrix of shape (max_iters, num_nodes) | |
grad = -alpha * D_inv @ s | |
while k < max_iters do | |
for i in num_nodes do | |
rad = rho * alpha * sqrt(degrees[i]) | |
| q[k,i] - (grad[i] + rad) if q[k,i] - grad[i] >= rad | |
q[k + 1, i] = | 0 if -rad < q[k,i] - grad[i] < rad | |
| q[k,i] - (grad[i] - rad) if q[k,i] - grad[i] <= -rad | |
end for | |
grad = D_inv @ (D - (1 - alpha) / 2 * (D + A)) @ D_inv @ q[k + 1] - alpha * D_inv @ s | |
k = k + 1 | |
end while | |
return sqrt(D) @ q[k] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(1 / alpha) should be (1 - alpha) took me a while to figure it out. but i did