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.

Travelling salesman problem in Neo4j

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! 

0 REPLIES 0
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online