GDS Virtual Graph 不同于组件查询

GDS Virtual Graph different than component queries

我正在使用 Neo4j Enterprise v 4.3 和 gds plugin 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
  }
)

它 returns 节点数为 29,关系数为零。

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

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

returns 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

这 returns 8726 行。

为什么我无法在我的虚拟图中获取关系?

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

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
  }
)