File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Division clustering algorithm

Janis Strautins

Joined: Dec 12, 2012
Posts: 19
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

Joined: Mar 17, 2011
Posts: 8942

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.


Bats fly at night, 'cause they aren't we. And if we tried, we'd hit a tree -- Ogden Nash (or should've been).
Articles by Winston can be found here
I agree. Here's the link:
subject: Division clustering algorithm
It's not a secret anymore!