cancel
Showing results for 
Search instead for 
Did you mean: 

Travelling salesman problem in Neo4j

__asia_
Node

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

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.