mage icon indicating copy to clipboard operation
mage copied to clipboard

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

Open matea16 opened this issue 1 year ago • 0 comments

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

matea16 avatar Jan 25 '24 10:01 matea16