Last active
August 29, 2015 14:08
-
-
Save cocodrips/7b9ed7793588f616ccd7 to your computer and use it in GitHub Desktop.
numpyでwalk
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
import numpy as np | |
""" | |
o-o-o-o-o | |
""" | |
m = np.matrix([ | |
[1, 1, 0, 0, 0], | |
[1, 1, 1, 0, 0], | |
[0, 1, 1, 1, 0], | |
[0, 0, 1, 1, 1], | |
[0, 0, 0, 1, 1] | |
]) | |
print m * m | |
print pow(m, 4) | |
""" | |
1-2-3 | |
| |/ | |
4 5-6 | |
""" | |
m = np.matrix([ | |
[1, 1, 0, 1, 0, 0], | |
[1, 1, 1, 0, 1, 0], | |
[0, 1, 1, 0, 1, 0], | |
[1, 0, 0, 1, 0, 0], | |
[0, 1, 1, 0, 1, 1], | |
[0, 0, 0, 0, 1, 1], | |
]) | |
print m * m | |
print pow(m, 4) | |
""" | |
Random graph | |
""" | |
import random | |
N = 600 | |
array = [[random.randint(0, 1) for _ in xrange(N)] for _ in xrange(N)] | |
m = np.matrix(array) | |
print pow(m, 1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result