Search code examples
memgraphdb

In which form Memgraph supports graph projection?


As a part of the project, I need to project some subgraphs from the main graph. However, I'm unclear about the mechanisms Memgraph provides to support graph projection. I need to isolate a certain part of the graph. I've taken a look at similar question and I've read the blog post at https://memgraph.com/blog/how-we-designed-and-implemented-graph-projection-feature but I didn't find any info on isolation.


Solution

  • Memgraph supports graph projection using the project() function (as explained in blog post that you have linked). You can use it to construct a subgraph out of the generated paths:

    MATCH p=(n)-[r]->(m)  
    WITH project(p) AS subgraph  
    RETURN subgraph;
    

    To isolate a certain part of the graph, you can add constraints to labels, edge types, or properties:

    MATCH p=(n:SpecificLabel)-[r:REL_TYPE]->(m:SpecificLabel)  
    WITH project(p) AS subgraph  
    RETURN subgraph;
    

    This query will return a subgraph of SpecificLabel nodes connected with the relationships of type REL_TYPE.