Graph with Graphviz

Triggered by a user question, let me just very briefly highlight a nice and easy graph visualization feature.

Sometimes, you just want to fast see what you are putting in your little example graph. In Neo4j, there is a well hidden gem-the Graphviz Component. To very shortly output a graphviz rendering, look at this test, demonstrating the basic usage (this code is actually taking a traversal instruction to walk the graph, you can easily just use the whole graph):

And gives you the following output in the Graphviz DOT notation: With this piped into a file, say, you can now do (after installing graphviz and dot on your machine):

dot -Tpng -O

And get an output file of, pictured below.

Voila, your are done and can see what you just programmed!

Happy hacking!


Want to learn more about graph databases? Click below to get your free copy of O’Reilly’s Graph Databases ebook and discover how to use graph technologies for your application today.

Download My Ebook



Anonymous says:

Hi, I was wondering if you can output the cluster style / subgraphs from graphviz with <b>org.neo4j.visualization.graphviz</b> according to this:<br /><br />&lt;a href=&quot;;;/a&gt;<br /><br />Thanks

Hi there,<br />for this, you can implement your own GrapStyle, see<br /><br />When you do it, please let us know, contribution is welcome!

Mark Needham says:

I was trying to visualise a continuous integration pipeline by parsing its Xml representation into a neo4j graph and then spitting out a graphviz representation but I couldn&#39;t work out how to get the &#39;title&#39; of a node to be the &#39;name&#39; property on the neo node.<br /><br />Is there anyway to do that? I looked at the source for a bit at the time but couldn&#39;t see an easy way

Mmh, not sure. Probably needs somethings like<br /> public void nodeTitle( String pattern )<br /> {<br /> final PatternParser parser = new PatternParser( pattern );<br /> styles.add( new StyleParameter.NodeTitle()<br /> {<br /> public String getTitle( Node container )<br /> {<br /> return parser.parse( container );<br /> }

Hi, your link to the well hidden Gem <br /><br /><br /><br />does not work anymore. Do you still use graphviz into Neo4J? Thanks!

Hi, the link you provided <br /><br /><br /><br />does not work anymore. Do you still use Graphviz<br />into Neo4J?<br /><br />Thanks

Anonymous says:

Repository is moved. Particular graphviz dir can be found here –

The link to the Graphviz module is currently:

And to the it is:

Many thanks for sharing the module, source snippets and hints.

Leave a Reply

Your email address will not be published. Required fields are marked *


Upcoming Event


From the CEO

Emil's Blog

Have a Graph Question?

Contact Us

Share your Graph Story?

Email us:

Popular Graph Topics