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.
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 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 Neuler (NEuler) Graph App 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?
The Graph Algorithms Playground is one of the Graph Apps included in the Graph Apps Gallery, so you can one click install from that page.
If that’s one click too many, you can one click install into the Neo4j Desktop using the link below:
Installing the Graph Algorithms Playground
This only works on Mac and Windows at the moment so, if like me, you’re using Linux, you’ll need to paste https://bit.ly/install-neuler into the ‘Install Graph Application’ form.
You can access this via the icon with four squares on the side bar of the Neo4j Desktop.
Once you’ve done that the Graph Algorithms Playground will be available to add to any of your projects.
Let’s explore what’s in the box, so to speak.
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:
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.
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 changing the ‘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 run the ‘Store results’ 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, and you have questions regarding your Neo4j database, you can always head to the #help-cypher channel on the Neo4j Users Slack or on the neo4j community.
And here’s that installation link one more time!
Introducing NEuler — The Graph Algorithms Playground was originally published in neo4j on Medium, where people are continuing the conversation by highlighting and responding to this story.