Good Java graph algorithm library? [closed]

2018-12-31 18:25发布

Has anyone had good experiences with any Java libraries for Graph algorithms. I've tried JGraph and found it ok, and there are a lot of different ones in google. Are there any that people are actually using successfully in production code or would recommend?

To clarify, I'm not looking for a library that produces graphs/charts, I'm looking for one that helps with Graph algorithms, eg minimum spanning tree, Kruskal's algorithm Nodes, Edges, etc. Ideally one with some good algorithms/data structures in a nice Java OO API.

18条回答
闭嘴吧你
2楼-- · 2018-12-31 18:50

check out Blueprints:

Blueprints is a collection of interfaces, implementations, ouplementations, and test suites for the property graph data model. Blueprints is analogous to the JDBC, but for graph databases. Within the TinkerPop open source software stack, Blueprints serves as the foundational technology for:

Pipes: A lazy, data flow framework

Gremlin: A graph traversal language

Frames: An object-to-graph mapper

Furnace: A graph algorithms package

Rexster: A graph server

查看更多
临风纵饮
3楼-- · 2018-12-31 18:50

For visualization our group had some success with prefuse. We extended it to handle architectural floorplates and bubble diagraming, and it didn't complain too much. They have a new Flex toolkit out too called Flare that uses a very similar API.

UPDATE: I'd have to agree with the comment, we ended up writing a lot of custom functionality/working around prefuse limitations. I can't say that starting from scratch would have been better though as we were able to demonstrate progress from day 1 by using prefuse. On the other hand if we were doing a second implementation of the same stuff, I might skip prefuse since we'd understand the requirements a lot better.

查看更多
其实,你不懂
4楼-- · 2018-12-31 18:56

Summary:

查看更多
冷夜・残月
5楼-- · 2018-12-31 18:56

It's also good to be convinced that a Graph can be represented as simply as :

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

and implement most the algorithms you find interesting by yourself. If you fall on this question in the middle of some practice/learning session on graphs, that's the best lib to consider. ;)

You can also prefer adjacency matrix for most common algorithms :

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

or a matrix for some operations :

class DenseGraph {
  int[] nodeValues;
  int[][] edges;     
}
查看更多
临风纵饮
6楼-- · 2018-12-31 18:57

Instructional graph algorithm implementations in java could be found here (by prof. Sedgewick et al.): http://algs4.cs.princeton.edu/code/

I was introduced to them while attending these exceptional algorithm courses on coursera (also taught by prof. Sedgewick):

https://www.coursera.org/course/algs4partI

https://www.coursera.org/course/algs4partII

查看更多
还给你的自由
7楼-- · 2018-12-31 19:00

Apache Commons offers commons-graph. Under http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/ one can inspect the source. Sample API usage is in the SVN, too. See https://issues.apache.org/jira/browse/SANDBOX-458 for a list of implemented algorithms, also compared with Jung, GraphT, Prefuse, jBPT

Google Guava if you need good datastructures only.

JGraphT is a graph library with many Algorithms implemented and having (in my oppinion) a good graph model. Helloworld Example. License: 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 stores the graphs using a matrix structure, which is not memory efficient for sparse graphs. License: BSD

Eclipse Zest has built in graph layout algorithms, which can be used independently of SWT. See org.eclipse.zest.layouts.algorithms. The graph structure used is the one of Eclipse Draw2d, where Nodes are explicit objects and not injected via Generics (as it happens in Apache Commons Graph, JGraphT, and JUNG2).

查看更多
登录 后发表回答