Neo4j shortestPath

I have a graph with two types of relationships:

  • Type T1represents one way street
  • A type T2represents two paths .

In the neo4j document tip, I want to avoid creating two relationships for two-way streets, as it slows down the shortestPath function.

But is there a way to cross T1 directional and T2 bidirectional in a function shortestPath?

It should be noted that I can not use undirected search because of the T1relationship!

+4
source share
1 answer

Using a cypher function shortespaththat you cannot execute.

, , T2.

street shortestpath, , - , shortespath, , .

API , APOC (https://neo4j-contrib.imtqy.com/neo4j-apoc-procedures/#_graph_algorithms_work_in_progress) AStar dijkstraWithDefaultWeight.

Update

, apoc.algo.dijkstraWithDefaultWeight algo APOC:

MATCH (from:Way { id: $idFrom }), 
      (to:Way { id: $idTo }) 
WITH from, to
CALL apoc.algo.dijkstraWithDefaultWeight(from, to, 'T1>|T2', 'distance', 1) YIELD path, weight
RETURN path, weight
+2

Source: https://habr.com/ru/post/1693320/


All Articles