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.

Search Graph Database

Search a Neo4j® graph database using functions provided by the MATLAB® interface to Neo4j and the Database Toolbox™ Interface for Neo4j Bolt Protocol. You can explore the graph data and perform graph network analysis using MATLAB directed graphs.

Search Functionality

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

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

See Also

| | | |

Related Topics

External Websites