Main Content

Graph Database Workflow for Neo4j Database Interfaces

You can interact with graph data stored in a Neo4j® database using the MATLAB® interface to Neo4j or the Database Toolbox™ Interface for Neo4j Bolt Protocol. The MATLAB interface to Neo4j uses the REST API to create a database connection. The Database Toolbox Interface for Neo4j Bolt Protocol uses the Bolt protocol to make the connection.

The MATLAB interface to Neo4j enables you to:

  • Create a Neo4j database connection using the REST API.

  • Import graph data from a Neo4j database into MATLAB.

  • Perform graph network analysis by creating a directed graph from the imported graph data.

  • Create, update, and delete nodes and relationships in the graph database.

  • Update node labels and properties and update relationship properties.

  • Export a directed graph from MATLAB into a Neo4j database.

  • Execute Cypher® queries on the Neo4j database, if you are familiar with the Cypher query language.

  • Close the database connection.

The Database Toolbox Interface for Neo4j Bolt Protocol enables you to use the same functionality and the same workflow to interact with graph data stored in a Neo4j database.

About Neo4j Graph Databases

A graph database stores data using a graph data model. This model consists of nodes and relationships. A relationship describes how two or more nodes are related to each other.

Nodes can have one or more node labels and property keys, or zero labels and property keys. Neo4j assigns unique identifiers to nodes and relationships.

Relationships are always directed and have a relationship type. A relationship always has a start node and an end node. A node can have incoming and outgoing relationships. Two nodes can have multiple relationships between them.

For details about graphs, see Directed and Undirected Graphs. For details about the Neo4j database, see Why Graph Databases?

Neo4j Graph Database Workflow

This workflow shows how to connect to a Neo4j database, search and update the graph database, store a directed graph, and perform graph network analysis.

  1. Connect to a Neo4j database using neo4j.

  2. Search the graph database.

    Conduct a general search in the graph database using any of these functions:

    Or, conduct a targeted search in the graph database using any of these functions:

  3. Update the graph database.

    Create nodes and relationships using these functions:

    Update nodes and relationships using these functions:

    Delete nodes and relationships using these functions:

  4. Export a directed graph from MATLAB into a Neo4j database by using the storeDigraph function.

  5. To perform graph network analysis, you can convert output structures to digraph objects using neo4jStruct2Digraph. For details, see Directed and Undirected Graphs.

    Or, if you know the Cypher query language, you can execute a Cypher query using executeCypher. For details, see Cypher Query Language.

  6. Close the database connection using the close function.

Advantage of Database Toolbox Interface for Neo4j Bolt Protocol

You can connect to a Neo4j database using the REST API or the Bolt protocol. The Bolt protocol provides the advantage of sending binary data instead of a JSON payload using the REST API. Binary data is smaller than a JSON payload. Sending data of a smaller size generally improves performance when you use the Bolt protocol.

To use the Bolt protocol, you must install the Database Toolbox Interface for Neo4j Bolt Protocol. For details, see Database Toolbox Interface for Neo4j Bolt Protocol Installation. For details about connecting to a Neo4j database using either interface, see the neo4j function.

See Also

| |

Related Topics

External Websites