Speaker-Listener Label Propagation
This feature is in the alpha tier. For more information on feature tiers, see API Tiers.
Glossary
- Directed
-
Directed trait. The algorithm is well-defined on a directed graph.
- Directed
-
Directed trait. The algorithm ignores the direction of the graph.
- Directed
-
Directed trait. The algorithm does not run on a directed graph.
- Undirected
-
Undirected trait. The algorithm is well-defined on an undirected graph.
- Undirected
-
Undirected trait. The algorithm ignores the undirectedness of the graph.
- Heterogeneous nodes
-
Heterogeneous nodes fully supported. The algorithm has the ability to distinguish between nodes of different types.
- Heterogeneous nodes
-
Heterogeneous nodes allowed. The algorithm treats all selected nodes similarly regardless of their label.
- Heterogeneous relationships
-
Heterogeneous relationships fully supported. The algorithm has the ability to distinguish between relationships of different types.
- Heterogeneous relationships
-
Heterogeneous relationships allowed. The algorithm treats all selected relationships similarly regardless of their type.
- Weighted relationships
-
Weighted trait. The algorithm supports a relationship property to be used as weight, specified via the relationshipWeightProperty configuration parameter.
- Weighted relationships
-
Weighted trait. The algorithm treats each relationship as equally important, discarding the value of any relationship weight.
Introduction
The Speaker-Listener Label Propagation Algorithm (SLLPA) is a variation of the Label Propagation algorithm that is able to detect multiple communities per node. The GDS implementation is based on the SLPA: Uncovering Overlapping Communities in Social Networks via A Speaker-listener Interaction Dynamic Process publication by Xie et al.
The algorithm is randomized in nature and will not produce deterministic results. To accommodate this, we recommend using a higher number of iterations.
Syntax
This section covers the syntax used to execute the SLLPA algorithm in each of its execution modes. We are describing the named graph variant of the syntax. To learn more about general syntax variants, see Syntax overview.
CALL gds.sllpa.stream(
graphName: String,
configuration: Map
)
YIELD
nodeId: Integer,
values: Map {
communtiyIds: List of Integer
}
Name | Type | Default | Optional | Description |
---|---|---|---|---|
graphName |
String |
|
no |
The name of a graph stored in the catalog. |
configuration |
Map |
|
yes |
Configuration for algorithm-specifics and/or graph filtering. |
Name | Type | Default | Optional | Description |
---|---|---|---|---|
List of String |
|
yes |
Filter the named graph using the given node labels. Nodes with any of the given labels will be included. |
|
List of String |
|
yes |
Filter the named graph using the given relationship types. Relationships with any of the given types will be included. |
|
Integer |
|
yes |
The number of concurrent threads used for running the algorithm. |
|
String |
|
yes |
An ID that can be provided to more easily track the algorithm’s progress. |
|
Boolean |
|
yes |
If disabled the progress percentage will not be logged. |
|
maxIterations |
Integer |
|
no |
Maximum number of iterations to run. |
minAssociationStrength |
String |
|
yes |
Minimum influence required for a community to retain a node. |
partitioning |
String |
|
yes |
The partitioning scheme used to divide the work between threads. Available options are |
Name | Type | Description |
---|---|---|
nodeId |
Integer |
Node ID. |
values |
Map |
A map that contains the key |
CALL gds.sllpa.stats(
graphName: String,
configuration: Map
)
YIELD
ranIterations: Integer,
didConverge: Boolean,
preProcessingMillis: Integer,
computeMillis: Integer,
configuration: Map
Name | Type | Default | Optional | Description |
---|---|---|---|---|
graphName |
String |
|
no |
The name of a graph stored in the catalog. |
configuration |
Map |
|
yes |
Configuration for algorithm-specifics and/or graph filtering. |
Name | Type | Default | Optional | Description |
---|---|---|---|---|
List of String |
|
yes |
Filter the named graph using the given node labels. Nodes with any of the given labels will be included. |
|
List of String |
|
yes |
Filter the named graph using the given relationship types. Relationships with any of the given types will be included. |
|
Integer |
|
yes |
The number of concurrent threads used for running the algorithm. |
|
String |
|
yes |
An ID that can be provided to more easily track the algorithm’s progress. |
|
Boolean |
|
yes |
If disabled the progress percentage will not be logged. |
|
maxIterations |
Integer |
|
no |
Maximum number of iterations to run. |
minAssociationStrength |
String |
|
yes |
Minimum influence required for a community to retain a node. |
partitioning |
String |
|
yes |
The partitioning scheme used to divide the work between threads. Available options are |
Name | Type | Description |
---|---|---|
ranIterations |
Integer |
Number of iterations run. |
didConverge |
Boolean |
Indicates if the algorithm converged. |
preProcessingMillis |
Integer |
Milliseconds for preprocessing the graph. |
computeMillis |
Integer |
Milliseconds for running the algorithm. |
configuration |
Map |
Configuration used for running the algorithm. |
CALL gds.sllpa.mutate(
graphName: String,
configuration: Map
)
YIELD
ranIterations: Integer,
didConverge: Boolean,
preProcessingMillis: Integer,
computeMillis: Integer,
mutateMillis: Integer,
nodePropertiesWritten: Integer,
configuration: Map
Name | Type | Default | Optional | Description |
---|---|---|---|---|
graphName |
String |
|
no |
The name of a graph stored in the catalog. |
configuration |
Map |
|
yes |
Configuration for algorithm-specifics and/or graph filtering. |
Name | Type | Default | Optional | Description |
---|---|---|---|---|
List of String |
|
yes |
Filter the named graph using the given node labels. |
|
List of String |
|
yes |
Filter the named graph using the given relationship types. |
|
Integer |
|
yes |
The number of concurrent threads used for running the algorithm. |
|
mutateProperty |
String |
|
yes |
The prefix used for all public properties in the PregelSchema. |
String |
|
yes |
An ID that can be provided to more easily track the algorithm’s progress. |
|
maxIterations |
Integer |
|
no |
Maximum number of iterations to run. |
minAssociationStrength |
String |
|
yes |
Minimum influence required for a community to retain a node. |
partitioning |
String |
|
yes |
The partitioning scheme used to divide the work between threads. Available options are |
Name | Type | Description |
---|---|---|
ranIterations |
Integer |
The number of iterations run. |
didConverge |
Boolean |
Indicates if the algorithm converged. |
preProcessingMillis |
Integer |
Milliseconds for preprocessing the graph. |
computeMillis |
Integer |
Milliseconds for running the algorithm. |
mutateMillis |
Integer |
Milliseconds for adding properties to the projected graph. |
nodePropertiesWritten |
Integer |
The number of properties that were written to Neo4j. |
configuration |
Map |
The configuration used for running the algorithm. |
CALL gds.sllpa.write(
graphName: String,
configuration: Map
)
YIELD
ranIterations: Integer,
didConverge: Boolean,
preProcessingMillis: Integer,
computeMillis: Integer,
writeMillis: Integer,
nodePropertiesWritten: Integer,
configuration: Map
Name | Type | Default | Optional | Description |
---|---|---|---|---|
graphName |
String |
|
no |
The name of a graph stored in the catalog. |
configuration |
Map |
|
yes |
Configuration for algorithm-specifics and/or graph filtering. |
Name | Type | Default | Optional | Description |
---|---|---|---|---|
List of String |
|
yes |
Filter the named graph using the given node labels. Nodes with any of the given labels will be included. |
|
List of String |
|
yes |
Filter the named graph using the given relationship types. Relationships with any of the given types will be included. |
|
Integer |
|
yes |
The number of concurrent threads used for running the algorithm. |
|
String |
|
yes |
An ID that can be provided to more easily track the algorithm’s progress. |
|
Boolean |
|
yes |
If disabled the progress percentage will not be logged. |
|
Integer |
|
yes |
The number of concurrent threads used for writing the result to Neo4j. |
|
writeProperty |
String |
|
yes |
The prefix used for all public properties in the PregelSchema. |
maxIterations |
Integer |
|
no |
Maximum number of iterations to run. |
minAssociationStrength |
String |
|
yes |
Minimum influence required for a community to retain a node. |
partitioning |
String |
|
yes |
The partitioning scheme used to divide the work between threads. Available options are |
Name | Type | Description |
---|---|---|
ranIterations |
Integer |
The number of iterations run. |
didConverge |
Boolean |
Indicates if the algorithm converged. |
preProcessingMillis |
Integer |
Milliseconds for preprocessing the graph. |
computeMillis |
Integer |
Milliseconds for running the algorithm. |
writeMillis |
Integer |
Milliseconds for writing result data back. |
nodePropertiesWritten |
Integer |
The number of properties that were written to Neo4j. |
configuration |
Map |
The configuration used for running the algorithm. |
Examples
All the examples below should be run in an empty database. The examples use Cypher projections as the norm. Native projections will be deprecated in a future release. |
In this section we will show examples of running the SLLPA algorithm on a concrete graph. The intention is to illustrate what the results look like and to provide a guide in how to make use of the algorithm in a real setting. We will do this on a small social network graph of a handful nodes connected in a particular pattern. The example graph looks like this:
CREATE
(a:Person {name: 'Alice'}),
(b:Person {name: 'Bob'}),
(c:Person {name: 'Carol'}),
(d:Person {name: 'Dave'}),
(e:Person {name: 'Eve'}),
(f:Person {name: 'Fredrick'}),
(g:Person {name: 'Gary'}),
(h:Person {name: 'Hilda'}),
(i:Person {name: 'Ichabod'}),
(j:Person {name: 'James'}),
(k:Person {name: 'Khalid'}),
(a)-[:KNOWS]->(b),
(a)-[:KNOWS]->(c),
(a)-[:KNOWS]->(d),
(b)-[:KNOWS]->(c),
(b)-[:KNOWS]->(d),
(c)-[:KNOWS]->(d),
(b)-[:KNOWS]->(e),
(e)-[:KNOWS]->(f),
(f)-[:KNOWS]->(g),
(g)-[:KNOWS]->(h),
(h)-[:KNOWS]->(i),
(h)-[:KNOWS]->(j),
(h)-[:KNOWS]->(k),
(i)-[:KNOWS]->(j),
(i)-[:KNOWS]->(k),
(j)-[:KNOWS]->(k);
In the example, we will use the SLLPA algorithm to find the communities in the graph.
MATCH (source:Person)-[r:KNOWS]->(target:Person)
RETURN gds.graph.project(
'myGraph',
source,
target,
{},
{ undirectedRelationshipTypes: ['*'] }
)
In the following examples we will demonstrate using the SLLPA algorithm on this graph.
Stream
In the stream
execution mode, the algorithm returns the community IDs for each node.
This allows us to inspect the results directly or post-process them in Cypher without any side effects.
For more details on the stream
mode in general, see Stream.
CALL gds.sllpa.stream('myGraph', {maxIterations: 100, minAssociationStrength: 0.1})
YIELD nodeId, values
RETURN gds.util.asNode(nodeId).name AS Name, values.communityIds AS communityIds
ORDER BY Name ASC
Name | communityIds |
---|---|
"Alice" |
[0] |
"Bob" |
[0] |
"Carol" |
[0] |
"Dave" |
[0] |
"Eve" |
[0, 1] |
"Fredrick" |
[0, 1] |
"Gary" |
[0, 1] |
"Hilda" |
[1] |
"Ichabod" |
[1] |
"James" |
[1] |
"Khalid" |
[1] |
Due to the randomness of the algorithm, the results will tend to vary between runs.