I currently imported a road map graph in Neo4j and I would like to execute some queries on it. There are crossroads, mapped as vertices and roads, mapped as relationships. Also, there are points of interest, which are mapped to a crossroad, using a relationship. Here is an example of the graph (not my picture but my graph looks similar): graph and my sample data: data

What I would like to be able to achieve is to find for a single crossroad the nearest neighbors from every POI category type (e.g. restaurant, coffee shop...). I tried using the shortest path algorithm (see below) but it runs for a very long time and I need to do this for every crossroad in the map (I have around 500 000):

```
MATCH (a:CROSSROAD)-[k:HAS_POI]->(o:POI {id: 10, type: "coffee_shop"})
MATCH (c:CROSSROAD)-[h:HAS_POI]->(p:POI {type: "restaurant"})
CALL algo.shortestPath(a, c, 'distance')
YIELD totalCost
RETURN p.id as POI, totalCost
ORDER BY totalCost
limit 1
```

Is there a better and faster way to do this?

I wonder if there is maybe a way to traverse from the node by taking the smallest distance on the ROAD relationship until a POI from the specific type is reached. Although I am not sure how to express this in Cypher language.

PS: I am quite new to Neo4j and Cypher and I am still learning, so excuse me if this is an obvious question.