apoc.convert.toTree() does not consider duplicate edge labels
snj07 opened this issue · comments
The apoc.convert.toTree()
function currently does not take into account duplicate edge labels between the same source and target nodes when preparing a tree structure. This behavior leads to unexpected results when dealing with graphs containing duplicate relationships with different attributes.
Queries to reproduce:
#vertices
CREATE (v1:T1 {id: 'v21', name: 'Vertex 21', p2: 'value21'})
CREATE (v2:T1 {id: 'v22', name: 'Vertex 22', p2: 'value22'})
#edges
CREATE (v1)-[:L_1 {prop1: 'v21->v22 [1]', prop2: 'value1'}]->(v2)
CREATE (v1)-[:L_1 {prop1: 'v21->v22 [2]', prop2: 'value2'}]->(v2)
#path query
MATCH p1 = (n:T1 {id:'v21'})-[e1]->(m1:T1)
RETURN p1
#tree query
MATCH p1 = (n:T1 {id:'v21'})-[e1]->(m1:T1)
WITH COLLECT(p1) as paths
CALL apoc.convert.toTree(paths, false)
YIELD value
RETURN value;
Expected Behavior
To have a config to disable this behavior
Hi! thanks for the report. We have fixed this and it should be available in 4.4.0.26 and 5.18 :)