JUNG - 如何获得图形的巨大连通分量? [英] JUNG - How to get the giant connected component of a graph?

查看:201
本文介绍了JUNG - 如何获得图形的巨大连通分量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在做的是:

  WeakComponentClusterer< Integer,String> wcc = new WeakComponentClusterer< Integer,String>(); 
集合<图<整数,字符串>> ccs = FilterUtils.createAllInducedSubgraphs(wcc.transform(graph),graph);

问题是在ccs中存储了所有连接的组件,但我只想要一个巨大的(GCC )。由于集合css中的集群顺序不是由它们的大小决定的,我必须遍历整个集合才能找到巨集群。坏事是我使用的图很庞大,并且有很多集群;所以,这种迭代花费了很多。



由于我是JUNG的新手,我只是想知道是否有一种快速检索图形的GCC的方法。任何帮助都是有效的。

解决方案

可能是解决问题的最简单方法是破解 WeakComponentClusterer ,以便在构建它们时跟踪组件大小(或者哪个是最大的,因为这是您感兴趣的),然后将该信息暴露给用户。 p>

这是我们在某些时候可能做出的修改,但您可以很容易地在本地代码副本中找到。


Currently, what I'm doing is:

WeakComponentClusterer<Integer, String> wcc = new WeakComponentClusterer<Integer, String>();
Collection<Graph<Integer,String>> ccs = FilterUtils.createAllInducedSubgraphs(wcc.transform(graph),graph);

The problem is that in ccs is stored all the connected components but I just want the giant one (GCC). Since the order of the clusters in the collection css is not determinated by their size, I have to iterate over the whole collection in order to find the giant cluster. The bad thing is that the graph I'm using is huge and has many clusters; so, that iteration costs a lot.

Since I'm new at JUNG I was just wondering if there's a fast way of retrieving the GCC of a graph. Any help is valid.

解决方案

Probably the easiest way to solve your problem would be to hack WeakComponentClusterer so that it kept track of the component sizes (or of which one was the largest, since that's what you're interested in) as it was constructing them, and then exposed that information to the user.

This is a modification we might make at some point but it's easy enough for you to to in your local copy of the code.

这篇关于JUNG - 如何获得图形的巨大连通分量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