Good Java graph algorithm library?
Solution 1
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.
Solution 2
Summary:
- 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
Solution 3
Check out JGraphT for a very simple and powerful Java graph library that is pretty well done and, to allay any confusion, is different than JGraph. Some sample code:
UndirectedGraph<String, DefaultEdge> g =
new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);
String v1 = "v1";
String v2 = "v2";
String v3 = "v3";
String v4 = "v4";
// add the vertices
g.addVertex(v1);
g.addVertex(v2);
g.addVertex(v3);
g.addVertex(v4);
// add edges to create a circuit
g.addEdge(v1, v2);
g.addEdge(v2, v3);
g.addEdge(v3, v4);
g.addEdge(v4, v1);
Solution 4
JUNG is a good option for visualisation, and also has a fairly good set of available graph algorithms, including several different mechanisms for random graph creation, rewiring, etc. I've also found it to be generally fairly easy to extend and adapt where necessary.
Solution 5
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).
Related videos on Youtube
Comments
-
Nick Fortescue almost 4 years
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.
-
Thomas Owens over 15 yearsWhat were your personal thoughts with prefuse? At my last job, a project started to use it, but ended up with a 90%+ rewritten (and optimized, with additions of new features) version of prefuse.
-
Jonik over 15 yearsI've used yFiles for visualisation of interdependencies between data items (as part of a commercial software platform). I didn't really use any graph analysis algorithms, but check if the y.algo package has what you need: yworks.com/products/yfiles/doc/api
-
Nick Fortescue about 15 yearsThanks for this, I'd never come across it. Are you using it?
-
mr.sverrir about 15 yearsYes, I am using it. I started using it maybe 4 years ago. So far so good, I just wish there was a port of that for .NET, too.
-
T9b over 12 yearsYou misunderstood the question: it is about the kind of graphs that have nodes and edges, not the kind that has pies and bars.
-
Ross Judson over 12 yearsSadly, the jdsl.org page seems to be a spam page now.
-
mr.sverrir over 12 yearsI have updated the link in the original post. Thanks.
-
SoftwareSavant over 11 yearsAlot of those are extremely complicated... Using factory Methods and so forth. I just need something simple to prep for an interview. Any ideas?
-
Frodo Baggins about 11 yearsJGraph does have an analysis package now that includes a range of analysis functions, jgraph.github.com/mxgraph/java/docs/index.html.
-
koppor almost 11 yearsyFiles is not opensource, but offers commercial licenses
-
koppor almost 11 yearsPackages hep.aida.* are LGPL (acs.lbl.gov/software/colt/license.html). This is imported via colt (jung.sourceforge.net/download.html). This prevents JUNG from being used in projects under the umbrella of ASF and ESF. Maybe one should use the github fork github.com/rortian/jung2 and remove that dependency. github.com/rortian/jung2/commit/… is mirroring the last CVS commit. The current commits seem to remove visualization functionality.
-
Someone Somewhere about 8 yearsThis is a great demo here github.com/jgrapht/jgrapht/wiki/DirectedGraphDemo
-
Maytham Fahmi about 7 yearsIf these are complicated than what kind of job you are looking for
-
Yacino almost 7 yearsThere is no released since 2010, I think that this project is abandoned
-
mosh almost 7 yearsGraph algorithms are explained here geeksforgeeks.org/graph-data-structure-and-algorithms with simple code
-
Vishrant over 6 yearsis there any Neo4J client (java client) where you can visualize it?