This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Neo4j database connection


Create a Neo4j® database connection using the MATLAB® interface to Neo4j. Explore the graph database or perform graph analytics using the MATLAB directed graph.

With a Neo4jConnect object, you can perform these tasks:

  • Explore the graph database for nodes and relationships.

  • Search the graph database for nodes, relationships, or a subgraph.

  • Execute a Cypher® query.


Create a Neo4jConnect object using neo4j.


expand all

This property is read-only.

Neo4j database connection URL that contains the server, port number, and web location of the Neo4j database, specified as a character vector.

Example: http://localhost:7474/db/data where localhost is the server, 7474 is the port number, /db/data is the web location of the database

Data Types: char

This property is read-only.

User name for accessing the Neo4j database, specified as a character vector.

Data Types: char

This property is read-only.

Error message, specified as a character vector. If this property is empty, the database connection is successful.

Data Types: char

Object Functions

expand all

nodeLabelsAll node labels in Neo4j database
relationTypesAll relationship types in Neo4j database
propertyKeysAll property keys in Neo4j database
searchNodeByIDSearch for Neo4j database nodes by node identifier
searchNodeSearch Neo4j database nodes by label or by property key and value
searchRelationSearch relationships for Neo4j database node
searchRelationByIDSearch Neo4j relationship by relationship identifier
searchGraphSearch for subgraph or entire graph in Neo4j database
createNodeCreate nodes in Neo4j database
createRelationCreate relationships between nodes in Neo4j database
deleteNodeDelete nodes from Neo4j database
deleteRelationDelete relationships from Neo4j database
updateNodeUpdate node labels and properties in Neo4j database
updateRelationUpdate relationship properties in Neo4j database
storeDigraphStore directed graph in Neo4j database
executeCypherExecute Cypher query on Neo4j database


collapse all

Create a Neo4j® database connection using the URL http://localhost:7474/db/data, user name neo4j, and password matlab.

url = 'http://localhost:7474/db/data';
username = 'neo4j';
password = 'matlab';

neo4jconn = neo4j(url,username,password)
neo4jconn = 

  Neo4jConnect with properties:

         URL: 'http://localhost:7474/db/data/'
    UserName: 'neo4j'
     Message: []

neo4j returns a Neo4jConnect object with these properties:

  • URL -- The Neo4j® database web location

  • UserName -- The user name used to connect to the database

  • Message -- Any database connection error messages

Check the Message property of the Neo4j® connection object neo4jconn.

ans =


The blank Message property indicates a successful Neo4j® database connection.

Retrieve all node labels using the Neo4j® database connection neo4jconn.

nlabels = nodeLabels(neo4jconn)
nlabels =

  1×1 cell array


The cell array nlabels contains a character vector for the one node label in the Neo4j® database.

Introduced in R2016b