def neighbors(X, Y, x, y):
    """
    returns a list of tuples containing all neighbor
    of the vertex (x, y)

    Arguments:
        X {int} -- number of vertices in X direction
        Y {int} -- number of vertices in Y direction
        x {int} -- x position of vertex 0 <= x <= X
        y {int} -- y position of vertex 0 <= y <= Y

    Returns:
        list -- neighbor of (x, y)
    """
    return [(x2, y2) for x2 in range(x-1, x+2)
            for y2 in range(y-1, y+2)
            if (-1 < x < X and
                -1 < y < Y and
                (x != x2 or y != y2) and
                (0 <= x2 < X) and
                (0 <= y2 < Y))]