Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-22-2020 07:17 AM
Good morning!
I have a request from a user to highlight the filtered nodes in the graph in a different color from the other nodes. To do this, I thought about changing the label of the filtered nodes in the graph view, in order to differentiate them from the others.
This is the Cypher query:
MATCH (n:PF) where n.CPF IN ["80091172500","91227712553"]
WITH collect(n) as nodes
UNWIND nodes as p1
MATCH (p1)-[rel_parentes:PARENTE_DE]-(parentes:PF)
RETURN p1, rel_parentes, parentes
The result is
Note that all nodes belong to the PF label, but I would like the nodes "80091172500" and "91227712553" to be visualized with a virtual label called "chosen" and the remaining nodes continue with the label PF. How can I do this?
07-25-2020 02:56 AM
you can use apoc to create a virtual node using something like
call apoc.create.vNode(["FakeLabel"],apoc.any.properties(p)) yield node
or depending on the version you can call
apoc.create.virtual.fromNode(mynode) yield node
but im not sure if you can then set the label of the virt node.
hope this helps or at least points you somewhere useful :0
07-27-2020 01:04 PM
Hi!
Thank you for your support!
I have tried to create a virtual node using apoc.create.vNode, but the virtual node was created without any relationship. I'd like to keep all relationships between the virtual and real nodes. I wrote a Cypher like that:
MATCH (n:PF) where n.CPF IN ["80091172500","91227712553"]
WITH collect(n) as nodes
UNWIND nodes as p1
MATCH (p1)-[rel_parentes:PARENTE_DE]-(parentes:PF)
CALL apoc.create.vNode(['CHOSEN'],{id:id(p1), CPF:p1.CPF}) yield node as v_p1
RETURN v_p1, rel_parentes, parentes, p1
The result was
In order to keep all relationships between the virtual and real nodes, I've tried to set manually the id property of the virtual node using id:id(p1) , but it didn't work.
Then I have tried to use apoc.create.virtual.fromNode but I wasn't able to set the label in the virtual node.
Is there a way to create the virtual node and keep the relationships between the virtual and real nodes?
07-31-2020 01:33 PM
You will have to also recreate the vRelationships 😕
All the sessions of the conference are now available online