dont use mage procedure
This commit is contained in:
parent
15c4bac87f
commit
81c93f6950
1 changed files with 18 additions and 21 deletions
|
|
@ -814,29 +814,26 @@ class MemgraphStorage(BaseGraphStorage):
|
||||||
subgraph_query = f"""
|
subgraph_query = f"""
|
||||||
MATCH (start:`{workspace_label}`)
|
MATCH (start:`{workspace_label}`)
|
||||||
WHERE start.entity_id = $entity_id
|
WHERE start.entity_id = $entity_id
|
||||||
WITH start
|
|
||||||
CALL path.subgraph_all(start, {{
|
MATCH path = (start)-[*BFS 0..{max_depth}]-(end:`{workspace_label}`)
|
||||||
relationshipFilter: [],
|
WHERE ALL(n IN nodes(path) WHERE '{workspace_label}' IN labels(n))
|
||||||
labelFilter: ['{workspace_label}'],
|
WITH collect(DISTINCT end) + start AS all_nodes_unlimited
|
||||||
minHops: 0,
|
|
||||||
maxHops: $max_depth
|
|
||||||
}})
|
|
||||||
YIELD nodes, rels
|
|
||||||
WITH
|
WITH
|
||||||
CASE
|
CASE
|
||||||
WHEN size(nodes) <= $max_nodes THEN nodes
|
WHEN size(all_nodes_unlimited) <= $max_nodes THEN all_nodes_unlimited
|
||||||
ELSE nodes[0..$max_nodes]
|
ELSE all_nodes_unlimited[0..$max_nodes]
|
||||||
END AS limited_nodes,
|
END AS limited_nodes,
|
||||||
rels,
|
size(all_nodes_unlimited) > $max_nodes AS is_truncated
|
||||||
size(nodes) > $max_nodes AS is_truncated
|
|
||||||
UNWIND rels AS rel
|
UNWIND limited_nodes AS n1
|
||||||
WITH limited_nodes, rel, is_truncated
|
UNWIND limited_nodes AS n2
|
||||||
WHERE startNode(rel) IN limited_nodes AND endNode(rel) IN limited_nodes
|
MATCH (n1)-[r]-(n2)
|
||||||
WITH limited_nodes, collect(DISTINCT rel) AS limited_relationships, is_truncated
|
WITH DISTINCT r, limited_nodes, is_truncated
|
||||||
|
|
||||||
RETURN
|
RETURN
|
||||||
[node IN limited_nodes | {{node: node}}] AS node_info,
|
[node IN limited_nodes | {{node: node}}] AS node_info,
|
||||||
limited_relationships AS relationships,
|
collect(DISTINCT r) AS relationships,
|
||||||
is_truncated
|
is_truncated
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result_set = None
|
result_set = None
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue