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 Monte-Carlo 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 Cost-effective Outbreak Detection in Networks to deal with the NP-hard problem of influence maximization. The CELF algorithm is based on a "lazy-forward" optimization. Τhe CELF algorithm dramatically improves the efficiency of the Greedy algorithm and should be preferred for large networks.

2. Syntax

CELF syntax per mode
Run CELF in stream mode on a named graph.
CALL gds.beta.influenceMaximization.celf.stream(
  graphName: String,
  configuration: Map
)
YIELD
  nodeId: Integer,
  spread: Float
Table 1. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 2. Configuration
Name Type Default Optional Description

nodeLabels

List of String

['*']

yes

Filter the named graph using the given node labels.

relationshipTypes

List of String

['*']

yes

Filter the named graph using the given relationship types.

concurrency

Integer

4

yes

The number of concurrent threads used for running the algorithm.

jobId

String

Generated internally

yes

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

seedSetSize

Integer

n/a

no

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

monteCarloSimulations

Integer

100

yes

The number of Monte-Carlo simulations.

propagationProbability

Float

0.1

yes

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

randomSeed

integer

n/a

yes

The seed value to control the randomness of the algorithm.

Table 3. Results
Name Type Description

nodeId

Integer

Node ID.

spread

Float

The spread gained by selecting the node.

Run CELF in stats mode on a named graph.
CALL gds.beta.influenceMaximization.celf.stats(
  graphName: String,
  configuration: Map
)
YIELD
  computeMillis: Integer,
  totalSpread: Float,
  nodeCount: Integer,
  configuration: Map
Table 4. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 5. Configuration
Name Type Default Optional Description

nodeLabels

List of String

['*']

yes

Filter the named graph using the given node labels.

relationshipTypes

List of String

['*']

yes

Filter the named graph using the given relationship types.

concurrency

Integer

4

yes

The number of concurrent threads used for running the algorithm.

jobId

String

Generated internally

yes

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

seedSetSize

Integer

n/a

no

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

monteCarloSimulations

Integer

100

yes

The number of Monte-Carlo simulations.

propagationProbability

Float

0.1

yes

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

randomSeed

integer

n/a

yes

The seed value to control the randomness of the algorithm.

Table 6. Results
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.

Run CELF in mutate mode on a named graph.
CALL gds.beta.influenceMaximization.celf.mutate(
  graphName: String,
  configuration: Map
)
YIELD
  mutateMillis: Integer,
  nodePropertiesWritten: Integer,
  computeMillis: Integer,
  totalSpread: Float,
  nodeCount: Integer,
  configuration: Map
Table 7. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 8. Configuration
Name Type Default Optional Description

nodeLabels

List of String

['*']

yes

Filter the named graph using the given node labels.

relationshipTypes

List of String

['*']

yes

Filter the named graph using the given relationship types.

concurrency

Integer

4

yes

The number of concurrent threads used for running the algorithm.

jobId

String

Generated internally

yes

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

seedSetSize

Integer

n/a

no

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

monteCarloSimulations

Integer

100

yes

The number of Monte-Carlo simulations.

propagationProbability

Float

0.1

yes

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

randomSeed

integer

n/a

yes

The seed value to control the randomness of the algorithm.

Table 9. Results
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.

Run CELF in write mode on a named graph.
CALL gds.beta.influenceMaximization.celf.write(
  graphName: String,
  configuration: Map
)
YIELD
  writeMillis: Integer,
  nodePropertiesWritten: Integer,
  computeMillis: Integer,
  totalSpread: Float,
  nodeCount: Integer,
  configuration: Map
Table 10. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 11. Configuration
Name Type Default Optional Description

nodeLabels

List of String

['*']

yes

Filter the named graph using the given node labels.

relationshipTypes

List of String

['*']

yes

Filter the named graph using the given relationship types.

concurrency

Integer

4

yes

The number of concurrent threads used for running the algorithm.

jobId

String

Generated internally

yes

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

writeConcurrency

Integer

value of 'concurrency'

yes

The number of concurrent threads used for writing the result to Neo4j.

seedSetSize

Integer

n/a

no

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

monteCarloSimulations

Integer

100

yes

The number of Monte-Carlo simulations.

propagationProbability

Float

0.1

yes

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

randomSeed

integer

n/a

yes

The seed value to control the randomness of the algorithm.

Table 12. Results
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:

Visualization of the example graph
The following Cypher statement will create the example graph in the Neo4j database:
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);
The following statement will project the graph and store it in the graph catalog.
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.

The following will estimate the memory requirements for running the algorithm:
CALL gds.beta.influenceMaximization.celf.write.estimate('myGraph', {
  writeProperty: 'spread',
  seedSetSize: 3
})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, requiredMemory
Table 13. Results
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.

The following will run the algorithm in stats mode:
CALL gds.beta.influenceMaximization.celf.stats('myGraph', {seedSetSize: 3})
YIELD totalSpread
Table 14. Results
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 post-process them in Cypher without any side effects.

For more details on the stream mode in general, see Stream.

The following will run the algorithm, and stream results:
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
Table 15. Results
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.

The following will run the algorithm, and updates the graph with the mutateProperty:
CALL gds.beta.influenceMaximization.celf.mutate('myGraph', {
  mutateProperty: 'celfSpread',
  seedSetSize: 3
})
YIELD nodePropertiesWritten
Table 16. Results
nodePropertiesWritten

10

Stream the mutated node properties:
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
Table 17. Results
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 in-memory 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.

The following will run the algorithm, and stream results:
CALL gds.beta.influenceMaximization.celf.write('myGraph', {
  writeProperty: 'celfSpread',
  seedSetSize: 3
})
YIELD nodePropertiesWritten
Table 18. Results
nodePropertiesWritten

10

Query the written node properties:
MATCH (n) RETURN n.name AS name, n.celfSpread AS spread
ORDER BY spread DESC, name ASC
Table 19. Results
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.