Hi there,
I am new to neo4j and would like to use it to answer the following question:
What is the shortest route in terms of distance in kilometres from "A-Town" to "Z-Town", where the tour should follow the alphabet using the first letters of the places crossed.
For this I have a dataset that contains the shortest routes between places followed by the first letter, i.e. routes between "A-Town" and all places starting with B, all routes from places with B to places with C, etc.
So with that I have created a graph that consists of
-
9153
Place
Nodes representing different places with aId
and aName
property -
around 3.2 Mio
PATH
relationships between these nodes with aDistance
property
I have tried the Dijkstra Shortest Path algorithm
MATCH (source:Place {Id: "1"}),
(target:Place {Id:"9153"})
CALL gds.shortestPath.dijkstra.stream(
'routes',
{
sourceNode:source,
targetNode:target,
relationshipWeightProperty:'Distance'
})
YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs, path
RETURN
index,
gds.util.asNode(sourceNode).Name AS sourceNodeName,
gds.util.asNode(targetNode).Name AS targetNodeName,
totalCost,
[nodeId IN nodeIds | gds.util.asNode(nodeId).Name] AS nodeNames,
costs,
nodes(path) as path
ORDER BY index
and some other algorithms, but I always just get the Warning Information
This query builds a cartesian product between disconnected patterns.
The warning makes sense, of course, since extremely many comparisons have to be queried.
Therefore now my question: What is the best way to proceed here, is there a suitable solution for this at all?
I would be very happy about any suggestions and help!