コード例 #1
0
  private void setupLRNeighbors() {
    List<Team> teams = pp.getTeams();
    for (Team t : teams) {
      // System.out.println(t);
      Vertex u = Vertex.vertexFromEmployee(t.getEmployee(0));
      Vertex v = Vertex.vertexFromEmployee(t.getEmployee(1));

      u.addToNeighbors(v);
      v.addToNeighbors(u);

      setCapacity(u, v, 1);
      setFlow(u, v, 0);
    }
  }
コード例 #2
0
  private void initialize() {
    Set<Employee> Lset = pp.getEmployees(0);
    Set<Employee> Rset = pp.getEmployees(1);

    // FIXME!!!
    // flow = new HashMap<Vertex, Map<Vertex, Integer>>(2 * (Lset.size() + Rset.size()));
    // capacity = new HashMap<Vertex, Map<Vertex, Integer>>(2 * (Lset.size() + Rset.size()));
    flow = new TreeMap<Vertex, Map<Vertex, Integer>>();
    capacity = new TreeMap<Vertex, Map<Vertex, Integer>>();

    setupSourceSide(Lset);
    setupSinkSide(Rset);

    setupLRNeighbors();
    biasForFriend();

    source.setHeight(V.size() + 2);
  }
コード例 #3
0
  public static void main(String[] args) {
    try {
      // Parse input and set up
      ProjectParams pp = ProjectParams.fromStdIn();
      // System.out.println(pp.getTeams());
      // System.out.println(pp);

      Solver solver = new Solver(pp);
      // System.out.println(solver + "\n");

      // Solve and print
      solver.solve();
      solver.printSolution();
    } catch (IOException e) {
      System.err.println("Error reading data from stdin\n");
      e.printStackTrace();
    }
  }