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

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


当前回答

相信一个图可以简单地表示为:

class Node {
   int value;
   List<Node> adj;
}

实现大部分你自己感兴趣的算法。如果您在一些关于图形的练习/学习过程中遇到了这个问题,那么这是最好的库。,)

对于大多数常见算法,你也可以选择邻接矩阵:

class SparseGraph {
  int[] nodeValues;
  List<Integer>[] edges;     
}

或者一些运算的矩阵:

class DenseGraph {
  int[] nodeValues;
  int[][] edges;     
}

其他回答

查看蓝图:

蓝图是属性图数据模型的接口、实现、实现和测试套件的集合。蓝图类似于JDBC,但用于图形数据库。在TinkerPop开源软件堆栈中,蓝图作为基础技术用于:

管道:一个惰性的数据流框架

Gremlin:一种图遍历语言

框架:对象到图的映射器

熔炉:一个图形算法包

Rexster:图形服务器

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.

http://incubator.apache.org/hama/是Hadoop上用于大量矩阵和图形数据的分布式科学软件包。

JUNG是一个很好的可视化选择,并且也有一组相当不错的可用图算法,包括几种不同的随机图创建、重布线等机制。我还发现,在必要的地方扩展和调整它通常相当容易。

简介:

JGraphT if you are more interested in data structures and algorithms. JGraph if your primary focus is visualization. Jung, yWorks, and BFG are other things people tried using. Prefuse is a no no since one has to rewrite most of it. Google Guava if you need good datastructures only. Apache Commons Graph. Currently dormant, but provides implementations for many algorithms. See https://issues.apache.org/jira/browse/SANDBOX-458 for a list of implemented algorithms, also compared with Jung, GraphT, Prefuse, jBPT