def merge_node_set_into_node(self, original: Node, attached: Set[Node]): # border attribute should be true if any are borders original.is_border = any([i.is_border for i in attached]) # all nodes in attached should be removed from grid for i in attached: if i.position != original.position: i.deleted = True # position should cover all attached original.position = set.union(*[i.position for i in attached]) # final outflow is the outflow for all nodes except outflows to itself all_possible_outflows = [] for i in attached: for j in i.outflow: if not overlaps(j.position, original.position): if not any([overlaps(j.position, k.position) for k in all_possible_outflows]): all_possible_outflows.append(j) original.outflow = all_possible_outflows
def set_border(self, i: int, j: int, node: Node): node.is_border = i == 0 or j == 0 or i == len( self.node_grid) - 1 or j == len(self.node_grid[0]) - 1