memgraphdb

How to convert a 1d array of country connections into a 2d array using cypher in Memgraph for k-means clustering?


I'm trying to use k-means clustering on a dataset where I have one kind of node, a country, and a list of connections between different countries. The connections are listed as a 1-dimensional array. How can I use Cypher in Memgraph to convert this into a 2-dimensional array for the nodes?


Solution

  • I assume that you are refering to returning of 2d array of connected countries.

    A simple

     MATCH (a:Country)-[r:REL]->(b:Country) RETURN a, b
    

    ā€‹ will return all connected countries, now you can apply different operators like unique and distinct to filter this further