def set_end(self, v: Vertex): """ Sets a given vertex as destination in graph. Parameters ---------- v: Vertex Destination point. """ v.set_end() self.end = v
def set_start(self, v: Vertex): """ Sets a given vertex as the starting point in graph. Parameters ---------- v: Vertex Starting point. """ v.set_start() self.start = v
def test_init(): v: Vertex = Vertex(10, 5, 10) assert v.x == 5 * 10 assert v.y == 10 * 10 assert v.colour == Colour.WHITE assert v.state == State.EMPTY
def test_setter(): v: Vertex = Vertex(12, 5, 8) v.set_start() v.set_barrier() v.set_closed() v.set_open() assert v.state == State.OPEN assert v.colour == Colour.LIGHT_BLUE
def init_grid(self) -> list: """ Initialize the graph by creating a 2d list where the first dimension represents a row and the second dimension represents a columns. Returns ------- list 2d list representing a graph. """ xs: list = [] ys: list = [] for row in range(self.rows): for col in range(self.columns): node = Vertex(row, col, self.vertex_width) ys.append(node) xs.append(ys) ys = [] return xs
def test_get_position(): v: Vertex = Vertex(10, 5, 10) v_pos: tuple = v.get_position() assert v_pos == (10, 5) assert type(v_pos) == tuple