Star Trek — U.S.S. Enterprise

Explore New Worlds — Adding Plugins to Neo4j

Jennifer Reif
Neo4j Developer Blog
8 min readJun 6, 2018

--

*updated 10/09/19

As always, there are always a flurry of changes to Neo4j and some of its tools. To coincide with each release, we usually also have updates completed for our extension libraries.

With all this in mind, I thought I would quickly show how to install 2 plugins from our list (APOC and graph algorithms). I hope to add to your list of skills and capabilities and open up the possibilities of utilizing Neo4j. Let’s get started!

Graph Algorithms

I want to kick off the post with this one because it is really fun and visual. This algorithms library allows you to explore your data and extract more meaningful insights in less time than traditional reports, queries, human review, etc. Currently, Neo4j’s graph algorithms library contains all the typically-used and desired algorithms, such as centrality, community detection, pathfinding, and many more.

With the latest release, we also added the approximate nearest neighborsand a few other improvements, including relationship aggregation and running on multiple relationships. For those new to the algorithm space, our new docs give a great explanation of any recent additions, as well as some examples.

This stuff sounds pretty awesome, right? So now let’s get Neo4j Desktop set up so you can start right in working with graph algorithms and testing them out.

  1. Open Neo4j Desktop. If you don’t have this application on your machine, you can download it from Neo4j’s website and follow the instructions to get it set up.
  2. Choose or Create a project to work within.

There are two different methods to install the Graph Algorithms plugin from here. I will list both options here, and you can choose which one you prefer.

A. If you want to install at the project level (i.e. all of your databases within the project will include the plugin), then you can pick your project and scroll down to the bottom of the right pane. At the bottom of the right pane, there is a box with Add Plugin. Click that, then choose the plugin you want to add (graph algorithms, in this case), then click Install on the popup message. You should then see it show up in your project pane in Desktop once you close the plugin modal.

B. If you want to install at the database level (i.e. you don’t want all of your databases in the project to have the plugin), then you can pick your project and click Manage on the database where you want to install it. Under the plugins tab, you will should see options for a few plugins. Click Install for the Graph Algorithms.

*Note: if your database is running, it may shut down and restart, or you may have to do that before the plugin can be used.

Once the installation is complete, you are ready to start running algorithms! You can load your own dataset and use Neo4j’s algorithms to bring out connections, or if you’re not sure how to get started, you can use a few of our sandbox guides.

My personal favorite guide is the Graph of Thrones example, where we look at the connections in the Game of Thrones book series to see which characters are the most influential, which characters tend to group into certain communities, and which characters are the most connected to others!

To access that sandbox guide, you can choose your project and database where you installed the algorithms, then click Open Browser and type :play data_science in the command line and click Play. The guide will walk you through the rest! The image below shows a visualization done on the Graph of Thrones data set in Neo4j.

You can also get quick help on any of the algorithm syntaxes with
call algo.list('algorithm-name')

APOC

This library was created by one of my colleagues as a way to provide additional procedures and functions that developers often need, but not yet baked into the product. The variety is amazing, and it is well-supported. Say goodbye to writing boring, repetitive functions over and over. It is also incredibly easy to run these procedures from the Neo4j Browser command line.

Where have these been all my life? :) Let’s get them set up and dive in!

You can follow the same first two steps above that we had for the Graph Algorithms plugin by opening Neo4j Desktop and choosing the project you want to work within. I’ve copied options A and B for installing the APOC plugin here so that I can provide relevant screenshots.

A. If you want to install at the project level (i.e. all of your databases within the project will include the plugin), then you can pick your project and scroll down to the bottom of the right pane. At the bottom of the right pane, there is a box with Add Plugin. Click that, then choose the plugin you want to add (APOC, in this case), then click Install on the popup message. You should then see it show up in your project pane in Desktop once you close the plugin modal.

B. If you want to install at the database level (i.e. you don’t want all of your databases in the project to have the plugin), then you can pick your project and click Manage on the database where you want to install it. Under the plugins tab, you will should see options for a few plugins. Click Install for APOC.

*Note: if your database is running, it may shut it down and restart, or you may have to do that before the plugin can be used.

To start working with APOC, you can start any of our sandbox guides or create a query with a procedure or function. Some of the ones that I’ve been working with recently are listed below. More info and details of all the available procedures can be found in the APOC documentation on GitHub.

APOC has a built-in help procedure that gives you a short description and syntax for all procedures and functions, you can run it with:
call apoc.help('keyword')

  • apoc.date.format(dateForConversion, [timeUnit], [format]) — convert an epoch time-value to a desired format. Can be useful for outputting to reports, showing on a web screen, including it in a URL as a parameter, and hundreds of other things.
  • apoc.load.json(url) — load data from a URL and use Cypher statements to create or update data in Neo4j database. Excellent for calling an API and dumping retrieved data into Neo4j.
  • apoc.periodic.iterate(query1, query2, {param1: value1}) — used as a sort of batch loader. Can pull a list of results in the first query, then execute another query on each of those query1 results to update each one or retrieve other data for it. Can set parameters for batch size, variables, retry number, etc.

Other Plugins and Graph Apps

There are many more plugins and graph applications you can add to interact with Neo4j in various ways. To check out the full list and to install any of them, you can go to the Graph Applications tab on Neo4j Desktop, as shown below.

You should see a list of applications you already have access to, as well as a section near the bottom to install other graph apps. Here, you can enter the url to pull in the graph app, or you can also discover all the applications we have available. To do that, click the Discover more graph apps link in blue at the bottom, and it will display a webpage with all the graph apps!

Just as an example, we’re going to install the Graph Algorithms Playground (NEuler), which is a tool to try out and visualize the graph algorithms on top of data sets. Several default data sets are provided for loading, or users can import their own data to Neo4j and use this to explore algorithms with their data.

So, on the graph app library page, we will choose Install on the Graph Algorithms Playground and go back to Neo4j Desktop.

Now that you’ve installed the application, you need to add it to whichever project you are working in. Simply pick your project, then click on the Add Application box at the top of the right pane and choose Add on the Graph Algorithms Playground application, then click Ok.

Between the plugins and graph apps, you can cover a lot of ground and different use cases. There is a lot of documentation, and we are always willing to help with questions or confusion via Community Site, Slack, StackOverflow, or email. Happy coding!

Resources

--

--

Jennifer Reif
Neo4j Developer Blog

Jennifer Reif is an avid developer and problem-solver. She enjoys learning new technologies, sometimes on a daily basis! Her Twitter handle is @JMHReif.