-
Book Overview & Buying
-
Table Of Contents
Graph Data Science with Neo4j
By :
There are several ways to use Neo4j:
For the scope of this book, we will use the Neo4j Desktop option, since this application takes care of many things for us and we do not want to go into server management at this stage.
The easiest way to use Neo4j on your local computer when you are in the experimentation phase, is to use the Neo4j Desktop application, which is available on Windows, Mac, and Linux OS. This user interface lets you create Neo4j databases, which are organized into Projects, manage the installed plugins and applications, and update the DB configuration – among other things.
Installing it is super easy: go to the Neo4j download center and follow the instructions. We recap the steps here, with screenshots to guide you through the process:
Figure 1.7 – Neo4j Download Center
eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InN0ZWxsYTBvdWhAZ21haWwuY29tIiwibWl4cGFuZWxJZ CI6Imdvb2dsZS1vYXV0a
...
...
The following steps depend on your operating system:
For Linux users, here is how to proceed:
# update path depending on your system
$ cd Downloads/
AppImage file you’ve just downloaded:$ DESKTOP_VERSION=`ls -tr neo4j-desktop*.AppImage | tail -1 | grep -Po "(?<=neo4j-desktop-)[^AppImage]+"
$ echo ${DESKTOP_VERSION}echo command shows something like 1.4.11-x86_64., you’re good to go. Alternatively, you can identify the pattern yourself and create the variable, like so:$ DESKTOP_VERSION=1.4.11-x86_64. # include the final dot
chmod and run the application:# make file executable:
$ chmod +x neo4j-desktop-${DESKTOP_VERSION}AppImage# run the application:
$ ./neo4j-desktop-${DESKTOP_VERSION}AppImageThe last command in the preceding code snippet starts the Neo4j Desktop application. The first time you run the application, it will ask you for the activation key you saved when downloading the executable. And that’s it – the application will be running, which means we can start creating Neo4j databases and interact with them.
Creating a new database with Neo4j desktop is quite straightforward:
This process is illustrated in the following screenshot:
Figure 1.8 – Adding a new database with Neo4j Desktop
Note
Save the password in a safe place; you’ll need to provide it to drivers and applications when connecting to this database.
Figure 1.9 – Choosing a name, password, and version for your new database
Figure 1.10 – Starting your newly created database
Note
You can’t have two databases running at the same time. If you start a new database while another is still running, the previous one must be stopped before the new one can be started.
You now have Neo4j Desktop installed and a running instance of Neo4j on your local computer. At this point, you are ready to start playing with graph data. Before moving on, let me introduce Neo4j Aura, which is an alternative way to quickly get started with Neo4j.
Neo4j also has a DB-as-a-service component called Aura. It lets you create a Neo4j database hosted in the cloud (either on Google Cloud Platform or Amazon Web Services, your choice) and is fully managed – there’s no need to worry about updates anymore. This service is entirely free up to a certain database size (50k nodes and 150k relationships), which makes it sufficient for experimenting with it. To create a database in Neo4j Aura, visit https://neo4j.com/cloud/platform/aura-graph-database/.
The following screenshot shows an example of a Neo4j database running in the cloud thanks to the Aura service:
Figure 1.11 – Neo4j Aura dashboard with a free-tier instance
Clicking Explore opens Neo4j Bloom, which we will cover in Chapter 3, Characterizing a Graph Dataset, while clicking Query starts Neo4j Browser in a new tab. You’ll be requested to enter the connection information for your database. The URL can be found in the previous screenshot – the username and password are the ones you set when creating the instance.
In the rest of this book, examples will be provided using a local database managed with the Neo4j Desktop application, but you are free to use whatever technique you prefer. However, note that some minor changes are to be expected if you choose something different, such as directory location or plugin installation method. In the latter case, always refer to the plugin or application documentation to find out the proper instructions.
Now that our first database is ready, it is time to insert some data into it. For this, we will use our first Cypher queries.
Change the font size
Change margin width
Change background colour