Beispiel #1
0
 /** Push-relabel algorithm for maximum flow */
 private void push(double[][] flow, double[] excess, int u, int v) {
   double send = Math.min(excess[u], graph[u][v] - flow[u][v]);
   flow[u][v] += send;
   flow[v][u] -= send;
   excess[u] -= send;
   excess[v] += send;
 }
Beispiel #2
0
 private void relabel(double[][] flow, int[] height, int u) {
   int minHeight = 2 * n;
   for (int v = 0; v < n; v++) {
     if (graph[u][v] - flow[u][v] > 0) {
       minHeight = Math.min(minHeight, height[v]);
       height[u] = minHeight + 1;
     }
   }
 }
Beispiel #3
0
  private void _cluster(double[][] data, int k) {
    long clock = System.currentTimeMillis();
    SpectralClustering cluster = new SpectralClustering(data, k, 0.355);
    System.out.format(
        "DBSCAN clusterings %d samples in %dms\n", data.length, System.currentTimeMillis() - clock);
    System.out.println("getNumClusters:" + cluster.getNumClusters());
    System.out.println("getClusterSize:" + cluster.getClusterSize());
    //        System.out.println(JSON.toJSONString(dbscan.getClusterSize()));
    System.out.println("toString:" + cluster.toString());
    /** ************************************************************ */
    boolean more = true;
    EigenValueDecomposition eigen = cluster.getEigen();
    double[] lab = eigen.getEigenValues();
    double sd = smile.math.Math.sd(eigen.getEigenValues());

    System.out.println("sd(eigen.getEigenValues()):" + sd);
    if (Math.min(eigen.getEigenValues()) > 0.3) {
      result = cluster;
      cluster(data, k + 1);
    } else {
      return;
    }
  }