private static void runAlgorithm(IGraph G) {
   // Solve it using greedy
   IVertexCoverSolver solver = SolverFactory.getSolver(algorithm);
   Cover cover = solver.solve(G.cloneGraph());
   System.out.println("#####################");
   System.out.println(algorithm.name() + " Algorithm:");
   System.out.println(
       (G.isCover(cover) ? "Valid" : "Invalid")
           + " cover found using "
           + cover.getSize()
           + " vertices"
           + ", weight is "
           + cover.getWeight());
 }
  private static void runOptimal(IGraph G) {
    // Solve it optimally using Integer Programming
    IVertexCoverSolver optimalSolver;
    Cover optimalSolverCover;
    try {
      optimalSolver = new OptimalSolver3();
      optimalSolverCover = optimalSolver.solve(G.cloneGraph());
    } catch (UnsatisfiedLinkError e) {
      optimalSolver = new OptimalSolver();
      optimalSolverCover = optimalSolver.solve(G.cloneGraph());
    }

    System.out.println("#####################");
    System.out.println("Optimal solution (Integer Programming):");
    System.out.println(
        (G.isCover(optimalSolverCover) ? "Valid" : "Invalid")
            + " cover found using "
            + optimalSolverCover.getSize()
            + " vertices");
  }