private static void fitToSize(Graph g, int xSize, int ySize, int padding) {
        double xMax = findGreatestX(g);
        double yMax = findGreatestY(g);
        double xCoefficient = (xSize - padding) / xMax;
        double yCoefficient = (ySize - padding) / yMax;
        for (int i = 0; i < g.getVertices().getSize(); i++) {
            Vertex v = g.getVertices().get(i);
            v.setLocation((int) (v.getX() * xCoefficient + padding / 2.0),
                    (int) (v.getY() * yCoefficient + padding / 2.0));
        }
    }