Introducing NEuler — The Graph Algorithms Playground
Until now the only way to run Graph Algorithms on Neo4j has been to learn Cypher. The Graph Algorithms Playground changes all that.
Note: This article assumes that you have used Neo4j Desktop before. We added some info that should get you through anyhow, but if you have questions, please refer to this great intro to Neo4j Desktop by Jennifer Reif.
It’s been almost two years since the release of the Neo4j Graph Algorithms library, which made it easy for developers to run algorithms like PageRank, Louvain Modularity, and Weighted Shortest Path, on their graph data.
These algorithms were made available as procedures, and can be executed directly from Cypher queries.
In January my colleague Irfan and I were chatting, and we thought it’d be cool if we could open up the power of graph algorithms to users that don’t want to spend their days writing Cypher code.
We presented our initial efforts building the Neo4j Euler (NEuler) Graph App (aka the Graph Algorithms Playground)in episode 54 of the Neo4j Online Meetup, and showed how the app could be used to analyse the Game of Thrones universe.
Over the last month we’ve taken user feedback on board, and added support for path finding and similarity algorithms.
How do I install it?
First you should have Neo4j Desktop installed. Then in the default Project, create and start a Graph.
The Graph Algorithms Playground (NEuler) is one of the Graph Apps included in the Graph Apps Gallery, so you can use the one-click-install (Windows, OSX) from that page.
This only works on Mac and Windows at the moment.
If like me, you’re using Linux, you’ll need to paste https://bit.ly/install-neuler into the ‘Install Graph Application’ form. That always works.
You can access this section via the icon with four squares on the sidebar of the Neo4j Desktop.
Make sure you have
at least version 0.1.10 of the app installed, otherwise some functionality like the example dataset will not yet be there. If you had installed it before, check that your Desktop is not in offline-mode. It has to be online to automatically install updates.
Once you’ve done that the Graph Algorithms Playground will be available to add to any of your projects, which you do via the (+) Add Application button in your Project, see below.
Presuming you added a new, empty graph (database) to your project and having started the graph, you can start the Graph Algorithms Playground graph app.
Let’s explore what’s in the box.
Exploring the Graph Algorithms Playground
Once you launch the Graph Algorithms Playground you’ll be faced with this screen, which describes the categories of algorithms available in the app.
If you want to learn more about the intricacies of the algorithms in each of these categories, this is the part of the post where I shamelessly plugin the Graph Algorithms Book that Amy Hodler and I have been working on.
You’ll can download your complimentary copy of this book by going to neo4j.com/graph-algorithms-book
Loading sample graphs
Anyway, enough of that, back to NEuler. I think the best way to understand graph algorithms is to play around with sample datasets that we know well and inspect the results that the algorithms return.
To help with that we’ve added a section of the app from which you can load sample graphs:
At the moment we’ve only got Game of Thrones, but we’ll add more over time. If we click ‘Load’ on the Game of Thrones dataset, we’ll see the following screen:
This dataset contains the interactions between characters across the seasons, and was compiled by Andrew Beveridge. You can explore it in Neo4j separately with
Clicking the ‘Yes load it!’ button will execute those Cypher queries, so don’t do this on a production database!
Once we’ve got that dataset loaded, we can start to explore the data in preparation for the new season that starts on Sunday (or Monday if you’re in the UK like me!).
One of the simplest algorithms is Degree Centrality, which on this dataset indicates how many interactions a character has had. From the screenshot below we can see that in Season 1 — Ned, Tyrion, and Catelyn were the most directly important.
We can do the same for the other seasons by selecting another ‘Relationship Type’ and running the algorithm again.
We can also view charts showing the results of the centrality algorithms. The chart below shows the output from running the PageRank algorithm on the Season 2 data.
This algorithm finds the characters who are the most transitively important i.e. which characters have been interacting with other important characters.
What about the code?
And if we want to try these algorithms out on our own, the ‘Code’ tab shows the queries and parameters that can be used in the Neo4j Browser to achieve this:
The ‘Send to Neo4j Browser’ option will generate a Browser Guide and open it up in the Neo4j Browser.
Combining community detection and centrality
One of the other cool features of the Graph Algorithms Playground is visualising the output of the algorithms.
This is most fun when combining community detection and centrality algorithms. In the example below we see the combination of the PageRank centrality and Louvain community detection algorithms.
If we tick the ‘Store results’ checkbox of these algorithms, we can then choose the ‘Node Size’ and ‘Node Color’ based on those results. In this visualisation we can see the communities from Season 2 of the show.
I thought we must have made a mistake because of the disconnected component containing Daenerys on the right of the diagram, but Irfan reminded me that in Season 2 they were away from everyone else and only interacted with each other!
We hope you like this addition to the Graph App Gallery. Enjoy playing around with the app and let us know in the comments if you like it. You can also share screenshots of the algorithm results on your data on Twitter, with the tags
If you have questions regarding your Neo4j experience, you can always head to the Neo4j Community Forum.
Don’t forget to grab the free copy of our O’Reilly book about “Graph Algorithms on Apache Spark and Neo4j”