Filtered Node Similarity

This algorithm is in the alpha tier. For more information on algorithm tiers, see Graph algorithms.

Supported algorithm traits:

1. Introduction

The Filtered Node Similarity algorithm is an extension to the Node Similarity algorithm. It adds support for filtering on source nodes, target nodes, or both.

2. Node filtering

A node filter reduces the node space for which the algorithm will produce results. Consider two similarity results: A = (alice)-[:SIMILAR_TO]→(bob) and B (bob)-[:SIMILAR_TO]→(alice). Result A will be produced if the (alice) node matches the source node filter and the (bob) node matches the target node filter If the (alice) node does not match the target node filter, or the (bob) node does not match the source node filter, result B will not be produce.

3. Configuring node filters

For the standard configuration of node similarity, see Node Similarity syntax.

The source node filter is specified with the sourceNodeFilter configuration parameter. The target node filter is specified with the targetNodeFilter configuration parameter. Neither parameter is mandatory.

The node filter parameters accept one of the following:

Table 1. Syntax for sourceNodeFilter and targetNodeFilter

a single node id

sourceNodeFilter: 42

a list of node ids

sourceNodeFilter: [23, 42, 87]

a single node

MATCH (person:Person) WITH person ORDER BY person.age DESC LIMIT 1 …​ sourceNodeFilter: n

a list of nodes

MATCH (person:Person) WHERE person.age > 35 collect(person) AS people …​ sourceNodeFilter: people

a single label

sourceNodeFilter: 'Person'