私は迷路を表すと思われる20のノードと21のパスを持っています。Neo4J、すべてのパスと最短パスを取得
これで、最初から最後まですべての可能なパス(3つあります)を探したいと思います。
私はまた、最も少ない量の損傷の場合には、最小の重量の経路を見つけたいと考えています。
正しい構文や改善のための任意のヒントを持つすべてのヘルプははるかに高く評価され、
これは私が試してみましたquerys、理解とで失敗しない..です
MATCH p=(a {name:"START"})-[:PATH*tall woods..guard]->(s{name:"Finish"}) RETURN p AS shortestPath, reduce(length=0, r in relationships(p) | length+r.length) AS totalLength order by totalLength
MATCH p=(a {name:"START"})-[:ROAD*tall woods..guard]->(s{name:"Finish"}) RETURN p AS shortestPath, reduce(length=0, r in relationships(p) | length+r.length) AS totalLength order by totalLength limit 1
私は[:Path * tall woods..guard]が間違っていると思いますが、すべてのパスをカンマで区切って書くべきですか?
create(a:LABYRINTH {name:"START"})-[:PATH {name:"spiders", damage:1}]-> (b:LABYRINTH{name:"B"}),
(a)-[:PATH {name:"tall woods", damage:1}]->(c:LABYRINTH {name:"C"}),
(c)-[:PATH {name:"lizards", damage:1}]->(d:LABYRINTH {name:"D"}),
(c)-[:PATH {name:"gremlins", damage:3}]-> (e:LABYRINTH {name:"E"}),
(e)-[:PATH {name:"dark woods", damage:0}]->(f:LABYRINTH {name:"F"}),
(e)-[:PATH {name:"old bridge", damage:2}]->(g:LABYRINTH {name:"G"}),
(g)-[:PATH {name:"orc", damage:5}]->(i:LABYRINTH {name:"I"}),
(i)-[:PATH {name:"dead end", damage:0}]->(h: LABYRINTH {name:"H"}),
(i)-[:PATH {name:"dusty planes", damage:0}]->(j: LABYRINTH {name:"J"}),
(i)-[:PATH {name:"ape", damage:3}]->(k: LABYRINTH {name:"K"}),
(k)-[:PATH {name:"mob", damage:1}]->(q: LABYRINTH {name:"Q"}),
(g)-[:PATH {name:"woods", damage:0}]->(z: LABYRINTH {name:"Z"}),
(z)-[:PATH {name:"dead planes", damage:0}]->(k),
(z)-[:PATH {name:"desert", damage:1}]->(m: LABYRINTH {name:"M"}),
(m)-[:PATH {name:"gorilla", damage:0}]->(n: LABYRINTH {name:"N"}),
(m)-[:PATH {name:"bridge", damage:0}]->(l: LABYRINTH {name:"L"}),
(l)-[:PATH {name:"mud", damage:1}]->(o: LABYRINTH {name:"O"}),
(i)-[:PATH {name:"waters", damage:2}]->(r: LABYRINTH {name:"R"}),
(r)-[:PATH {name:"witch", damage:1}]->(p: LABYRINTH {name:"P"}),
(q)-[:PATH {name:"guard", damage:0}]->(s: LABYRINTH {name:"Finish"}),
(r)-[:PATH {name:"old witch", damage:1}]->(s)
少なくとも質問を投稿してください –
あなたが表示したのはあなたのものです。質問を編集して、試したクエリ、結果、および特定の問題を表示してください。 –