Example #1
0
 /**
  * Add the point <code>p</code> to the cluster and expand the cluster using the neighbors of
  * MatchPoint <code>p</code>
  *
  * @param p the MatchPoint to expand upon
  * @param clust
  */
 private void expandClusters(MatchPoint p, Set<MatchPoint> clust) {
   clust.add(p);
   p.setAssigned();
   Vector<MatchPoint> neighbors = new Vector<MatchPoint>(p.getNeighbors());
   int i = 0;
   while (i < neighbors.size()) {
     MatchPoint tmp = neighbors.get(i);
     if (!tmp.isVisited()) {
       tmp.setVisited();
       if (tmp.size() >= MIN_PTS) neighbors.addAll(tmp.getNeighbors());
     }
     if (!tmp.isAssigned()) {
       clust.add(tmp);
       tmp.setAssigned();
     }
     i++;
   }
 }
Example #2
0
 /** Run the DBSCAN algorithm */
 private void runDBSCAN() {
   Iterator<MatchPoint> it = currPoints.iterator();
   Set<MatchPoint> currClust = null;
   MatchPoint tmp = null;
   while (it.hasNext()) {
     tmp = it.next();
     if (tmp.isVisited()) continue;
     if (tmp.size() < MIN_PTS) {
       tmp.setNoise();
       tmp.setAssigned();
     } else {
       currClust = new TreeSet<MatchPoint>(xSort);
       expandClusters(tmp, currClust);
       readPairClusters.add(new ReadCluster(currClust));
     }
     tmp.setVisited();
   }
 }
Example #3
0
  /**
   * Print the current state of this SpatialCluster to the given File.
   *
   * <p>Used mainly for debugging.
   *
   * @param file the File to write the current state to.
   * @throws IOException if an I/O occurred when trying to write to <code>file</code>
   */
  void exportCurrState(File file) throws IOException {
    file.createNewFile();
    PrintStream out = new PrintStream(file);
    Iterator<MatchPoint> it = currPoints.iterator();
    while (it.hasNext()) {
      MatchPoint tmp = it.next();
      out.println(tmp.x() + "\t" + Math.abs(tmp.y()) + "\t0");
    }

    Iterator<ReadCluster> kcIt = readPairClusters.iterator();
    while (kcIt.hasNext()) {
      ReadCluster tmpKc = kcIt.next();
      it = tmpKc.getMatchPoints().iterator();
      while (it.hasNext()) {
        MatchPoint tmp = it.next();
        out.println(tmp.x() + "\t" + Math.abs(tmp.y()) + "\t" + tmpKc.id);
      }
    }
    out.close();
  }
Example #4
0
 @Override
 public int compare(MatchPoint arg0, MatchPoint arg1) {
   if (arg0.x() == arg1.x()) return arg0.y() - arg1.y();
   else return arg0.x() - arg1.x();
 }