Node Similarity

Table 1. Changes in Configuration
Graph Algorithms v3.5 Graph Data Science v1.0

direction

-

concurrency

concurrency

readConcurrency

readConcurrency [1]

writeConcurrency

writeConcurrency [2]

topK

topK

bottomK

bottomK

topN

topN

bottomN

bottomN

similarityCutoff

similarityCutoff

degreeCutoff

degreeCutoff

writeProperty

writeProperty [2]

writeRelationshipType

writeRelationshipType [2]

write

-

graph

-

1. Only when using anonymous graph

2. Only for write mode

Table 2. Changes in YIELD fields
Graph Algorithms v3.5 Graph Data Science v1.0

loadMillis

createMillis

computeMillis

computeMillis

writeMillis

writeMillis

postProcessingMillis

postProcessingMillis

node1

node1 [3]

node2

node2 [3]

similarity

similarity [3]

nodesCompared

nodesCompared [4]

relationships

relationshipsWritten [4]

write

-

-

similarityDistribution

-

configuration [5]

writeProperty [6]

-

writeRelationshipType [6]

-

min, max, mean, p50, p75, p90, p95, p99, p999 [7]

-

3. Only for stream mode

4. Only for write mode

5. The configuration used to run the algorithm

6. Inlined into configuration

7. Inlined into similarityDistribution

Table 3. Node Similarity Stream Mode
Graph Algorithms v3.5 Graph Data Science v1.0

Minimalistic streaming over named graph:

CALL algo.nodeSimilarity.stream(null, null, {graph: 'myGraph'})
YIELD node1, node2, similarity
CALL gds.nodeSimilarity.stream('myGraph')
YIELD node1, node2, similarity

Streaming over named graph using topK and similarityCutoff configuration properties:

CALL algo.nodeSimilarity.stream(
  null,
  null,
  {
    graph: 'myGraph',
    topK: 1,
    similarityCutoff: 0.5
  }
)
CALL gds.nodeSimilarity.stream(
  'myGraph',
  {
    topK: 1,
    similarityCutoff: 0.5
  }
)

Streaming over named graph using bottomK configuration property:

CALL algo.nodeSimilarity.stream(
  null,
  null,
  {
    graph: 'myGraph',
    bottomK: 15
  }
)
CALL gds.nodeSimilarity.stream(
  'myGraph',
  {
    bottomK: 15
  }
)

Minimalistic streaming over anonymous graph:

CALL algo.nodeSimilarity.stream(
  'MyLabel',
  'MY_RELATIONSHIP_TYPE'
)
CALL gds.nodeSimilarity.stream({
  nodeProjection: 'MyLabel',
  relationshipProjection: 'MY_RELATIONSHIP_TYPE'
})

Streaming over anonymous graph using REVERSE relationship projection:

CALL algo.nodeSimilarity.stream(
  'MyLabel',
  'MY_RELATIONSHIP_TYPE',
  { direction: 'INCOMING' }
)
CALL gds.nodeSimilarity.stream({
  nodeProjection: 'MyLabel',
  relationshipProjection: {
    MY_RELATIONSHIP_TYPE: {
      orientation: 'REVERSE'
    }
  }
})

Streaming over anonymous graph using two way relationships [1]:


1. Not algorithm specific. This is also possible with named graphs. The graph has to be created with two relationship projections - one for each direction
CALL algo.nodeSimilarity.stream(
  'MyLabel',
  'MY_RELATIONSHIP_TYPE',
  { direction: 'BOTH' }
)
CALL gds.nodeSimilarity.stream({
  nodeProjection: 'MyLabel',
  relationshipProjection: {
    MY_RELATIONSHIP_TYPE_NATURAL: {
      type: 'MY_RELATIONSHIP_TYPE',
      orientation: 'NATURAL'
    },
    MY_RELATIONSHIP_TYPE_REVERSE: {
      type: 'MY_RELATIONSHIP_TYPE',
      orientation: 'REVERSE'
    }
  }
})

8. Not algorithm specific. This is also possible with named graphs. The graph has to be created with two relationship projections - one for each direction

Table 4. Node Similarity Write Mode
Graph Algorithms v3.5 Graph Data Science v1.0

Minimalistic write with writeRelationshipType and writeProperty:

CALL algo.nodeSimilarity(
  null,
  null,
  {
    graph: 'myGraph',
    writeRelationshipType: 'MY_WRITE_REL_TYPE',
    writeProperty: 'myWriteProperty',
    write: true
  }
)
YIELD
  nodesCompared,
  relationships,
  writeMillis,
  iterations,
  p1,
  writeProperty
CALL gds.nodeSimilarity.write(
  'myGraph',
  {
    writeRelationshipType: 'MY_WRITE_REL_TYPE',
    writeProperty: 'myWriteProperty'
  }
)
YIELD
  nodesCompared,
  relationships,
  writeMillis,
  ranIterations,
  similarityDistribution AS sd,
  configuration AS conf
RETURN
  nodesCompared,
  relationships,
  writeMillis,
  ranIterations,
  sd.p1 AS p1,
  conf.writeProperty AS writeProperty

Memory estimation of the algorithm:

CALL algo.memrec(
  'MyLabel',
  'MY_RELATIONSHIP_TYPE',
  'nodeSimilarity',
  {
    writeRelationshipType: 'MY_WRITE_REL_TYPE',
    writeProperty: 'myWriteProperty',
    write: true
  }
)
CALL gds.nodeSimilarity.write.estimate(
  {
    nodeProjection: 'MyLabel',
    relationshipProjection: 'MY_RELATIONSHIP_TYPE',
    writeRelationshipType: 'MY_WRITE_REL_TYPE',
    writeProperty: 'myWriteProperty'
  }
)