I want to solve travelling salesman problem/nearest neighbors using Neo4j Connector for Apache Spark. I have tried using Cypher query first but it takes forever to calculate the result. I have dataset that consist of 200 cities and relationships between them.
``
MATCH (from:Node {name: "Source node" })
MATCH path = (from)-[:CONNECTED_TO*]->()
WHERE ALL(n in nodes(path) WHERE 1 = length(filter(m in nodes(path) WHERE m = n)))
AND length(nodes(path)) = 200
RETURN path,
reduce(distance = 0, edge in relationships(path) | distance + edge.distance)
AS totalDistance
ORDER BY totalDistance ASC
LIMIT 1
How can I solve travelling salesman problem using Neo4j Connector for Apache Spark. Any help apprectiated. Thanks!