def get_gram_matrix(datapoint, neighborhood_matrix):
    """
    Takes a datapoint (as a line vector) and its associated neighborhood matrix
    as given by 'get_neighbors' and returns the corresponding Gram matrix.
    """
    diff_to_neighbors = datapoint - neighborhood_matrix
    gram_matrix = diff_to_neighbors.T * diff_to_neighbors
    return gram_matrix