NoSQL Zone is brought to you in partnership with:

Michael Hunger has been passionate about software development for a long time. He is particularly interested in the people who develop software, software craftsmanship, programming languages, and improving code. For the last few years he has been working with Neo Technology on the Neo4j graph database. As the project lead of Spring Data Neo4j he helped developing the idea to become a convenient and complete solution for object graph mapping. He is also taking care of Neo4j cloud hosting efforts. Michael now takes care of the Neo4j community in all regards and is involved with activities in all parts of the company. Michael is a DZone MVB and is not an employee of DZone and has posted 14 posts at DZone. You can read more from them at their website. View Full User Profile

Styling Neo4j Server Visualization

06.11.2014
| 1941 views |
  • submit to reddit

To give you a head start when using Neo4j-Browser I wanted to share these quick tips for styling and querying.

howto_style

First of all, you have to download, unzip and start neo4j. If you have a JDK (Java7) installed and on the path it should look like this:

$ cd neo4j-community-2.1.1
$ bin/neo4j start

Using additional JVM arguments:  ....
Starting Neo4j Server...WARNING: not changing user
process [70299]... waiting for server to be ready...... OK.
http://localhost:7474/ is ready.

As told, we open the URL http://localhost:7474/ in our browser and can start working with Neo4j and its query language Cypher directly.

If you want to learn more first, click on any of the helpful links show after startup, these are quick slide shows that introduce the different concepts quickly.

  • Intro – a guided tour :play intro

  • Concepts – GraphDB 101 :play concepts

  • Cypher – query language :play cypher

  • The Movie Graph – a mini graph app :play movie graph

But we want to get going with the visualization. So let’s import some data, query it and start styling. To do that, we run :play movies, click on the huge Cypher CREATE … statement and
run it using the triangular run button in the command line editor.

After a few seconds the data is imported, but we’ll see only the lonely Matrix node that’s returned. We want to see more and that’s why go to the favorites tab on the left, indicated by a star and
click on the Get Some Data entry, preferably on the green round run-button besides the title. This should give us a graph visualization to play with.

But those nodes only show numbers! Now click on any red node that has ACTED_IN relationships pointing to it. These are Movie nodes. In the popup you’ll see the node label “Movie” on the top.
In the tab on the right, denoted with an “eye”, you can set the styling parameters and property chosen for the displayed title.

style_node

Play a bit with the styling options and do the same for the other nodes (labeled Person). The next step is styling relationships, just click on one (e.g. DIRECTED) and try it out.

style_relationship

The whole visualization is powered by a concept called Graph Style Sheet or GRASS. You can access the style sheet with the link at the bottom of the styling popup.
The resulting style renderer allows you to look at the style-sheet, download it or update it via drag-and-drop. You can also reset all styling with the “fire extinguisher”.

style_sheet_grass

If you rather watch me performing all these things, here is the screencasts that explains it all in detail. Enjoy!

How to style the Neo4j-Browser visualization? from Neo Technology on Vimeo.

Published at DZone with permission of Michael Hunger, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)