www.gusucode.com > database 案例源码程序 matlab代码 > database/SearchGraphByNodeLabelsExample.m
%% Search Graph by Node Labels % Create a Neo4j(R) 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(R) connection object % |neo4jconn|. neo4jconn.Message %% % The blank |Message| property indicates a successful connection. %% % Search the graph for all nodes that are labeled as |'Person'| using the % Neo4j(R) database connection |neo4jconn|. nlabel = {'Person'}; graphinfo = searchGraph(neo4jconn,nlabel) %% % |graphinfo| is a structure that contains the results of the search: %% % * |Nodes| -- A table containing all starting and ending nodes that denote each % matched relationship. % * |Relations| -- A table containing all matched relationships. %% % Access the table of nodes. graphinfo.Nodes %% % Access property keys for the first node. graphinfo.Nodes.NodeData{1} %% % Access the table of relationships. graphinfo.Relations %% % Access property keys for the first relationship. graphinfo.Relations.RelationData{1} %% % The first relationship has no property keys. %% % Search the graph for all node labels in the database. allnodes = nodeLabels(neo4jconn); graphinfo = searchGraph(neo4jconn,allnodes);