0
都市で輸送するためのテストデータベースを作成しています。 私の目標は、どの停留所でも見つけることができます。 私はこのグラフを作成しました:Neo4Jクエリでパスが表示されない
match p=shortestPath((a)-[:TO*]-(c))
where a.Id=131 and c.Id=268
return p, length(p) limit 1
またはこのクエリ:それは、任意の経路が表示されないのです
MATCH (p1:Tram {id: 131}), (p2:Tram {id: 263133}),
path = shortestpath((p1)-[:NEXT*]-(p2))
RETURN path
create (Stop_13_1:Tram {Id: 131}),
(Stop_13_2:Tram {Id: 132}),
(Stop_26_1:Tram {Id: 261}),
(Stop_26_2:Tram {Id: 262}),
(Stop_26_3_13_3:Tram {Id: 263133}),
(Stop_26_4_13_4:Tram {Id: 264134}),
(Stop_26_5_13_5:Tram {Id: 265135}),
(Stop_26_6_13_6:Tram {Id: 266136}),
(Stop_26_7_13_7:Tram {Id: 267137}),
(Stop_26_8:Tram {Id: 268}),
(Stop_7_1:Trollebus {Id: 71}),
(Stop_7_2:Trollebus {Id: 72}),
(Stop_7_3:Trollebus {Id: 73}),
(Stop_7_4:Trollebus {Id: 74}),
(Stop_7_5:Trollebus {Id: 75});
私は短い道を見つけてみてください
。 クエリの編集にお役立てください。P.S.私は関係を追加するのを忘れ:
MATCH (Stop_13_1 {Id: 131}),
(Stop_13_2 {Id: 132}),
(Stop_26_1 {Id: 261}),
(Stop_26_2 {Id: 262}),
(Stop_26_3_13_3 {Id: 263133}),
(Stop_26_4_13_4 {Id: 264134}),
(Stop_26_5_13_5 {Id: 265135}),
(Stop_26_6_13_6 {Id: 266136}),
(Stop_26_7_13_7 {Id: 267137}),
(Stop_26_8 {Id: 268}),
(Stop_7_1 {Id: 71}),
(Stop_7_2 {Id: 72}),
(Stop_7_3 {Id: 73}),
(Stop_7_4 {Id: 74}),
(Stop_7_5 {Id: 75})
MERGE (Stop_13_1)- [:NEXT{distance:4.7,route:13,transport:'tram',direct:'down'}]->(Stop_13_2)
MERGE (Stop_13_2)-[:NEXT{distance:4.7,route:13,transport:'tram',direct:'up'}]->(Stop_13_1)
MERGE (Stop_13_2)-[:NEXT{distance:3.7,route:13,transport:'tram',direct:'down'}]->(Stop_26_3_13_3)
MERGE (Stop_26_3_13_3)-[:NEXT{distance:3.7,route:13,transport:'tram',direct:'up'}]->(Stop_13_2)
MERGE (Stop_26_1)-[:NEXT{distance:5.8,route:26,transport:'tram',direct:'down'}]->(Stop_26_2)
MERGE (Stop_26_2)-[:NEXT{distance:5.8,route:26,transport:'tram',direct:'up'}]->(Stop_26_1)
MERGE (Stop_26_2)-[:NEXT{distance:2.5,route:26,transport:'tram',direct:'down'}]->(Stop_26_3_13_3)
MERGE (Stop_26_3_13_3)-[:NEXT{distance:2.5,route:26,transport:'tram',direct:'up'}]->(Stop_26_2)
MERGE (Stop_26_3_13_3)-[:NEXT{distance:3.1,route:26,route:13,transport:'tram',direct:'down'}]->(Stop_26_4_13_4)
MERGE (Stop_26_4_13_4)-[:NEXT{distance:3.1,route:26,route:13,transport:'tram',direct:'up'}]->(Stop_26_3_13_3)
MERGE (Stop_26_4_13_4)-[:NEXT{distance:5.8,route:26,route:13,transport:'tram',direct:'down'}]->(Stop_26_5_13_5)
MERGE (Stop_26_5_13_5)-[:NEXT{distance:5.8,route:26,route:13,transport:'tram',direct:'up'}]->(Stop_26_4_13_4)
MERGE (Stop_26_5_13_5)-[:NEXT{distance:10.8,route:26,route:13,transport:'tram',direct:'down'}]->(Stop_26_6_13_6)
MERGE (Stop_26_6_13_6)-[:NEXT{distance:10.8,route:26,route:13,transport:'tram',direct:'up'}]->(Stop_26_5_13_5)
MERGE (Stop_26_6_13_6)-[:NEXT{distance:2.5,route:26,route:13,transport:'tram',direct:'down'}]->(Stop_26_7_13_7)
MERGE (Stop_26_7_13_7)-[:NEXT{distance:2.5,route:26,route:13,transport:'tram',direct:'up'}]->(Stop_26_6_13_6)
MERGE (Stop_26_5_13_5)-[:NEXT{distance:0.6,transport:'walking',direct:'down'}]->(Stop_7_2)
MERGE (Stop_7_2)-[:NEXT{distance:0.6,transport:'walking',direct:'up'}]->(Stop_26_5_13_5)
MERGE (Stop_26_8)-[:NEXT{distance:1,route:26,transport:'tram',direct:'down'}]->(Stop_26_7_13_7)
MERGE (Stop_26_7_13_7)-[:NEXT{distance:1,route:26,transport:'tram',direct:'up'}]->(Stop_26_8)
MERGE (Stop_7_1)-[:NEXT{distance:2.2,route:7,transport:'trolleybus',direct:'down'}]->(Stop_7_2)
MERGE (Stop_7_2)-[:NEXT{distance:2.2,route:7,transport:'trolleybus',direct:'up'}]->(Stop_7_1)
MERGE (Stop_7_2)-[:NEXT{distance:1.6,route:7,transport:'trolleybus',direct:'up'}]->(Stop_7_3)
MERGE (Stop_7_3)-[:NEXT{distance:2.5,route:7,transport:'trolleybus',direct:'up'}]->(Stop_7_4)
MERGE (Stop_7_4)-[:NEXT{distance:3.1,route:7,transport:'trolleybus',direct:'down'}]->(Stop_7_5)
MERGE (Stop_7_5)-[:NEXT{distance:4.4,route:7,transport:'trolleybus',direct:'down'}]->(Stop_7_2)
あなたが作成したrノードが、私は関係の作成を参照していない。それをあなたの説明に加えることができますか?また、作成した要素をそれぞれ別々の行に作成できるように、作成を分割できますか?水平にスクロールすると読みにくくなります。 – InverseFalcon
Christopheの答えは正しいですが、次のステップでは、NEXT関係の距離プロパティを考慮した加重最短パスを使用できるAPOCプロシージャプラグインの追加をお勧めします。 https://github.com/neo4j-contrib/neo4j-apoc-procedures#graph-algorithms-work-in-progress – InverseFalcon