class ElementwiseMax extends SingleParentVariable<Matrix> {

    @Override
    public Matrix apply(ComputationContext ctx) {
        Matrix max = Matrix.fill(Double.NEGATIVE_INFINITY, rows, cols);

        double[] parentData = ctx.data(parent()).data();
        for (int row = 0; row < rows; row++) {
            int[] neighbors = this.adjacencyMatrix[row];
            for(int col = 0; col < cols; col++) {
                int resultElementIndex = row * cols + col;
                if (neighbors.length > 0) {
                    for (int neighbor : neighbors) {
                        int neighborElementIndex = neighbor * cols + col;
                        max.setDataAt(
                            resultElementIndex,
                            Math.max(parentData[neighborElementIndex], max.dataAt(resultElementIndex))
                        );
                    }
                } else {
                    max.setDataAt(resultElementIndex, 0);
                }
            }
        }

        return max;
    }

    public  ElementwiseMax(Variable<?> parent, int[][] adjacencyMatrix);

}