Search code examples
memgraphdb

How does one typically do subgraph isomorphism?


MAGE doesn’t seem to contain this algorithm. So I was wondering. Do I just build up a query that will match the subgraph(s) that I I am interested in?


Solution

  • MAGE does contain such an algorithm inside the nxalg module.

    Simple example is:

    MATCH (n:Label1)-[e]-(), (r:Label2)-[f]-()
    WITH
    COLLECT(n) AS nodes1
    COLLECT(e) AS edges1
    COLLECT(r) AS nodes2
    COLLECT(f) AS edges2
    CALL nxalg.is_isomorphic(nodes1, edges1, nodes2, edges2) YIELD *
    RETURN is_isomorphic;