【问题标题】:NEO4J shortestPath taking into account a particular relationship patternNEO4J shortestPath 考虑到特定的关系模式
【发布时间】:2014-06-10 09:57:04
【问题描述】:

我有一个图表,其中我的节点链具有关系 [:LINKS_TO],我可以成功地让 shortestPath 函数工作。

对于我的大多数用户来说,这种详细程度都很好。

我有另一组用户,他们需要更丰富的关系信息。鉴于关系上的属性应该代表关系的优势或得分,我创建了特定节点来保存描述性元数据。

这意味着我有一个模式说 (start)-[:PARTICIPATES]-(middle)-[:REFERENCES]->(end)

链的起点和终点之间可以有任意数量的节点。

我正在努力让 shortestPath 函数返回更详细链的任何结果。有没有办法使用 Cypher 做到这一点?

【问题讨论】:

    标签: neo4j relationship shortest-path


    【解决方案1】:

    您也可以保留有关关系的元数据信息。

    根据您的需要,这应该可以:

    MATCH p = shortestPath((start)-[:PARTICIPATES|:REFERENCES*]->(end))
    RETURN nodes(p)
    

    【讨论】:

    • 我不得不将其稍微调整为以下//Shortest DB relationship path MATCH (startTable { name:"ProductPhoto" }),(endTable { name:"Customer" }), p = shortestPath((startTable)-[r:PARTICIPATES_IN|:REFERENCES*..15]-(endTable)) RETURN p
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-23
    相关资源
    最近更新 更多