www.gusucode.com > database 案例源码程序 matlab代码 > database/SearchGraphByRelationshipsExample.m
%% Search Graph by Relationships % 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 the relationship type |'knows'| using the Neo4j(R) % database connection |neo4jconn|. reltype = {'knows'}; graphinfo = searchGraph(neo4jconn,reltype) %% % |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 the table of relationships. graphinfo.Relations %% % Search the graph for all relationship types in the database. allreltypes = relationTypes(neo4jconn); graphinfo = searchGraph(neo4jconn,allreltypes);