0

我正在使用 Neo4j Enterprise v 4.3 和 gds 插件 v 1,7.0。我创建了一个虚拟图,如下:

 CALL gds.graph.create.cypher(
  "match_seg",
  "MATCH (d:DNA_Match) where d.ancestor_rn=33454
   RETURN id(d) AS id",
   "MATCH (m:DNA_Match{ancestor_rn:33454)-[r:match_segment]->(s:Segment{chr:'01'}) where r.cm>=7 and r.snp_ct>=500
   RETURN
     id(m) AS source,
     id(s) AS target,
     r.cm AS weight",
  {
    readConcurrency: 4,
    validateRelationships:FALSE
  }
)

它返回节点计数 29 和关系计数为零。

然而,当我在 Neo4j 中运行单个查询时,我得到了不同的结果。

MATCH (d:DNA_Match) where d.ancestor_rn=33454
   RETURN id(d) AS id

返回 29 个节点

但这是明显的异常:

MATCH (m:DNA_Match{ancestor_rn:33454})-[r:match_segment]->(s:Segment{chr:'01'}) where r.cm>=7 and r.snp_ct>=500
   RETURN
     id(m) AS source,
     id(s) AS target,
     r.cm AS weight

这将返回 8726 行。

为什么我没有在我的虚拟图中得到关系?

4

1 回答 1

1

您的问题是您只投影一个节点:

MATCH (d:DNA_Match) where d.ancestor_rn=33454
RETURN id(d) AS id

GDS 库删除所有源节点和目标节点都不存在的关系。您将需要执行以下操作:

 CALL gds.graph.create.cypher(
  "match_seg",
  "MATCH (d:DNA_Match) where d.ancestor_rn=33454
   RETURN id(d) AS id
   UNION
   MATCH (m:DNA_Match{ancestor_rn:33454)-[r:match_segment]-> 
   (s:Segment{chr:'01'}) where r.cm>=7 and r.snp_ct>=500
   RETURN id(s) as id",
   "MATCH (m:DNA_Match{ancestor_rn:33454)-[r:match_segment]->(s:Segment{chr:'01'}) where r.cm>=7 and r.snp_ct>=500
   RETURN
     id(m) AS source,
     id(s) AS target,
     r.cm AS weight",
  {
    readConcurrency: 4,
    validateRelationships:FALSE
  }
)
于 2021-09-27T07:10:34.710 回答