public ArrayList<Vertex> maxFlowMinCut() {
        Edge[] path = findPath(source, target);
        this.maxFlow = 0;

        while (path != null && path[0].getTarget().equals(target)) {
            // find the minimum edge weight
            float weight = Float.MAX_VALUE;
            for (int i = 0; i < path.length; i++) {
                float tempWeight = path[i].getWeight();
                if (tempWeight < weight) {
                    weight = tempWeight;
                }
            }

            maxFlow += weight;

            // Subtracting the minimum weight and create the residual edges
            for (int i = 0; i < path.length; i++) {
                Edge edge = path[i];
                edge.setWeight(edge.getWeight() - weight);

                Edge residualEdge = graph.getEdge(edge.getTarget(), edge.getSource());
                if (residualEdge == null) {
                    graph.addEdge(new Edge(edge.getTarget(), edge.getSource(), weight));
                }
                else {
                    residualEdge.setWeight(residualEdge.getWeight() + weight);
                }
            }


            graph.setUnvisitedGraph();
            path = findPath(source, target);
        }

        ArrayList<Vertex> mincut = new ArrayList<Vertex>();
        for (int i = 0; i < path.length; i++) {
            Vertex v = path[i].getTarget();
            mincut.add(v);
//            System.out.println(v);
        }
        Vertex v = path[path.length - 1].getSource();
        mincut.add(v);
//        System.out.println(v);

        return mincut;
    }