Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def AC3(csp, queue=None, removals=None):
if not csp.curr_domains[Xi]:
return False
for Xk in csp.neighbors[Xi]:
if Xk != Xi:
if Xk != Xj:
queue.append((Xk, Xi))
return True

Expand Down
7 changes: 7 additions & 0 deletions tests/test_csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ def test_AC3():
assert AC3(csp, removals=removals) is True
assert (removals == [('A', 1), ('A', 3), ('B', 1), ('B', 3)] or
removals == [('B', 1), ('B', 3), ('A', 1), ('A', 3)])

domains = {'A': [ 2, 4], 'B': [ 3, 5]}
constraints = lambda X, x, Y, y: int(x) > int (y)
removals=[]
csp = CSP(variables=None, domains=domains, neighbors=neighbors, constraints=constraints)

assert AC3(csp, removals=removals)


def test_first_unassigned_variable():
Expand Down