user238384
user238384

Reputation: 2466

simple java hierarchical issue

I am having a problem to deal with following data.

1 a 0.64 3
2 d 0.76 3
3 e 0.46 3
1 k 3.43 9
2 i 4.37 9
1 j 0.43 5
2 h 4.74 5
3 j 7.44 5
4 p 3.47 5
1 k 8.33 4

it has 4 column. First is just id for each group. 4th colum is group id while float value is just value and 2nd column too.

Here is what I am trying to do: I want to store this data in java data structure so when I call group id 5 it return me its all sub ids groups too ( 5,4,3 ) or if i call 4 it return (4,3 ) if i call 9 group id it return me all bellow group ids

any idea ???? treemap just support two column :(

Thanks in advance !

EDITED


I am having one more problem with my application :)

I have following type of data

2 3 4
3 6 7
4 2 8

7 8 3

Ok so from above data you can see that 2 and 3 made 4 in 3rd row that 4 combined with 2 to made 8 and then 7 combined with 8 to make 3

Mind gogling :p

How can get tree structure of that data i mean if i call 3 from 3rd column then it return me row 2nd as it made a new cluster with (3.6) if i call 4 it return me 3rd row

its really confused by the way I am trying to implement hierarchical clustering algo ( but on the basis of similairty not distance ) If any body knows any class that can do it please let me know I can not use open source as this application is semi commercial

Upvotes: 0

Views: 544

Answers (2)

BalusC
BalusC

Reputation: 1109112

any idea ???? treemap just support two column :(

Just wrap the data in a custom javabean class, so that you can use a Map<Long, Data>.

The custom class Data can look like this:

public class Data {
    private long id;
    private String col2;
    private double col3; // Or BigDecimal.
    private int col4;
    // Add/generate constructors+getters+setters.
}

The Long map key is here just the id of the Data.

Upvotes: 1

glebm
glebm

Reputation: 21100

You can use a database (make sure to add indices to all the columns)

Upvotes: 0

Related Questions