Skip to content

Commit

Permalink
#4 Inverted graph bug fixed
Browse files Browse the repository at this point in the history
By default Networkx starting node position (0,0) is in the bottom left. This is now inverted - starting node position is in the top left. This is done to match the order in the sudoku board (matrix visualisation).
  • Loading branch information
kcuric committed Jan 21, 2020
1 parent 9dcb7ca commit 1c04ac4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sudoku/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def _generate():
global size

# Reset
for child in tab1.winfo_children():
child.destroy()

for child in tab2.winfo_children():
child.destroy()

Expand Down
3 changes: 2 additions & 1 deletion sudoku/modules/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _add_nodes(self, board: list):
for row in range(len(board)):
for col in range(len(board)):
label += 1
self.labels[(row, col)] = label
self.labels[(col, row)] = label
self.display_labels[label] = board[row][col]
self.board.add_node(label)

Expand Down Expand Up @@ -115,6 +115,7 @@ def show_graph(self):
def get_figure(self):
plt.clf()
pos = dict((v,k) for k,v in self.labels.items())
plt.gca().invert_yaxis()
nx.draw_networkx(
self.board,
pos=pos,
Expand Down

0 comments on commit 1c04ac4

Please sign in to comment.