CELF
This feature is in the beta tier. For more information on feature tiers, see Operations reference.
1. Introduction
The CELF algorithm for influence maximization aims to find k
nodes that maximize the expected spread of influence in the network.
It simulates the influence spread using the Independent Cascade model, which calculates the expected spread by taking the average spread over the mc
MonteCarlo simulations.
In the propagation process, a node is influenced in case that a uniform random draw is less than the probability p
.
Leskovec et al. 2007 introduced the CELF algorithm in their study Costeffective Outbreak Detection in Networks to deal with the NPhard problem of influence maximization. The CELF algorithm is based on a "lazyforward" optimization. Τhe CELF algorithm dramatically improves the efficiency of the Greedy algorithm and should be preferred for 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. 

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. 

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. 

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 
2512 
2512 
"2512 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?