Search code examples
memgraphdb

Can I expand all nodes in Memgraph lab?


My query returns quite large number of nodes, but I'd like to expand them anyway. Is there Expand all command in Memgraph Lab? I can't find one.

enter image description here


Solution

  • At the moment it is not possible to do that. You could click on each node and click "Expand" but that would take time and it is not efficient at all.

    A possible workaround is with Cypher. let's say you have a Cypher query that returns nodes and edges that are your base for the graph view, e.g.

    This is on a Pandora Papers dataset, a query to get people having connections to Qatar.

    MATCH path=(:Officer)-->(country:Country)
    WHERE country.iso_2_code = "QA"
    RETURN path;
    

    You can then just remove RETURN path and replace it with WITH path to get level 1 expand on all nodes.

    MATCH path=(:Officer)-->(country:Country)
    WHERE country.iso_2_code = "QA"
    WITH path
    MATCH (n)-[e]->(m)
    WHERE n IN nodes(path) OR m IN nodes(path)
    RETURN n, e, m;
    

    You can do the same if you are not having path in the first query, but n as node, e.g.

    MATCH (officer:Officer)-->(country:Country)
    WHERE country.iso_2_code = "QA"
    WITH collect(officer) + collect(country) as nodes
    MATCH (n)-[e]->(m)
    WHERE n IN nodes OR m IN nodes
    RETURN n, e, m;