neo4j use a distance function to determine distance between houses

This should give you the distances, ordered by house values:

MATCH (h1: House), (h2: House)
WHERE h1 <> h2
RETURN
  h1, h2,
  round(distance(
    point({longitude: h1.houseLong, latitude: h1.houseLat}),
    point({longitude: h2.houseLong, latitude: h2.houseLat}))) AS dist
ORDER BY h1.house, h2.house

NOTE: Every pair of houses will be represented twice (in reverse order), which is apparently what you wanted.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top