neo4j win10安装
neo4j依赖jdk环境,本例中neo4j-community-3.5.8、jdk1.8
neo4j启动
在neo4j-community-3.5.8的bin目录下,执行neo4j start
neo4j stop为停服务
客户端访问
http://localhost:7474/browser/
账号密码默认为neo4j
安装算法插件
1、下载neo4j对应算法的插件jar包 https://github.com/neo4j-contrib/neo4j-graph-algorithms/releases
通过这个地址查看neo4j版本和插件版本的对应并下载对应的jar包https://github.com/neo4j-contrib/neo4j-graph-algorithms/blob/master/versions.json
2、将graph-algorithms-algo-[version].jar 下载的jar包复制到$NEO4J_HOME/plugins目录中。
3、将以下内容添加到您的$NEO4J_HOME/conf/neo4j.conf
文件中:
dbms.security.procedures.unrestricted=algo.*
此处配置的作用是:需要为库提供不受限制的访问权限,因为算法使用较低级别的内核API来读取和写入。
4、重启neo4j
D:\xxx\neo4j-community-3.5.8\bin neo4j start
验证算法插件是否正确安装
通过
CALL algo.list()
验证
page-rank算法简单示例
数据:
MERGE (home:Page {name:'Home'})
MERGE (about:Page {name:'About'})
MERGE (product:Page {name:'Product'})
MERGE (links:Page {name:'Links'})
MERGE (a:Page {name:'Site A'})
MERGE (b:Page {name:'Site B'})
MERGE (c:Page {name:'Site C'})
MERGE (d:Page {name:'Site D'})
MERGE (home)-[:LINKS]->(about)
MERGE (about)-[:LINKS]->(home)
MERGE (product)-[:LINKS]->(home)
MERGE (home)-[:LINKS]->(product)
MERGE (links)-[:LINKS]->(home)
MERGE (home)-[:LINKS]->(links)
MERGE (links)-[:LINKS]->(a)
MERGE (a)-[:LINKS]->(home)
MERGE (links)-[:LINKS]->(b)
MERGE (b)-[:LINKS]->(home)
MERGE (links)-[:LINKS]->(c)
MERGE (c)-[:LINKS]->(home)
MERGE (links)-[:LINKS]->(d)
MERGE (d)-[:LINKS]->(home)
执行算法查看结果
CALL algo.pageRank.stream('Page', 'LINKS', {iterations:20, dampingFactor:0.85})
YIELD nodeId, score
RETURN algo.asNode(nodeId).name AS page,score
ORDER BY score DESC