Created
February 14, 2017 10:12
-
-
Save diunko/eed7e0b4b92639501d2eb34ffedabe21 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
G = {} | |
G[(1,2,3)] = [(1,2,2), (1,2,3), (0,2,3), | |
(2,2,2), (1,3,2), (2,1,3)] | |
def next_states(S): | |
r = [] | |
if 0<S[2]: | |
r.append((S[0],S[1]+1,S[2]-1)) | |
r.append((S[0]+1,S[1],S[2]-1)) | |
r.append((S[0],S[1],S[2]-1)) | |
if 0<S[1]: | |
r.append((S[0]+1,S[1]-1,S[2])) | |
r.append((S[0],S[1]-1,S[2])) | |
if 0<S[0]: | |
r.append((S[0]+1,S[1],S[2])) | |
return r | |
def build_graph(): | |
G = {} | |
states = [(0,N,M)] | |
while True: | |
s = states[i] | |
ss = next_states(s) | |
for s1 in ss: | |
if s1 in G: | |
pass | |
else: | |
G[s].append(s1) | |
return G |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment