cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Creating subgraph by filtering on embeddings

skerr
Node Clone

Using Neo4J 4.3.2 Enterprise
Before creating a graph projection, I transformed several node categorical properties into embeddings using one-hot encoding. One of these node properties was n.tier consisting of several levels (gold, silver, red, etc., ). A sample from the in memory graph where i filter on a particular tier looks like:

MATCH (g:Guest) where g.tierEmbedding[1] = 1.0
RETURN g.tierEmbedding, g.tier limit 3

And this returns:

g.tierEmbedding	        g.tier
[0.0, 1.0, 0.0, 0.0, 0.0]	"Red"
[0.0, 1.0, 0.0, 0.0, 0.0]	"Red"
[0.0, 1.0, 0.0, 0.0, 0.0]	"Red"

Ensuring that the embeddings exist in the graph projection:

CALL gds.graph.streamNodeProperties('tableguests-complete', ['tierEmbedding'])

Results in (result is truncated):

nodeId	nodeProperty	propertyValue
0	"tierEmbedding"	[1.0, 0.0, 0.0, 0.0, 0.0]
1	"tierEmbedding"	[0.0, 1.0, 0.0, 0.0, 0.0]

All is good. Now from the graph projection, i want to create a subgraph of just "Red" Guests:

CALL gds.beta.graph.create.subgraph('tableguests-subgraph', 'tableguests-complete', 'n:Table OR (n:Guest AND n.tierEmbedding[1] = 1.0)', '*')
YIELD graphName, fromGraphName, nodeCount, relationshipCount

Gives the following error:

Failed to invoke procedure `gds.beta.graph.create.subgraph`: Caused by: java.lang.UnsupportedOperationException

Am i correct in assuming that the nodeFilter containing the n.tierEmbedding[1] = 1.0 is not allowed? This seems to be an appropriate cypher predicate for filtering nodes in the input graph.

2 REPLIES 2

A this point, graph.subgraph does not support filtering on list properties (only floats, integers, and booleans). I've added your post to our feature request backlog, and we'll let you know once list support is added!

Hi @alicia.frame1
Can we also please add filtering based on string properties ? Currently I get the same unsupported error when attempting to filter based on a string value.