有人对图形算法的Java库有很好的经验吗?我试过JGraph,发现它还行,谷歌中有很多不同的。有哪些是人们在实际生产代码中成功使用或推荐的?

澄清一下,我不是在寻找一个生成图形/图表的库,我在寻找一个有助于图算法的库,例如最小生成树,Kruskal的算法节点,边等。理想情况下,它在一个漂亮的Java OO API中具有一些良好的算法/数据结构。


当前回答

Apache Commons提供了Commons -graph。在http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/下可以查看源代码。SVN中也有API使用示例。参见https://issues.apache.org/jira/browse/SANDBOX-458获得实现的算法列表,并与Jung, GraphT, Prefuse, jBPT进行比较

谷歌番石榴如果你只需要好的数据结构。

JGraphT是一个实现了许多算法的图库,并且(在我看来)有一个很好的图模型。Helloworld例子。许可:LGPL + EPL。

JUNG2 is also a BSD-licensed library with the data structure similar to JGraphT. It offers layouting algorithms, which are currently missing in JGraphT. The most recent commit is from 2010 and packages hep.aida.* are LGPL (via the colt library, which is imported by JUNG). This prevents JUNG from being used in projects under the umbrella of ASF and ESF. Maybe one should use the github fork and remove that dependency. Commit f4ca0cd is mirroring the last CVS commit. The current commits seem to remove visualization functionality. Commit d0fb491c adds a .gitignore.

Prefuse使用矩阵结构存储图,这对于稀疏图来说内存效率不高。许可:BSD

Eclipse Zest内置了图形布局算法,可以独立于SWT使用。看到org.eclipse.zest.layouts.algorithms。所使用的图结构是Eclipse Draw2d中的一个,其中节点是显式对象,而不是通过泛型注入的(这发生在Apache Commons graph、JGraphT和JUNG2中)。

其他回答

试试Annas吧,它是一个开源的图形包,很容易掌握

http://annas.googlecode.com

如果你实际上是在寻找图表库,而不是节点/边缘图库,我建议你挥霍大无面图库(BFG)。它比JFreeChart更容易使用,看起来更好,运行更快,有更多的输出选项,真的没有可比性。

If you were using JGraph, you should give a try to JGraphT which is designed for algorithms. One of its features is visualization using the JGraph library. It's still developed, but pretty stable. I analyzed the complexity of JGraphT algorithms some time ago. Some of them aren't the quickest, but if you're going to implement them on your own and need to display your graph, then it might be the best choice. I really liked using its API, when I quickly had to write an app that was working on graph and displaying it later.

如果你喜欢图形算法,JDSL (Java中的数据结构库)应该足够好了——http://www.cs.brown.edu/cgc/jdsl/

在一个大学项目中,我摆弄了yWorks的yFiles,发现它有很好的API。