private int getDistance(Vertex node, Vertex target) { for (Edges edge : edges) { if (edge.getStart().equals(node) && edge.getDestination().equals(target)) { return edge.getWeight(); } } throw new RuntimeException("Error"); }