neo4j / graph-data-science

Source code for the Neo4j Graph Data Science library of graph algorithms.
https://neo4j.com/docs/graph-data-science/current/
Other
596 stars 157 forks source link

[Feature Request] Ignore some labels in native projections #223

Closed Cobra5197 closed 1 year ago

Cobra5197 commented 1 year ago

Is your feature request related to a problem? Please describe. Neo4j allows nodes to have multiple labels. My problem is that I wanted to remove nodes from the projection that had a particular label in addition to another label. Example: I have Entity nodes but some are super nodes which I would like to remove from the projection, so I wrote a cypher query to find and set a label to these nodes.

Describe the solution you would like I would like to have for the native projection another configuration parameter which follow the same logic as nodeProjection parameter to ignore nodes that have certain labels.

Describe alternatives you have considered I am using Cypher projection but that is not optimized like native projection: MATCH (n:Entity) WHERE NOT n:Super RETURN id(n) AS id, labels(n) AS labels

Additional context Also, if this feature is developed, in write mode, the ignored nodes property should be set to null. For example, if in write mode I choose the _group as the property name as the result for the algorithm, the ignoreNodes should not have this property because they may have been in the projection before.

Regards, Cobra

vnickolov commented 1 year ago

@Cobra5197 thank you for raising this, we are going to look at it. In the meantime if this is blocking you, maybe you can invert the labels, what I mean is with the Cypher query that you use to set node label to Super you can probably set label NotSuper (or something that makes more sense in your domain) on the "normal" nodes and use that label for projection instead.

I hope this helps.

Cobra5197 commented 1 year ago

Thank you, it's a good idea :)

Mats-SX commented 1 year ago

Hello @Cobra5197

We have thought a bit about this feature and we have decided that we will not add it. Behind this decision are a few observations:

I hope this is an acceptable answer.

All the best Mats