views:

64

answers:

2

Hi All, 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

A: 

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

glebm
Sounds like this might be a homework problem :)
Chris Dennett
+1  A: 

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.

BalusC
thanks i already saw this kind of solution before. I am not OOP expert :) coz mostly I work in php :) can you please explain how to access data with the help of col4?
thats not really an OOP concept, thats a data structure concept.
Woot4Moo
Woot4Moo i am talking about the solution that BalusC provided here.
Are those parent-child relationships? I've read your question over 3 times, but I can't get straight what you're actually telling/asking. Your English is pretty confusing, I've had to repeat reading a sentence too often again. Adding linguistic characters like dots, commas, etc. may clarify a lot. Try a spell/grammar checker.
BalusC
sorry for confused english as I was confused. Anyways can you see edited part? Any hint for that?
Sorry, I'm lost. Maybe others are able to understand it and give correct answers. Good luck further.
BalusC