Documentation

### This is machine translation

Translated by
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.

## Searching Graph Database Using MATLAB Interface to Neo4j

Search the Neo4j® graph database using functions provided by the MATLAB® interface to Neo4j. You can explore the graph data or perform graph network analysis using MATLAB directed graphs.

### MATLAB Interface to Neo4j Search Functions

Search graph data in the Neo4j graph database using different parts of the graph:

To access the part of the graph database that you want to analyze, combine these functions and explore the graph data in the output arguments.

### General and Targeted Search Workflows

You can search the Neo4j graph database in a general or targeted way. A general search starts from a subgraph or the entire graph. A targeted search starts from an origin node and traverses its relationships.

After finding a part of the graph, you can create a MATLAB directed graph and perform graph network analysis.

#### Conduct General Search

1. Conduct a general search for a subgraph using `searchGraph`.

For example, to find the subgraph `graphinfo`, enter this code, which assumes a successful Neo4j database connection `neo4jconn`.

```nlabel = {'Person'}; graphinfo = searchGraph(neo4jconn,nlabel);```
2. Convert the output structure `graphinfo` into a `digraph` object `G` using `neo4jStruct2Digraph`.

```G = neo4jStruct2Digraph(graphinfo); ```
3. Perform graph network analysis using `G`. For details, see Directed and Undirected Graphs (MATLAB).

For example, determine the shortest path between nodes using `distances`.

```d = distances(G); ```

Or, explore the graph data by accessing the output structure `graphinfo`.

#### Conduct Targeted Search

1. To start your search, find the origin node using `searchNode` or `searchNodeByID`.

For example, to find the origin node `nodeinfo`, enter this code, which assumes a successful Neo4j database connection `neo4jconn` and the node identifier `2`.

```nodeinfo = searchNodeByID(neo4jconn,2); ```
2. Search for graph data by using the origin node and `searchRelation`. Or, if you know the relationship identifier, then use the `searchRelationByID` function.

For example, this code assumes that you are searching for incoming relationships.

```relinfo = searchRelation(neo4jconn,nodeinfo,'in'); ```
3. Convert the output structure `relinfo` into a `digraph` object `G` by using `neo4jStruct2Digraph`.

```G = neo4jStruct2Digraph(relinfo); ```
4. Perform graph network analysis using the `digraph` object `G`. For details, see Directed and Undirected Graphs (MATLAB).

For example, determine the shortest path between nodes using `distances`.

```d = distances(G); ```

Or, explore the graph data by accessing the output structures `nodeinfo` and `relinfo`.

## External Websites

#### Using MATLAB with Big Data from Sensors and IoT Devices

Download white paper