CELF
This feature is in the beta tier. For more information on feature tiers, see API Tiers.
1. Introduction
The influence maximization problem asks for a set of k
nodes that maximize the expected spread of influence in the network.
The set of these initial k
is called the seed set
.
The Neo4j GDS Library supports approximate computation of the best seed set under the Independent Cascade propagation model.
In this propagation model, initially we assume that the nodes in the seed set become influenced and the process works as follows.
An influenced node influences each of its neighbors with probability p
.
The spread is then the number of nodes that become influenced.
The Neo4j GDS Library supports the CELF algorithm, introduced in 2007 by Leskovec et al. in Costeffective Outbreak Detection in Networks to compute a seed set with a large expected spread.
The CELF algorithm is based on the Greedy algorithm for the problem.
It works iteratively in k
steps to create the returned seed set S
,
where at each step the node yielding the maximum expected spread gain is added to S
.
The expected spread gain of a node u
not in S
is estimated by running mc
different Monte Carlo simulations of the propagation process and counting for each simulation the number of nodes that would become influenced if u
were to be added in S
.
The CELF algorithm extends on Greedy by introducing a lazy forwarding mechanism, which prunes a lot of nodes from being examined, thereby massively reducing the number of conducted simulations. This makes CELF much faster than Greedy on large networks.
2. Syntax
CALL gds.beta.influenceMaximization.celf.stream(
graphName: String,
configuration: Map
)
YIELD
nodeId: Integer,
spread: Float
Name  Type  Default  Optional  Description 

graphName 
String 

no 
The name of a graph stored in the catalog. 
configuration 
Map 

yes 
Configuration for algorithmspecifics 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. 

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. 

seedSetSize 
Integer 

no 
The number of nodes that maximize the expected spread in the network. 
monteCarloSimulations 
Integer 

yes 
The number of MonteCarlo simulations. 
propagationProbability 
Float 

yes 
The probability of a node being activated by an active neighbour node. 
randomSeed 
integer 

yes 
The seed value to control the randomness of the algorithm. 
Name  Type  Description 

nodeId 
Integer 
Node ID. 
spread 
Float 
The spread gained by selecting the node. 
CALL gds.beta.influenceMaximization.celf.stats(
graphName: String,
configuration: Map
)
YIELD
computeMillis: Integer,
totalSpread: Float,
nodeCount: 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 algorithmspecifics 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. 

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. 

seedSetSize 
Integer 

no 
The number of nodes that maximize the expected spread in the network. 
monteCarloSimulations 
Integer 

yes 
The number of MonteCarlo simulations. 
propagationProbability 
Float 

yes 
The probability of a node being activated by an active neighbour node. 
randomSeed 
integer 

yes 
The seed value to control the randomness of the algorithm. 
Name  Type  Description 

computeMillis 
Integer 
Milliseconds for running the algorithm. 
totalSpread 
Float 
The sum of individual seed set node spreads. 
nodeCount 
Integer 
Number of nodes in the graph. 
configuration 
Map 
The configuration used for running the algorithm. 
CALL gds.beta.influenceMaximization.celf.mutate(
graphName: String,
configuration: Map
)
YIELD
mutateMillis: Integer,
nodePropertiesWritten: Integer,
computeMillis: Integer,
totalSpread: Float,
nodeCount: 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 algorithmspecifics 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. 

String 

yes 
An ID that can be provided to more easily track the algorithm’s progress. 

seedSetSize 
Integer 

no 
The number of nodes that maximize the expected spread in the network. 
monteCarloSimulations 
Integer 

yes 
The number of MonteCarlo simulations. 
propagationProbability 
Float 

yes 
The probability of a node being activated by an active neighbour node. 
randomSeed 
integer 

yes 
The seed value to control the randomness of the algorithm. 
Name  Type  Description 

mutateMillis 
Integer 
Milliseconds for adding properties to the projected graph. 
nodePropertiesWritten 
Integer 
Number of properties added to the projected graph. 
computeMillis 
Integer 
Milliseconds for running the algorithm. 
totalSpread 
Float 
The sum of individual seed set node spreads. 
nodeCount 
Integer 
Number of nodes in the graph. 
configuration 
Map 
The configuration used for running the algorithm. 
CALL gds.beta.influenceMaximization.celf.write(
graphName: String,
configuration: Map
)
YIELD
writeMillis: Integer,
nodePropertiesWritten: Integer,
computeMillis: Integer,
totalSpread: Float,
nodeCount: 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 algorithmspecifics 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. 

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. 

seedSetSize 
Integer 

no 
The number of nodes that maximize the expected spread in the network. 
monteCarloSimulations 
Integer 

yes 
The number of MonteCarlo simulations. 
propagationProbability 
Float 

yes 
The probability of a node being activated by an active neighbour node. 
randomSeed 
integer 

yes 
The seed value to control the randomness of the algorithm. 
Name  Type  Description 

