简单的java层次结构问题

发布于 2024-08-23 18:02:13 字数 769 浏览 4 评论 0原文

我在处理以下数据时遇到问题。

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

它有 4 列。首先是每个组的 id。第四列是组 ID,同时为浮点数 值只是值和第二列。

这是我正在尝试做的事情: 我想将此数据存储在 java 数据结构中,因此当我调用组 id 5 时,它会返回我 它的所有子 id 组也是 ( 5,4,3 ) 或者如果我调用 4 它返回 (4,3 ) 如果我调用 9 组 id 它返回给我所有下面的组 ID

有什么想法吗???树形图只支持两列:(

提前致谢!

编辑


我的应用程序还有一个问题:)

我有以下类型的数据

2 3 4
3 6 7
4 2 8

7 8 3

好的,从上面的数据你可以看到 2 和 3 组成 4 在第 3 行,4 与 2 相加得到 8 然后 7 与 8 结合起来得到 3

令人费解:p

如何获得该数据的树结构 我的意思是,如果我从第三列调用 3,那么它会返回我第二行,因为它创建了一个新簇 与 (3.6) 如果我调用 4,它会返回第三行,

这真的很困惑 顺便说一句,我正在尝试实现层次聚类算法(但基于 相似度而不是距离)如果有人知道可以做到这一点的任何课程,请告诉我 我不能使用开源,因为这个应用程序是半商业的

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

予囚 2024-08-30 18:02:13

有什么想法吗???树形图仅支持两列:(

只需将数据包装在自定义javabean类中,这样就可以使用Map

自定义类Data可以看一下像这样:

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

Long 地图键在这里只是 Dataid

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.

我一向站在原地 2024-08-30 18:02:13

您可以使用数据库(确保为所有列添加索引)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文