void calculate(List<Vertex> vertices) {
        List<Vertex> unvisitVertices = new ArrayList<>();
        for ( Vertex vertex : vertices ) {
            unvisitVertices.add(vertex);
        }
        while ( ! unvisitVertices.isEmpty() ) {
            Collections.sort(unvisitVertices, VERTEX_COMPARATOR);
            Vertex target = unvisitVertices.remove(0);
            for (VertexConnection connection : target.getConnections() ) {
                Vertex toVertex = connection.getToVertex();
                boolean isAlreadyVisited = ! unvisitVertices.contains(toVertex);
                if ( isAlreadyVisited ) {
                    continue;
                }

                boolean smallerWeightFound = connection.getWeight() < toVertex.getDistance();
                if ( smallerWeightFound ) {
                    toVertex.setDistance(connection.getWeight());
                    toVertex.setPrev(target.getNumber());
                }
            }
        }
    }