0
votes

How do we find out paths in neo4j which will cover all the selected set of nodes.

This will be used for solving a tsp of sorts. to find path which covers all the given set of cities, later will sort on the basis of total distance covered by the path.

1
Check this related question - you might consider using an MST algorithm to find a path that touches everything; that's what they do. stackoverflow.com/questions/25609717/…FrobberOfBits

1 Answers

0
votes

You can find all paths between two nodes like this.

match p=(:startNode)-->(:endNode)
return p;

or you can try like

match p=(:startNode)-->(:endNode)
return nodes(p) as node, relationships(p) as  rels

You can get all paths like this

match p = ()-->()
return p
limit 100 // Apply limit according to nodes