简体   繁体   English

neo4j 图算法中的定性搜索

[英]Qualitative searches in neo4j graph algorithms

We have different entities and relationships in our neo4j graph.我们的 Neo4j 图中有不同的实体和关系。 So there are different types of triangles that can potentially be in the graph,所以图中可能有不同类型的三角形,

CITATION -> CITATION -> CITATION引文 -> 引文 -> 引文

CITATION -> CITATION -> JOURNAL引文 -> 引文 -> 期刊

to name a few.仅举几例。 I was able to find all these in the algorithm to find triangles:我能够在算法中找到所有这些来找到三角形:

CALL algo.triangle.stream(null, null)
YIELD nodeA, nodeB, nodeC


RETURN labels(algo.asNode(nodeA)) AS nodeA, nodeA AS nodeAinfo, labels(algo.asNode(nodeB)) AS nodeB, algo.asNode(nodeB).CITATION AS nodeBinfo, labels(algo.asNode(nodeC)) AS nodeC, algo.asNode(nodeC).CITATION AS nodeCinfo ORDER BY labels(algo.asNode(nodeA))

However, I am wondering if there is a way to specify the type of triangle in as a parameter of the function.但是,我想知道是否有办法将三角形的类型指定为函数的参数。 I think I am only able to input a node type and a relationship type in the algorithm.我想我只能在算法中输入节点类型和关系类型。

CALL algo.triangle.stream('citation', 'cited_by')
YIELD nodeA, nodeB, nodeC

What if there are a two or more node types and two or more relationships types - is there a way to specify these?如果有两个或多个节点类型和两个或多个关系类型 - 有没有办法指定这些? Thanks.谢谢。

The first 2 arguments to algo.triangle.stream can be Cypher queries returning the native IDs of the nodes of interest and the end-nodes of the relationships of interest, respectively. algo.triangle.stream 的前 2 个参数可以是 Cypher 查询,分别返回感兴趣节点的本机 ID 和感兴趣关系的末端节点。 To indicate you are using this syntax, the config map must specify a graph property with the value of 'cypher' .为了表明您正在使用此语法,配置映射必须指定一个值为'cypher'graph属性。

For example, here is a snippet that shows how to get triangles involving CITATION and JOURNAL nodes, and cited_by and referenced_by relationships:例如,这里是一个片段,展示了如何获取涉及CITATIONJOURNAL节点以及cited_byreferenced_by关系的三角形:

CALL algo.triangle.stream(
  'MATCH (p) WHERE ANY(lbl IN ["CITATION", "JOURNAL"] WHERE lbl IN LABELS(p)) RETURN id(p) as id',
  'MATCH (p1)-[r]->(p2) WHERE TYPE(r) IN ["cited_by", "referenced_by"] RETURN id(p1) as source,id(p2) as target',
  {graph:'cypher'})
YIELD nodeA, nodeB, nodeC
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM