cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Routing with osm data in Neo4j

This is my first project trying to use Neo4j to solve problem. Hope this approach will work. Thank you in advance for the community and community users to help me out.

Let me introduce my problem first, I'm currently working on a project which needs to generate an optimized routing given a list of machine address. Which means I need to traverse all the machines with minimum effort. So I'm thinking maybe this can be achieved by adding those machines as Point Of Interest after loading OSM data into Neo4j, then use the minimum spanning tree to get the best routing plan.

I've imported osm data into Neo4j and followed the steps in README of https://github.com/neo4j-contrib/osm Now I have a few issues to be solved:

1) Is it possible to add point of interest by providing a list of (lat,lon)? If yes, can you give me a sample cypher?

2) Assume 1) can be solved, for now, I'm just using the same adding POI query as in README, which is adding restaurants as POI, I found those POI cannot route to another POI via Routable nodes and ROUTE relationship. If I add Intersection in the
nodeProjection, the query will be extremely slow. Hence my minimum spanning Tree algorithm is not giving me the correct result as well.

3) Is there a way to find the nearest POI given any location (lat,lon)?

FYI my scripts for shortest path and minimum spanning tree

CALL gds.alpha.shortestPath.astar.stream({
 nodeProjection: ['Routable','PointOfInterest'],
 relationshipProjection: {
   ROUTE: {
     type: 'ROUTE',
     properties: 'distance'
   }
 },
 startNode: start,
 endNode: end,
 propertyKeyLat: 'lat',
 propertyKeyLon: 'lon'
})
YIELD nodeId, cost
RETURN gds.util.asNode(nodeId).name AS station, cost

minimum spanning tree script

CALL gds.alpha.spanningTree.minimum.write({
 nodeProjection: ['Routable','PointOfInterest'],
 relationshipProjection: {
   ROUTE: {
     type: 'ROUTE',
     properties: 'distance'
   }
 },
 startNodeId: id(n),
 relationshipWeightProperty: 'distance',
 writeProperty: 'MINST',
 weightWriteProperty: 'writeCost'
})
YIELD createMillis, computeMillis, writeMillis, effectiveNodeCount
RETURN createMillis, computeMillis, writeMillis, effectiveNodeCount;MATCH path = (n:PointOfInterest {name: 'Hongdae Korean BBQ'})-[:MINST*]-()
WITH relationships(path) AS rels
UNWIND rels AS rel
WITH DISTINCT rel AS rel
RETURN startNode(rel) AS source, endNode(rel) AS destination, rel.writeCost AS cost
0 REPLIES 0