Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-22-2022 07:28 AM
Hello, can you please help me understand the correct query of deleting specific group of nodes inside a graph,
I want to be able to delete only this: CellType(blue) and the function(red) that is connected to it, and the variables(light green) without deleting the whole graph, for example I want to delete at first the group that i've marked in 1 and only her, and after for example i want to delete the group i've marked in 2 ,but without deleting the whole graph they connect to. is there an elegant and generic way to do it?:)
Solved! Go to Solution.
07-23-2022 08:05 PM
try this:
match (n:Function)
where id(n) in [156, 163]
match (n)--(m)
detach delete n, m
07-22-2022 08:21 AM
From the look of the graph data, you can match on the function node (red) and delete it and its immediate neighboring nodes.
match (n:Function{id: 0})
match (n)--(m)
detach delete n, m
07-23-2022 12:40 AM
Hello,
this query doesn't work for some reason, any other idea? or maybe the syntax not correct?
Vera.
07-23-2022 03:20 AM
I assume you changed the ‘id’ property condition to a property and value that identifies the ‘function’ node you want to delete. If you don’t have a unique identifier, you can use the neo4j id.
what doesn’t work about it? Can you provide some details?
do you have a small script I can use to generate the data for testing?
07-23-2022 10:13 AM
The data of the current graph looks like this:
n | |
---|---|
1
|
{ "identity": 149, "labels": [ "Variable" ], "properties": { "variableName": "x" } } |
2
|
{ "identity": 150, "labels": [ "Function" ], "properties": { "expression": "x" } } |
3
|
{ "identity": 151, "labels": [ "CellType" ], "properties": { "name": "inputCell", "transformType": "INPUT_TO_ANALOG" } } |
4
|
{ "identity": 152, "labels": [ "CellInstance" ], "properties": { "yCoordinate": 2.7, "xCoordinate": 2.6 } } |
5
|
{ "identity": 153, "labels": [ "CellInstance" ], "properties": { "yCoordinate": 2.7, "xCoordinate": 2.6 } } |
6
|
{ "identity": 154, "labels": [ "Variable" ], "properties": { "variableName": "x" } } |
7
|
{ "identity": 155, "labels": [ "Variable" ], "properties": { "variableName": "y" } } |
8
|
{ "identity": 156, "labels": [ "Function" ], "properties": { "expression": "x+y" } } |
9
|
{ "identity": 157, "labels": [ "CellType" ], "properties": { "name": "addition", "transformType": "ANALOG_TO_ANALOG" } } |
10
|
{ "identity": 158, "labels": [ "CellInstance" ], "properties": { "yCoordinate": 2.7, "xCoordinate": 2.6 } } |
11
|
{ "identity": 159, "labels": [ "Connection" ], "properties": { "delay": 0 } } |
12
|
{ "identity": 160, "labels": [ "Connection" ], "properties": { "delay": 0 } } |
13
|
{ "identity": 161, "labels": [ "Variable" ], "properties": { "variableName": "x" } } |
14
|
{ "identity": 162, "labels": [ "Variable" ], "properties": { "variableName": "y" } } |
15
|
{ "identity": 163, "labels": [ "Function" ], "properties": { "expression": "x+y" } } |
16
|
{ "identity": 164, "labels": [ "CellType" ], "properties": { "name": "addition", "transformType": "ANALOG_TO_ANALOG" } } |
17
|
{ "identity": 165, "labels": [ "CellInstance" ], "properties": { "yCoordinate": 2.7, "xCoordinate": 2.6 } } |
07-23-2022 08:05 PM
try this:
match (n:Function)
where id(n) in [156, 163]
match (n)--(m)
detach delete n, m
All the sessions of the conference are now available online