writeMillis 
Integer 
Milliseconds for adding properties to the projected graph. 
nodePropertiesWritten 
Integer 
Number of properties added to the Neo4j database. 
computeMillis 
Integer 
Milliseconds for running the algorithm. 
totalSpread 
Float 
The sum of individual seed set node spreads. 
nodeCount 
Integer 
Number of nodes in the graph. 
configuration 
Map 
The configuration used for running the algorithm. 
3. Examples
In this section we will show examples of running the CELF 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: 'Jimmy'}),
(b:Person {name: 'Jack'}),
(c:Person {name: 'Alice'}),
(d:Person {name: 'Ceri'}),
(e:Person {name: 'Mohammed'}),
(f:Person {name: 'Michael'}),
(g:Person {name: 'Ethan'}),
(h:Person {name: 'Lara'}),
(i:Person {name: 'Amir'}),
(j:Person {name: 'Willie'}),
(b)[:FRIEND_OF]>(c),
(c)[:FRIEND_OF]>(a),
(c)[:FRIEND_OF]>(g),
(c)[:FRIEND_OF]>(h),
(c)[:FRIEND_OF]>(i),
(c)[:FRIEND_OF]>(j),
(d)[:FRIEND_OF]>(g),
(f)[:FRIEND_OF]>(e),
(f)[:FRIEND_OF]>(g),
(g)[:FRIEND_OF]>(a),
(g)[:FRIEND_OF]>(b),
(g)[:FRIEND_OF]>(h),
(g)[:FRIEND_OF]>(e),
(h)[:FRIEND_OF]>(i);
CALL gds.graph.project(
'myGraph',
'Person',
'FRIEND_OF'
);
In the following examples we will demonstrate using the CELF algorithm on this graph.
3.1. Memory Estimation
First off, we will estimate the cost of running the algorithm using the estimate
procedure.
This can be done with any execution mode.
We will use the write
mode in this example.
Estimating the algorithm is useful to understand the memory impact that running the algorithm on your graph will have.
When you later actually run the algorithm in one of the execution modes the system will perform an estimation.
If the estimation shows that there is a very high probability of the execution going over its memory limitations, the execution is prohibited.
To read more about this, see Automatic estimation and execution blocking.
For more details on estimate
in general, see Memory Estimation.
CALL gds.beta.influenceMaximization.celf.write.estimate('myGraph', {
writeProperty: 'spread',
seedSetSize: 3
})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, requiredMemory
nodeCount  relationshipCount  bytesMin  bytesMax  requiredMemory 

10 
14 
2584 
2584 
"2584 Bytes" 
3.2. Stats
In the stats
execution mode, the algorithm returns a single row containing a summary of the algorithm result.
This execution mode does not have any side effects.
It can be useful for evaluating algorithm performance by inspecting the computeMillis
return item.
In the examples below we will omit returning the timings.
The full signature of the procedure can be found in the syntax section.
For more details on the stats
mode in general, see Stats.
CALL gds.beta.influenceMaximization.celf.stats('myGraph', {seedSetSize: 3})
YIELD totalSpread
totalSpread 

3.76 
Using stats
mode is useful to inspect how different configuration options affect the totalSpread
and choose ones that produce optimal spread.
3.3. Stream
In the stream
execution mode, the algorithm returns the spread for nodes that are part of the seed set.
This allows us to inspect the results directly or postprocess them in Cypher without any side effects.
For more details on the stream
mode in general, see Stream.
CALL gds.beta.influenceMaximization.celf.stream('myGraph', {seedSetSize: 3})
YIELD nodeId, spread
RETURN gds.util.asNode(nodeId).name AS name, spread
ORDER BY spread DESC, name ASC
name  spread 

"Alice" 
1.6 
"Ceri" 
1.08 
"Michael" 
1.08 
Note that in stream
mode the result is only the seed set computed by the algorithm.
The other nodes are not considered influential and are not included in the result.
3.4. Mutate
The mutate
execution mode extends the stats
mode with an important side effect: updating the named graph with a new influenceMaximization property containing the spread for that influenceMaximization.
The name of the new property is specified using the mandatory configuration parameter mutateProperty
.
The result is a single summary row, similar to stats
, but with some additional metrics.
The mutate
mode is especially useful when multiple algorithms are used in conjunction.
For more details on the mutate
mode in general, see Mutate.
CALL gds.beta.influenceMaximization.celf.mutate('myGraph', {
mutateProperty: 'celfSpread',
seedSetSize: 3
})
YIELD nodePropertiesWritten
nodePropertiesWritten 

10 
CALL gds.graph.nodeProperty.stream('myGraph', 'celfSpread')
YIELD nodeId, propertyValue
RETURN gds.util.asNode(nodeId).name as name, propertyValue AS spread
ORDER BY spread DESC, name ASC
name  spread 

"Alice" 
1.6 
"Ceri" 
1.08 
"Michael" 
1.08 
"Amir" 
0 
"Ethan" 
0 
"Jack" 
0 
"Jimmy" 
0 
"Lara" 
0 
"Mohammed" 
0 
"Willie" 
0 
Note that in mutate
all nodes in the inmemory graph get the spread
property.
The nodes that are not considered influential by the algorithm receive value of zero.
3.5. Write
The write
execution mode extends the stats
mode with an important side effect: writing the spread for each influenceMaximization as a property to the Neo4j database.
The name of the new property is specified using the mandatory configuration parameter writeProperty
.
The result is a single summary row, similar to stats
, but with some additional metrics.
The write
mode enables directly persisting the results to the database.
For more details on the write
mode in general, see Write.
CALL gds.beta.influenceMaximization.celf.write('myGraph', {
writeProperty: 'celfSpread',
seedSetSize: 3
})
YIELD nodePropertiesWritten
nodePropertiesWritten 

10 
MATCH (n) RETURN n.name AS name, n.celfSpread AS spread
ORDER BY spread DESC, name ASC
name  spread 

"Alice" 
1.6 
"Ceri" 
1.08 
"Michael" 
1.08 
"Amir" 
0 
"Ethan" 
0 
"Jack" 
0 
"Jimmy" 
0 
"Lara" 
0 
"Mohammed" 
0 
"Willie" 
0 
Note that in write
all nodes in Neo4j graph projected get the spread
property.
The nodes that are not considered influential by the algorithm receive value of zero.
Was this page helpful?