Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-15-2021 09:08 AM
I have a list which contains the information about the dependencies between nodes, for example [[node1, [node2, node3, node4]], [node2, [node 5, node6]] ...], which means node1 is dependent on node2, node3 and node4; node2 is dependent on node5 and node6.
From this list I want to create a virtual graph. The problems is when I UNWIND the list, it will create virtual nodes with same names multiple times. See my cypher codes below.
I did not find the way to check if a virtual node has been created or not.
My question is how to check the existence of a virtual node.
.....
UNWIND outputList AS dependency
WITH head(dependency) AS Data_Node, head(tail(dependency)) AS Dependent_Data_Nodes
CALL apoc.do.when(apoc.create.vNode(["DataNode"],{name:Data_Node})={},
'CALL apoc.cr eate.vNode(["DataNode"],{name:Data_Node}) yield node AS a',
'RETURN apoc.create.vNode(["DataNode"],{name:Data_Node}) AS a',
{Data_Node:Data_Node}
)
yield value
WITH value.a AS targetNode, Dependent_Data_Nodes
UNWIND Dependent_Data_Nodes AS Dependent_Data_Node
CALL apoc.do.when(apoc.create.vNode(["DataNode"],{name:Dependent_Data_Node})={},
'CALL apoc.create.vNode(["DataNode"],{name:Dependent_Data_Node}) yield node AS b',
'RETURN apoc.create.vNode(["DataNode"],{name:Dependent_Data_Node}) AS b',
{Dependent_Data_Node:Dependent_Data_Node}
)
yield value
WITH value.b AS startNode, targetNode
CALL apoc.create.vRelationship(startNode,"TRANSFORM_TO",{},targetNode) yield rel
RETURN *
All the sessions of the conference are now available online