Graph visualization library?



I have a directed acyclic graph, represented as a Scala object. Is there a nice library that would help me to turn the graph into a visualization? Thanks!

Best, Oliver


I’m a pretty big fan of using SVG these days for data visualizations
because of the rich set of JavaScript libraries available. For
network-based visualizations I have used D3, and also Cytoscape. Both have
a lot of different network visualizations available.

Brian Maso


I have a commercial project that makes heavy use of graph-based data structures, so I do have some experience to share. It’s not entirely an answer to your question, but it may be helpful.

I started out representing my graph using custom Scala objects, but I’ve been very happy that I moved over to JGraphT to represent my graphs. There are many important algorithms out there for analyzing, deriving and generating graphs, and it’s very helpful to have them all available. Once we had access to canned algorithms, we found uses we hadn’t even considered before.

JGraphT t’s a Java-based library, but it didn’t take much work to write implicit extension methods that make it convenient and idiomatic in Scala (e.g., def += (v: V) = inner.addVertex(v)). There are also some Scala-based graph libraries out there, notably Graph for Scala but at the time when I looked closely, JGraphT had a number of features that I needed that it lacked.

The biggest drawback to using JGraphT + some Scala extension methods is that it’s designed around mutable data structures (like most Java libraries). This isn’t a big deal for my use case as I’d probably use mutable structures for performance anyway—but the option to easily have immutable graphs would be nice.

As far as visualization proper, JGraphT doesn’t handle this, but it’s capable of writing out DOT and GraphML files, which you can feed into lots of different visualization frameworks. If you don’t want to switch to a graph library in your code, you could also generate the DOT format directly: it’s pretty simple.

If the visualization isn’t actually part of the application and you’re just trying to see the data structures, my workflow is to generate a DOT file and pull it into OmniGraffle. (OmniGraffle is macOS only and you have to pay for it, but it’s well worth the money.) A cross-platform option along these lines is yEd, which can consume GraphML.

As @bmaso mentioned, D3 has some powerful graph visualization options that you can drive from DOT files if you want to build something into your own product. It’s not as powerful and convenient as OmniGraffle if your goal is to do exploration of your own graphs, but it’s a perfectly serviceable starting point if you’re building graph visualization into your product.

JGraphT also has a companion called and mxGraph that seems to be able to import GraphML, but I haven’t worked with it personally.