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 neo4j.dot, you can now do (after installing graphviz and dot on your machine):

dot -Tpng -O neo4j.dot


And get an output file of neo4j.dot.png, pictured below.






















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


Happy hacking!


/peter
 

Keywords:  


11 Comments

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;http://www.graphviz.org/content/cluster&gt;graphviz.org/content/cluster&lt;/a&gt;<br /><br />Thanks

Hi there,<br />for this, you can implement your own GrapStyle, see https://github.com/neo4j/community/blob/master/graphviz/src/main/java/org/neo4j/visualization/graphviz/GraphStyle.java<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 />https://github.com/neo4j/community/tree/master/graphviz<br /><br />does not work anymore. Do you still use graphviz into Neo4J? Thanks!

Hi, the link you provided <br /><br />https://github.com/neo4j/community/tree/master/graphviz<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 – https://github.com/neo4j/neo4j/tree/master/community/graphviz

Leave a Reply

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

Related Posts

Popular Graph Topics

Archives

Have a Graph Question?

Reach out and connect with the Neo4j staff.
Stackoverflow
Contact Us