Neo4j - 查找具有最相似属性(节点和关系)的三元组?
Neo4j - Find triplets with most similar attributes (nodes and relationships)?
我有很多三元组,每个用户节点都有不同的属性(它可以包含user_id,一些节点的位置,角色,其他节点可以没有位置但有他们的婚姻状况,use_car 等)和数据节点。
数据节点可以包含位置、大小、原点,有时它只包含位置。
我在这些节点之间有一个关系 - 具有一些属性,如 folder_name、approved/rejected 等
给定一个新的三元组,如何根据属性(用户节点+关系+数据节点)找到最相似的三元组
有什么功能可以做到这一点吗?我很乐意获得检查方向或最小示例。
按照这些思路应该可以帮助您入门
MATCH (u:User)-->(something)<--(other:User)
WHERE u <> other
WITH u, COUNT(something) AS sharedSomethings
ORDER BY sharedSomethings DESC
也许你可以使用 Node Similarity algorithm that uses the Jaccard similarity under the hood. It is available in the Neo4j Graph Data Science library. This algorithm will allow you to compare node similarity based on their attribute nodes as you call them. If you also want to compare node properties, you would have to create your own comparing sets for each node and then use the basic implementation of Jaccard similarity score: https://neo4j.com/docs/graph-data-science/current/alpha-algorithms/jaccard/
我有很多三元组,每个用户节点都有不同的属性(它可以包含user_id,一些节点的位置,角色,其他节点可以没有位置但有他们的婚姻状况,use_car 等)和数据节点。 数据节点可以包含位置、大小、原点,有时它只包含位置。 我在这些节点之间有一个关系 - 具有一些属性,如 folder_name、approved/rejected 等
给定一个新的三元组,如何根据属性(用户节点+关系+数据节点)找到最相似的三元组
有什么功能可以做到这一点吗?我很乐意获得检查方向或最小示例。
按照这些思路应该可以帮助您入门
MATCH (u:User)-->(something)<--(other:User)
WHERE u <> other
WITH u, COUNT(something) AS sharedSomethings
ORDER BY sharedSomethings DESC
也许你可以使用 Node Similarity algorithm that uses the Jaccard similarity under the hood. It is available in the Neo4j Graph Data Science library. This algorithm will allow you to compare node similarity based on their attribute nodes as you call them. If you also want to compare node properties, you would have to create your own comparing sets for each node and then use the basic implementation of Jaccard similarity score: https://neo4j.com/docs/graph-data-science/current/alpha-algorithms/jaccard/