import numpy as np
import matplotlib.pyplot as plt
%matplotlib notebook

N = 10
OBSTALE = '1'
START = 'S'
END = 'E'
game_map = np.array([[ROAD] * 10] * 10)
game_map[1:5, 1] = OBSTALE
game_map[8:10, 1] = OBSTALE
game_map[2:6, 3] = OBSTALE
game_map[7:10, 3] = OBSTALE
game_map[1:5, 5] = OBSTALE
game_map[6:8, 5] = OBSTALE
game_map[0:3, 7] = OBSTALE
game_map[4:6, 7] = OBSTALE
game_map[0, 0] = START
game_map[8, 7] = END

for row in game_map:
for col in row:
print(col, end='')
print('')

S******1**
*1***1*1**
*1*1*1*1**
*1*1*1****
*1*1*1*1**
***1***1**
*****1****
***1*1****
*1*1***E**
*1*1******

class Node:
def __init__(self, x, y):
self.x = x
self.y = y

def __eq__(self, other):
return self.x == other.x and self.y == other.y

def __hash__(self):
return N * self.x + self.y

def __repr__(self):
return '({0}, {1})'.format(self.x, self.y)

class Edge:
def __init__(self, node1, node2, weight):
self.node1 = node1
self.node2 = node2
self.weight = weight

def either(self):
return self.node1

def other(self, node):
if node == self.node1:
return self.node2
else:
return self.node1

class Graph:
def __init__(self, game_map):
self.num_nodes = N * N
for i in range(0, len(game_map)):
for j in range(0, len(game_map[i])):
node = Node(i, j)
for i in range(0, len(game_map)):
for j in range(0, len(game_map[i])):
if game_map[i][j] != OBSTALE:
k = i - 1
while k >= 0 and game_map[k][j] != OBSTALE:
edge = Edge(Node(i, j), Node(k, j), i - k)
k -= 1
k = j + 1
while k < N and game_map[i][k] != OBSTALE:
edge = Edge(Node(i, j), Node(i, k), k - j)
k += 1
k = i + 1
while k < N and game_map[k][j] != OBSTALE:
edge = Edge(Node(i, j), Node(k, j), k - i)
k += 1
k = j - 1
while k >= 0 and game_map[i][k] != OBSTALE:
edge = Edge(Node(i, j), Node(i, k), j - k)
k -= 1

node1 = edge.either()
node2 = edge.other(node1)

(0, 0) [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0)]

def floy(graph, start, end):