memgraph / mage

MAGE - Memgraph Advanced Graph Extensions :crystal_ball:
Apache License 2.0
238 stars 23 forks source link

Add a function that parses a map of nodes and rel into a graph object #441

Open matea16 opened 5 months ago

matea16 commented 5 months ago

Currently, in order to pass an object as a subgraph argument to a procedure, it has to be a Graph type object which is only provided by the output of the project() function.

For the usability purposes, it would be useful to have a function that takes map of nodes and edges as an argument and parses them into a Graph type of object. For example, the following query works as expected:

MATCH p=(:Node)-[:RELATION]-(:Node)
WITH project(p) AS subgraph
CALL bridges.get(subgraph)
YIELD node_from, node_to
RETURN node_from, node_to;

but, the you can not pass the subgraph as an argument using this query:

CALL {
  MATCH (n:Node)
  RETURN n
  LIMIT 1
}
CALL path.subgraph_all(n, {}) YIELD nodes, rels
WITH {nodes: nodes, edges: rels} AS subgraph
CALL bridges.get(subgraph)
YIELD node_from, node_to
RETURN node_from, node_to;

Source from the community