%% Return Graph Information as Directed Graph
% Search for graph information in a Neo4j® database by using node labels. Return the information as a directed graph and display the edges and nodes of the graph.
% Assume that you have graph data stored in a Neo4j database that represents a social neighborhood. This database has seven nodes and eight relationships. Each node has only one unique property key name with a value ranging from User1 through User7. Each relationship has the type knows.
%
% 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);

%
% Check the Message property of the Neo4j connection object neo4jconn. The blank Message property indicates a successful connection.

neo4jconn.Message

%
% Search the graph for all nodes with the node label Person using the Neo4j database connection. Return graph information as a directed graph by using the 'DataReturnFormat' name-value pair argument with the value 'digraph'.

nlabel = "Person";
graphinfo = searchGraph(neo4jconn,nlabel, ...
    'DataReturnFormat','digraph');

%
% Display the edges of the directed graph.

graphinfo.Edges

%
% Display the nodes of the directed graph.

graphinfo.Nodes

%
% Close the database connection.

close(neo4jconn)

% Copyright 2019 The MathWorks, Inc.