JUNG - How to get the giant connected component of a graph?

末鹿安然 提交于 2019-12-10 17:42:45

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/7182052/jung-how-to-get-the-giant-connected-component-of-a-graph

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!