This code calculates maximal flow and minimal cost. Problem is, that every graph is calculated correctly, but this one is wrong. Expected output is 359 and my output is 363.

Input data:
1 2 4 8
1 3 6 9
2 4 3 7
2 6 2 5
3 4 1 8
3 5 6 6
4 5 6 5
4 6 3 4
5 9 3 10
6 7 2 8
6 8 1 7
7 10 4 9
8 9 2 4
8 10 4 6
9 11 4 12
10 12 7 6
11 12 6 10

Code:

import java.util.ArrayList;
import java.io.File;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {		
		int maxVertex = 0;
		ArrayList<Edge> edgeList = new ArrayList<>();
		String path = "./data/mini2.hrn";
		
		try (Scanner scan = new Scanner(new File(path))) {
			System.out.println("Loading graph data...");
			while (scan.hasNextInt()) {

				int from = scan.nextInt();
				int to = scan.nextInt();
				int cost = scan.nextInt();
				int capacity = scan.nextInt();

				edgeList.add(new Edge(from, to, cost, capacity));
				maxVertex = Math.max(maxVertex, ((from >= to) ? from : to));
			}
		} catch (Exception e) { throw new RuntimeException("File " + path + " not found"); }

		Graph graph = new Graph(edgeList, maxVertex);
		graph.getMaxFlow(1, maxVertex);
	}
}

public class Edge {

	private int a;
	private int b;
	private int cost;
	private int capacity;
	private int flow;
	
	public Edge(int from, int to, int cost, int capacity) {
	this(from, to, cost, capacity, 0);
	}
	
	public Edge (int from, int to, int cost, int capacity, int flow) { 
	this.a = from;
	this.b = to;
	this.cost = cost;
	this.capacity = capacity;
	this.flow = flow;
	}
	
	public int getA() {
	return this.a;
	}
	
	public int getB() {
	return this.b;
	}
	
	public int getCost() {
	return this.cost;
	}
	
	public int getCapacity() {
	return this.capacity;
	}
	
	public void setCapacity(int capacity) {
	this.capacity = capacity;
	}
	
	public int getFlow() {
	return this.flow;
	}
	
	public void setFlow(int flow) {
	this.flow = flow;
	}
	
	public void addFlow(int flow) {
	this.flow += flow;
	}
	
	public Edge getReverseEdge() {
	return new Edge(this.b, this.a, -this.cost, 0, -this.flow);
	}
}


import java.util.ArrayList;

public class Vertex {
	
	private int id;
	private ArrayList<Edge> inputEdges;
	private ArrayList<Edge> outputEdges;

	public Vertex(int id) {
		this.id = id;
		this.inputEdges = new ArrayList<>();
		this.outputEdges = new ArrayList<>();
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public ArrayList<Edge> getInputEdges() {
		return this.inputEdges;
	}

	public void addInputEdge(Edge e) {
		this.inputEdges.add(e);
	}

	public ArrayList<Edge> getOutputEdges() {
		return this.outputEdges;
	}

	public void addOutputEdge(Edge e) {
		this.outputEdges.add(e);
	}
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;

public class Graph {

    private int totalCost;
    
	private ArrayList<Vertex> vertexList;
	private ArrayList<Edge> edgeList;

	public Graph(ArrayList<Edge> edgeList, int maxVertex) {

		this.edgeList = edgeList;
		this.vertexList = new ArrayList<>(maxVertex);

		for (int i = 0; i < maxVertex + 1; i++) {
			this.vertexList.add(new Vertex(i));
		}

	}

	public void getMaxFlow(int source, int sink) {

        int maxFlow = 0;
        totalCost = 0;
        int[] parent = new int[vertexList.size()];
    
        while (dijkstra(source, sink, parent)) {
    
            int pathFlow = Integer.MAX_VALUE;
            int pathCost = 0;
    
            for (int v = sink; v != source; v = parent[v]) {
                int u = parent[v];
                for (Edge e : this.edgeList) {
                    if (e.getA() == u && e.getB() == v) {
                        pathFlow = Math.min(pathFlow, e.getCapacity() - e.getFlow());
                        pathCost += e.getCost();
                    }
                }
            }
    
            for (int v = sink; v != source; v = parent[v]) {
                int u = parent[v];
                for (Edge e : this.edgeList) {
                    if (e.getA() == u && e.getB() == v) {
                        e.addFlow(pathFlow);
                    } else if (e.getA() == v && e.getB() == u) {
                        e.addFlow(-pathFlow);
                    }
                }
            }
            maxFlow += pathFlow;
            totalCost += pathFlow * pathCost;
        }
    
        System.out.println(String.format("Output [source, sink, max-flow, min-cost]: %d, %d, %d, %d", source, sink, maxFlow, totalCost));
    }

    private boolean dijkstra(int source, int sink, int[] parent) {

        int[] dist = new int[vertexList.size()];
        Arrays.fill(dist, Integer.MAX_VALUE);
        dist[source] = 0;
    
        boolean[] visited = new boolean[vertexList.size()];
    
        PriorityQueue<Integer> pq = new PriorityQueue<>((u, v) -> dist[u] - dist[v]);
        pq.add(source);
    
        while (!pq.isEmpty()) {
            int u = pq.poll();
            visited[u] = true;
    
            for (Edge e : this.edgeList) {
                if ((e.getCapacity() - e.getFlow()) > 0 && e.getA() == u) {
                    int v = e.getB();
                    int alt = dist[u] + e.getCost();
                    if (alt < dist[v]) {
                        dist[v] = alt;
                        parent[v] = u;
                        pq.add(v);
                    }
                }
            }
        }
    
        return visited[sink];
    }
}