Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: dbscan algorithm

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    22
    Thanks
    1
    Thanked 1 Time in 1 Post

    Post dbscan algorithm

    please help me..i cnt run this dbscan algorithm. i have project tommrow ..it is giving 59 errors..please send me dbscan working algo without errors.
    /**
    *
    */
    package algorithms;

    import input.Dataset;
    import input.Element;

    import java.util.Collection;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.SortedMap;

    /**
    * @author Markus
    *
    */
    public class DBSCAN implements ClusteringAlgorithm {

    float epsilon;
    int minPoints;



    public float getEpsilon() {
    return epsilon;
    }
    public void setEpsilon(float epsilon) {
    this.epsilon = epsilon;
    }
    public int getMinPoints() {
    return minPoints;
    }
    public void setMinPoints(int minPoints) {
    this.minPoints = minPoints;
    }
    /* (non-Javadoc)
    * @see algorithms.ClusteringAlgorithm#doClustering(input. Dataset)
    */
    @Override
    public void doClustering(Dataset dataset) {
    int currentClusterId = 0;
    dataset.reset();
    for (int i = 0; i < dataset.size(); i++) {
    Element featureVector = dataset.get(i);
    if(featureVector.getCalculatedClusternumber() == Element.UNCLASSIFIED){
    if(this.expandCluster(i,currentClusterId, this.epsilon, this.minPoints, dataset ));
    currentClusterId ++;
    }

    }

    }
    /**
    * @param featureVector
    * @param currentClusterId
    * @param gamma2
    * @param minPoints2
    */
    private boolean expandCluster(int pointnumber, int currentClusterId, float gamma2, int minPoints2, Dataset dataset) {
    LinkedList<Integer> seeds = (LinkedList<Integer>) this.getNeighbours(dataset, pointnumber);
    if (seeds.size() < this.minPoints){ //no core point
    dataset.get(pointnumber).setCalculatedClusternumbe r(Element.NOISE);
    return false;
    }
    else{
    for (Integer i : seeds) {
    dataset.get(i).setCalculatedClusternumber(currentC lusterId);
    }
    seeds.remove((Integer)pointnumber);
    while (!seeds.isEmpty()){
    int currentPoint = seeds.getFirst();
    Collection<Integer> result = this.getNeighbours(dataset, currentPoint);

    if (result.size() >= this.minPoints){
    for (Integer resultPId : result) {
    Element resultP = dataset.get(resultPId);
    if (resultP.getCalculatedClusternumber() == Element.UNCLASSIFIED){
    seeds.addLast(resultPId);
    resultP.setCalculatedClusternumber(currentClusterI d);
    }
    if (resultP.getCalculatedClusternumber() == Element.NOISE){
    resultP.setCalculatedClusternumber(currentClusterI d);
    }
    }
    }
    seeds.remove((Integer)currentPoint);
    }
    return true;
    }

    }
    /**
    * This method queries the dataset for the neighbours of the passed element (id) that
    * satisfie [dist (id, x) <= epsilon for x element of dataset] .
    * The method returns the ids of the points that fullfill the condition
    * @param dataset
    * @param featureVector
    * @param id
    * @return list of ids that are in the epsilon neighborhood
    */
    private Collection<Integer> getNeighbours(Dataset dataset, int id) {
    SortedMap<Float, List<Integer>> neigbourList = dataset.getNeighbourMatrix()[id];
    List<Integer> result = new LinkedList<Integer>();
    //because the api returns strictly smaller we add a small value.
    Collection <List<Integer>>closepoints = neigbourList.headMap(this.epsilon +0.0000000000000001f).values();
    for (List<Integer> list : closepoints) {
    result.addAll(list);
    }
    return result;

    }

    public String toString(){
    return "DBSCAN";
    }



    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: dbscan algorithm

    it is giving 59 errors..please send me dbscan working algo without errors.
    And...what are the errors? We are neither a code service or a fixit service, so providing all information helps someone else come along and provide guidance.

Similar Threads

  1. Creating an algorithm to do this
    By colerelm in forum Java Theory & Questions
    Replies: 4
    Last Post: October 16th, 2012, 02:54 PM
  2. CRC algorithm
    By aldykid in forum Algorithms & Recursion
    Replies: 1
    Last Post: August 7th, 2011, 10:50 AM
  3. all i need is algorithm
    By coder.freak in forum Paid Java Projects
    Replies: 3
    Last Post: April 6th, 2011, 11:11 AM
  4. [SOLVED] Algorithm Help
    By aussiemcgr in forum Java Theory & Questions
    Replies: 2
    Last Post: September 10th, 2010, 04:12 PM
  5. algorithm
    By AmmrO in forum Algorithms & Recursion
    Replies: 13
    Last Post: September 24th, 2009, 09:18 PM

Tags for this Thread