<p>Has anyone had good experiences with any Java libraries for Graph algorithms. I've tried <a href="http://www.jgraph.com/jgraph.html" rel="noreferrer">JGraph</a> 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?</p>

<p>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.</p>

[{'answer_id': 51609, 'author': 'Jacob Rigby', 'author_id': 5357, 'author_profile': 'https://Stackoverflow.com/users/5357', 'pm_score': 3, 'selected': False, 'text': '<p>For visualization our group had some success with <a href="http://prefuse.org/" rel="noreferrer">prefuse</a>.  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.</p>\n\n<p>UPDATE:\nI\'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.</p>\n'}, {'answer_id': 51628, 'author': 'Turismo', 'author_id': 5271, 'author_profile': 'https://Stackoverflow.com/users/5271', 'pm_score': 3, 'selected': False, 'text': '<p>In a university project I toyed around with yFiles by <a href="http://www.yworks.com" rel="noreferrer">yWorks</a> and found it had pretty good API. </p>\n'}, {'answer_id': 51631, 'author': 'Jacob Rigby', 'author_id': 5357, 'author_profile': 'https://Stackoverflow.com/users/5357', 'pm_score': 0, 'selected': False, 'text': '<p>If you are actually looking for Charting libraries and not for Node/Edge Graph libraries I would suggest splurging on Big Faceless Graph library (<a href="http://big.faceless.org/products/graph/" rel="nofollow noreferrer">BFG</a>).  It\'s way easier to use than JFreeChart, looks nicer, runs faster, has more output options, really no comparison.</p>\n'}, {'answer_id': 51657, 'author': 'Kai', 'author_id': 2963, 'author_profile': 'https://Stackoverflow.com/users/2963', 'pm_score': 5, 'selected': False, 'text': '<p><a href="http://jung.sourceforge.net/" rel="noreferrer">JUNG</a> 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.</p>\n'}, {'answer_id': 51978, 'author': 'Hank Gay', 'author_id': 4203, 'author_profile': 'https://Stackoverflow.com/users/4203', 'pm_score': 2, 'selected': False, 'text': '<p>I don\'t know if I\'d call it production-ready, but there\'s <a href="http://jgabl.sourceforge.net/" rel="nofollow noreferrer">jGABL</a>.</p>\n'}, {'answer_id': 52062, 'author': 'Joe Liversedge', 'author_id': 4552, 'author_profile': 'https://Stackoverflow.com/users/4552', 'pm_score': 5, 'selected': False, 'text': '<p>Check out <a href="http://jgrapht.org/" rel="noreferrer">JGraphT</a> for a very simple and powerful Java graph library that is pretty well done and, to allay any confusion, <em>is different than JGraph</em>. Some <a href="https://github.com/jgrapht/jgrapht/wiki/HelloWorld" rel="noreferrer">sample code</a>:</p>\n\n<pre><code>UndirectedGraph&lt;String, DefaultEdge&gt; g =\n        new SimpleGraph&lt;String, DefaultEdge&gt;(DefaultEdge.class);\n\n    String v1 = "v1";\n    String v2 = "v2";\n    String v3 = "v3";\n    String v4 = "v4";\n\n    // add the vertices\n    g.addVertex(v1);\n    g.addVertex(v2);\n    g.addVertex(v3);\n    g.addVertex(v4);\n\n    // add edges to create a circuit\n    g.addEdge(v1, v2);\n    g.addEdge(v2, v3);\n    g.addEdge(v3, v4);\n    g.addEdge(v4, v1);\n</code></pre>\n'}, {'answer_id': 52691, 'author': 'Bartosz Bierkowski', 'author_id': 3666, 'author_profile': 'https://Stackoverflow.com/users/3666', 'pm_score': 8, 'selected': True, 'text': '<p>If you were using JGraph, you should give a try to <a href="http://jgrapht.org/" rel="noreferrer">JGraphT</a> 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.</p>\n'}, {'answer_id': 579116, 'author': 'mr.sverrir', 'author_id': 70033, 'author_profile': 'https://Stackoverflow.com/users/70033', 'pm_score': 3, 'selected': False, 'text': '<p>JDSL (Data Structures Library in Java) should be good enough if you\'re into graph algorithms - <a href="http://www.cs.brown.edu/cgc/jdsl/" rel="noreferrer">http://www.cs.brown.edu/cgc/jdsl/</a></p>\n'}, {'answer_id': 854877, 'author': 'mansu', 'author_id': 105735, 'author_profile': 'https://Stackoverflow.com/users/105735', 'pm_score': 6, 'selected': False, 'text': '<p>Summary:</p>\n\n<ul>\n<li><a href="https://github.com/jgrapht/jgrapht/" rel="noreferrer">JGraphT</a> if you are more interested in data structures and algorithms.</li>\n<li><a href="https://www.jgraph.com/jgraph.html" rel="noreferrer">JGraph</a> if your primary focus is visualization.</li>\n<li><a href="http://jung.sourceforge.net/" rel="noreferrer">Jung</a>, <a href="http://www.yworks.com" rel="noreferrer">yWorks</a>, and <a href="http://bfo.com/products/graph/" rel="noreferrer">BFG</a> are other things people tried using.</li>\n<li><a href="https://github.com/prefuse/Prefuse" rel="noreferrer">Prefuse</a> is a no no since one has to rewrite most of it.</li>\n<li><a href="https://github.com/google/guava/wiki/GraphsExplained" rel="noreferrer">Google Guava</a> if you need good datastructures only.</li>\n<li><a href="http://commons.apache.org/sandbox/commons-graph/" rel="noreferrer">Apache Commons Graph</a>. Currently dormant, but provides implementations for many algorithms. See <a href="https://issues.apache.org/jira/browse/SANDBOX-458" rel="noreferrer">https://issues.apache.org/jira/browse/SANDBOX-458</a> for a list of implemented algorithms, also compared with Jung, GraphT, Prefuse, <a href="https://github.com/jbpt/codebase" rel="noreferrer">jBPT</a></li>\n</ul>\n'}, {'answer_id': 961683, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>Try Annas its an open source graph package which is easy to get to grips with</p>\n\n<p><a href="http://annas.googlecode.com" rel="noreferrer">http://annas.googlecode.com</a></p>\n'}, {'answer_id': 2506409, 'author': 'Jonathan Hendler', 'author_id': 135043, 'author_profile': 'https://Stackoverflow.com/users/135043', 'pm_score': 4, 'selected': False, 'text': '<p><a href="http://neo4j.org/" rel="noreferrer">http://neo4j.org/</a> is a graph database that contains many of graph algorithms and scales better than most in-memory libraries.</p>\n'}, {'answer_id': 2844481, 'author': 'xyz', 'author_id': 342449, 'author_profile': 'https://Stackoverflow.com/users/342449', 'pm_score': 3, 'selected': False, 'text': '<p><a href="http://incubator.apache.org/hama/" rel="noreferrer">http://incubator.apache.org/hama/</a> is a distributed scientific package on Hadoop for massive matrix and graph data.</p>\n'}, {'answer_id': 2980129, 'author': 'Bob', 'author_id': 359160, 'author_profile': 'https://Stackoverflow.com/users/359160', 'pm_score': 0, 'selected': False, 'text': '<p>JGraph from <a href="http://mmengineer.blogspot.com/2009/10/java-graph-floyd-class.html" rel="nofollow noreferrer">http://mmengineer.blogspot.com/2009/10/java-graph-floyd-class.html</a></p>\n\n<p>Provides a powerfull software to work with graphs (direct or undirect). Also generates Graphivz code, you can see graphics representations. You can put your own code algorithms into pakage, for example: backtracking code. The package provide some algorithms: Dijkstra, backtracking minimun path cost, ect.. </p>\n'}, {'answer_id': 16699707, 'author': 'koppor', 'author_id': 873282, 'author_profile': 'https://Stackoverflow.com/users/873282', 'pm_score': 4, 'selected': False, 'text': '<p>Apache Commons offers <a href="http://commons.apache.org/sandbox/commons-graph/" rel="noreferrer">commons-graph</a>. Under  <a href="http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/" rel="noreferrer">http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/</a> one can inspect the source. Sample API usage is <a href="http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseMutableGraphTestCase.java?view=markup" rel="noreferrer">in the SVN</a>, too. See <a href="https://issues.apache.org/jira/browse/SANDBOX-458" rel="noreferrer">https://issues.apache.org/jira/browse/SANDBOX-458</a> for a list of implemented algorithms, also compared with Jung, GraphT, Prefuse, <a href="https://github.com/jbpt/codebase" rel="noreferrer">jBPT</a></p>\n\n<p><a href="https://github.com/google/guava/wiki/GraphsExplained" rel="noreferrer">Google Guava</a> if you need good datastructures only.</p>\n\n<p><a href="https://github.com/jgrapht/jgrapht" rel="noreferrer">JGraphT</a> is a graph library with many Algorithms implemented and having  (in my oppinion) a good graph model. <a href="https://github.com/jgrapht/jgrapht/wiki/HelloWorld" rel="noreferrer">Helloworld Example</a>. License: LGPL+EPL.</p>\n\n<p><a href="http://jung.sourceforge.net" rel="noreferrer">JUNG2</a> 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 <code>hep.aida.*</code> are LGPL (via the <a href="http://acs.lbl.gov/software/colt/license.html" rel="noreferrer">colt library</a>, which <a href="http://jung.sourceforge.net/download.html" rel="noreferrer">is imported by JUNG</a>). This prevents JUNG from being used in projects under the umbrella of ASF and ESF. Maybe one should use the <a href="http://github.com/rortian/jung2" rel="noreferrer">github fork</a> and remove that dependency. <a href="https://github.com/rortian/jung2/commit/f4ca0cdcd3312589cbb48de7350b84cbff6067b9" rel="noreferrer">Commit f4ca0cd</a> is mirroring the last CVS commit. The current commits seem to remove visualization functionality. <a href="https://github.com/rortian/jung2/commit/d0fb491c0b5d2156e12df3a344521cfe7581c3d8" rel="noreferrer">Commit d0fb491c</a> adds a <code>.gitignore</code>.</p>\n\n<p><a href="https://github.com/prefuse/Prefuse" rel="noreferrer">Prefuse</a> stores the graphs using a matrix structure, which is not memory efficient for sparse graphs. License: BSD</p>\n\n<p><a href="http://www.eclipse.org/gef/zest/" rel="noreferrer">Eclipse Zest</a> has built in graph layout algorithms, which can be used independently of SWT. See <a href="http://git.eclipse.org/c/gef/org.eclipse.zest.git/tree/org.eclipse.zest.layouts/src/org/eclipse/zest/layouts/algorithms" rel="noreferrer">org.eclipse.zest.layouts.algorithms</a>. The graph structure used is the one of <a href="http://www.eclipse.org/gef/draw2d/" rel="noreferrer">Eclipse Draw2d</a>, where <a href="http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.draw2d.doc.isv/reference/api/org/eclipse/draw2d/graph/DirectedGraph.html" rel="noreferrer">Nodes are explicit objects</a> and not injected via Generics (as it happens in Apache Commons Graph, JGraphT, and JUNG2).</p>\n'}, {'answer_id': 19005810, 'author': 'Luc', 'author_id': 753672, 'author_profile': 'https://Stackoverflow.com/users/753672', 'pm_score': 2, 'selected': False, 'text': '<p>If you need performance, you might take a look at Grph. The library is developed in the French University and CNRS/Inria.</p>\n\n<p><a href="http://www.i3s.unice.fr/~hogie/grph/" rel="nofollow">http://www.i3s.unice.fr/~hogie/grph/</a></p>\n\n<p>The project is active and reactive support is provided!</p>\n'}, {'answer_id': 21218206, 'author': 'Norbert Madarász', 'author_id': 478686, 'author_profile': 'https://Stackoverflow.com/users/478686', 'pm_score': 2, 'selected': False, 'text': '<p>Instructional graph algorithm implementations in java could be found here (by prof. Sedgewick et al.):\n<a href="http://algs4.cs.princeton.edu/code/" rel="nofollow">http://algs4.cs.princeton.edu/code/</a></p>\n\n<p>I was introduced to them while attending these exceptional algorithm courses on coursera (also taught by prof. Sedgewick):</p>\n\n<p><a href="https://www.coursera.org/course/algs4partI" rel="nofollow">https://www.coursera.org/course/algs4partI</a></p>\n\n<p><a href="https://www.coursera.org/course/algs4partII" rel="nofollow">https://www.coursera.org/course/algs4partII</a></p>\n'}, {'answer_id': 21348339, 'author': 'Snicolas', 'author_id': 693752, 'author_profile': 'https://Stackoverflow.com/users/693752', 'pm_score': 3, 'selected': False, 'text': "<p>It's also good to be convinced that a Graph can be represented as simply as : </p>\n\n<pre><code>class Node {\n   int value;\n   List&lt;Node&gt; adj;\n}\n</code></pre>\n\n<p>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. ;)</p>\n\n<p>You can also prefer adjacency matrix for most common algorithms : </p>\n\n<pre><code>class SparseGraph {\n  int[] nodeValues;\n  List&lt;Integer&gt;[] edges;     \n}\n</code></pre>\n\n<p>or a matrix for some operations : </p>\n\n<pre><code>class DenseGraph {\n  int[] nodeValues;\n  int[][] edges;     \n}\n</code></pre>\n"}, {'answer_id': 21487933, 'author': 'alex', 'author_id': 165130, 'author_profile': 'https://Stackoverflow.com/users/165130', 'pm_score': 3, 'selected': False, 'text': '<p>check out <a href="https://github.com/tinkerpop/blueprints/wiki">Blueprints</a>:</p>\n\n<p>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:</p>\n\n<p><a href="http://pipes.tinkerpop.com/">Pipes</a>: A lazy, data flow framework</p>\n\n<p><a href="http://gremlin.tinkerpop.com/">Gremlin</a>: A graph traversal language</p>\n\n<p><a href="http://frames.tinkerpop.com/">Frames</a>: An object-to-graph mapper</p>\n\n<p><a href="http://furnace.tinkerpop.com/">Furnace</a>: A graph algorithms package</p>\n\n<p><a href="http://rexster.tinkerpop.com/">Rexster</a>: A graph server</p>\n'}]
['https://Stackoverflow.com/questions/51574', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5346/']