aspose file tools*
The moose likes Java in General and the fly likes Division clustering algorithm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Division clustering algorithm" Watch "Division clustering algorithm" New topic
Author

Division clustering algorithm

Janis Strautins
Greenhorn

Joined: Dec 12, 2012
Posts: 18
Hi!
I am making the [title] algorithm and I have ran into some problems I can't really understand. It's nothing too complicated, one class reads a file and passes it as a linked list to the main algorithm method(table ->divison). From there, one cluster is created from the start table, the distance matrix is calculated. The highest distance is found and the cluster is split into two. And so on, till some kind of ending, iteration count etc. The algorithm works well for one iteration only, afterwards... I can't see where the possible error is, any help would be greatly appreciated. It's my whole days work, probably can't think straight anymore. Thanks in advance!

One row in the table:



One cell in the matrix:



The cluster class:


Algorithms main running class:


The file reader:

Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7795
    
  21

Janis Strautins wrote:I can't see where the possible error is, any help would be greatly appreciated.

Well, I hate to say, but the minute I see anything like:
if(clusterList.get(k).matrix.get(i).distances.get(j).value>max.value) ...
my brain just shuts down.

My suggestion: refactor your code to rationalise all these horrible method chains. You (and we) will be in a much better position to then read your code and understand what it's trying to do.

PS: DontWriteLongLines (←click). I've tried to break yours up as best I can, but you're hamstringing yourself by
(a) Aggressive indentation. (Tip: DON'T use tabs).
(b) The number of layers you're handling at a time.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
Consider Paul's rocket mass heater.
 
subject: Division clustering algorithm