在查询shortestPath时获取密码时的关系

时间:2018-05-23 12:45:26

标签: neo4j cypher neo4j-java-api

我试图找到两个节点之间的最短路径,我想获得关系(起始节点,结束节点和类型),这样我就可以用Java生成子图。

我正在使用这个密码:

MATCH (nodeA),(nodeB), p = shortestPath((nodeA)-[*..15]-(nodeB)) WHERE ID(nodeA) = 1332076 AND ID(nodeB) = 1459451 UNWIND nodes(p) as n UNWIND relationships(p) as r RETURN collect(distinct { id : id(n), labels : labels(n), data: n}) as nodes, collect(distinct r) as relationships

我的问题是以我不理解的格式返回关系。像这样:

{ "TFFamily": "MADS", "Category": "DIRECT", "PubMedID": "UNKNOWN", "Reference": "NA", "Interaction": "UNCONFIRMED", "TargetType": "AT2G36590", "Confirmation": "NO", "isTF": "AT2G36590" } { "HIT_END": "104", "BLAST_alignement_length": "52", "BLAST_evalue": "4.00E-27", "HIT_START": "53", "BLAST_percentage_identity": "82.69", "percentage_match": "43.7", "QUERY_START": "58", "clusterid": "CLUSTER_5713", "QUERY_END": "109", "BLAST_mismatches": "9", "BLAST_nrofgaps": "0"}

究竟是什么关系(p)? 有没有办法获得startId,endId和类型?

由于

编辑:

可能的解决方案:

不确定这是否是最佳选择,但我发现 startNode(r)和endNode(r)

" MATCH (nodeA),(nodeB), p = shortestPath((nodeA)-[%s*..%s]-(nodeB))" + //
                " WHERE ID(nodeA) = {1} AND ID(nodeB) = {2} " +  //
                " UNWIND nodes(p) as n" + //
                " UNWIND relationships(p) as r" + //
                " RETURN COLLECT(distinct { id : id(n), labels : labels(n), data: n}) as nodes, " + //
                " COLLECT(distinct { relationshipId : ID(r), startId : ID(startNode(r)), labels : type(r) , endId: ID(endNode(r))}) as edges"; //

0 个答案:

没有答案