Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan 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 search for nodes, use one of two functions. Search for one or more nodes using searchNode. Search for a node with a specific identifier using searchNodeByID.

  • Search for relationships from an origin node using searchRelation.

  • Search for the entire graph database or a subgraph using searchGraph.

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.

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

See Also

| | | |

Related Examples

More About

Was this topic helpful?