最近学习Neo4j4.4.4版本图数据库,用到了(Graph Data Science)做PageRank算法。当我在用下面这个函数给子图命名的时候,系统一直给我报错
CALL gds.graph.create(
'myGraph',
'Page',
'LINKS',
{
relationshipProperties: 'weight'
}
)
#报错是这样的
There is no procedure with the name `gds.graph.create` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
说是没有gds.graph.create这个函数,我找了很多文档也找不着,后来发现GDS2.0以上版本把这个函数给删除了。
我改成
CALL gds.graph.project('myGraph','Page','LINKS')
问题得到了解决
评估内存的函数
CALL gds.pageRank.write.estimate('myGraph', {
writeProperty: 'pageRank',
maxIterations: 20,
dampingFactor: 0.85
})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, requiredMemory
再进行PageRank算法
CALL gds.pageRank.stream('myGraph')
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC
我自己参考借鉴这篇文章做的。
neo4j使用PageRank算法
返回GDS的版本
RETURN gds.version()
GDS里面各种函数的用途
CALL gds.list()
GDS里面各种函数的具体参数
CALL dbms.procedures()
查到创建子图的函数参数如下:
"gds.graph.project(graphName :: STRING?, nodeProjection :: ANY?, relationshipProjection :: ANY?, configuration = {} :: MAP?) :: (nodeProjection :: MAP?, relationshipProjection :: MAP?, graphName :: STRING?, nodeCount :: INTEGER?, relationshipCount :: INTEGER?, projectMillis :: INTEGER?)"
如果需要创建两个类型的点之间的关系,
CALL gds.graph.project(
'myGraph',
['users','movies'],
'rated',
{
relationshipProperties:'rating'
}
)