learngraphtheory.org

Guest User

Using app without sign in

Cover of the book Graph Theory Through Problems

Practice book

Graph Theory Through Problems

300 Exercises with Hints, Worked Algorithms and Complete Solutions

By Mohammed Islam Hadjoudj

Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.

Available inKindlePaperback

13 chapters

Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on Amazon
Algorithm Selection

Select an algorithm and generate steps to begin visualization

Independent Cascade Simulator

How far will it spread from here?

How a rumour, a product or an infection spreads from the start vertex: each newly active vertex tries each link once, then 2000 runs estimate who is reached

Time: O(V + E) per run
Space: O(V)
Use Case: Viral marketing, epidemics, misinformation, cascading failures
Showing the example graph for this algorithm.
Algorithm Execution

Select an algorithm and generate steps to begin visualization

About Independent Cascade (Spread)

The independent cascade model describes how something spreads through a network: a rumour, a new product, a piece of news or an infection. It starts at a seed vertex. Every vertex that becomes active gets one chance to pass it on to each neighbour that is not active yet, and succeeds with the probability of that link. Jacob Goldenberg, Barak Libai and Eitan Muller introduced it in 2001 for word-of-mouth marketing, and David Kempe, Jon Kleinberg and Éva Tardos made it the standard model of influence spread in 2003. In epidemiology it is the SIR model with an infection that lasts one round.

How it works

The cascade runs in rounds. In round 1 the seed tries each of its links: for every link a random number between 0 and 1 is drawn, and if it is below the link's probability the neighbour becomes active. In the next round only the vertices activated in the round before try their links, once each, and a link that failed is never tried again. The cascade stops when a round activates no one. One run is a single random story, so the page repeats the cascade 2000 times and reports each vertex's chance of being reached and the expected number of vertices reached. Computing these chances exactly is #P-hard, which is why simulation is the standard method.

Applications

Marketers use the model for influence maximization: choosing the few customers who will start the largest cascade, a problem Kempe, Kleinberg and Tardos solved approximately with a greedy algorithm. Epidemiologists use it to estimate how far an outbreak can travel through a contact network and whom to vaccinate first. It also models the spread of news and misinformation on social media, failures cascading through power grids and financial networks, and malware moving between computers.

Pseudocode

The independent cascade model describes how something spreads through a network: a rumour, a product or an infection. Each newly activated vertex gets exactly one chance to activate each inactive neighbour, succeeding with the probability on the edge.

IndependentCascade(graph, seed):
    active = {seed},  newest = {seed}
    while newest is not empty:
        next = {}
        for each u in newest:
            for each inactive neighbor v of u:
                with probability p(u, v):
                    add v to active and to next
        newest = next
    return active

Spread(seed, R):   // expected reach
    return the average size of IndependentCascade(seed) over R runs

Each edge is tried at most once, in the round after its first endpoint becomes active, and the attempts are independent. That is what makes the model tractable: the outcome of a run is the same as first deciding at random which edges are live, with their probabilities, and then taking everything reachable from the seed through live edges.

Worked example, step by step

Spread a rumour from A on the example this page loads. The visualizer replays one run with fixed random numbers, then estimates the expected reach from 2000 runs.

Example graph: Undirected friendships with pass-on probabilities: A-B 0.8, A-C 0.5, B-C 0.3, B-D 0.6, B-E 0.4, C-E 0.6, C-F 0.7, D-G 0.5, E-G 0.3, E-H 0.5, F-H 0.4, G-I 0.6 and H-I 0.2. Nine people in all.

  1. Round 1. A tries B and draws 0.49, below 0.8, so B is convinced. A tries C and draws 0.91, above 0.5, so C is not. A never gets another chance with C.
  2. Round 2. B tries its inactive friends: C succeeds with 0.18 below 0.3, D with a draw close to 0 below 0.6, and E with 0.29 below 0.4. C is reached after all, through B.
  3. Round 3. C, D and E were all activated in round 2, so none of them tries the others. C reaches F with 0.51 below 0.7. D fails with G (0.63 against 0.5), and E fails with G too (0.87 against 0.3) but reaches H (0.13 below 0.5).
  4. Round 4. F has no inactive friends left, since C and H are both active. H tries I and fails with 0.71 against 0.2. Nobody new was activated, so the cascade dies out.
  5. Many runs. This run reached 7 of the 9 people, all but G and I. Over 2000 runs from A the average reach is 5.41, so this particular run was a lucky one.

A single cascade is a random event, and its size can vary from 1, if A convinces nobody, to all 9. What the model predicts is the expected spread, 5.41 people for seed A, and the probability that each person is reached. Those are the quantities used to compare seeds, to choose whom to target in a campaign, or whom to protect in an epidemic.

Complexity, and where it comes from

Time: O(V + E) per run, O(R (V + E)) for the expected spread · Space: O(V)

One simulation activates each vertex at most once and tries each edge at most once, so it costs O(V + E). Computing the expected spread exactly is #P-hard, as Chen, Wang and Wang showed in 2010, so it is estimated by averaging R runs, and the error shrinks like 1 over the square root of R. Choosing the best k seeds, the influence maximisation problem, is NP-hard. Because the expected spread is monotone and submodular, the greedy algorithm that adds the seed with the largest marginal gain is guaranteed to reach at least 1 - 1/e, about 63 percent, of the optimum, at a cost of O(k n R (V + E)) without further tricks.

When to use Independent Cascade (Spread), and when not to

Diffusion models differ in how a vertex decides to adopt. The choice of model changes which seeds look best.

AlternativePrefer it whenCost
Linear threshold modelAdoption depends on the combined pressure of many neighbours, as with costly products or behaviours, rather than on single contacts.O(V + E) per run
SIR epidemic modelInfected vertices stay infectious for some time and then recover, so repeated contacts matter.O(V + E) per run
Greedy with CELFYou need the best k seeds. Lazy evaluation of marginal gains skips most recomputations.much faster than plain greedy
Reverse influence samplingInfluence maximisation on graphs with millions of vertices, with the same 1 - 1/e guarantee in near-linear time.near O((V + E) k log V)
Degree or PageRank heuristicsA quick seed choice without simulation. Often reasonable, but hubs in the same area overlap and waste seeds.O(V + E)

Common pitfalls

  • Treating one run as the prediction. One cascade is one sample. In the example a single run reached 7 people while the average is 5.41. Report the average over many runs, and its spread, not a single simulation.
  • Letting an edge try more than once. In this model each edge gets exactly one attempt. Allowing a vertex to keep trying in later rounds turns it into a different model, closer to SI epidemics, with much larger spread.
  • Choosing seeds by degree alone. The highest degree vertices are often neighbours of each other, so their cascades overlap. The greedy method accounts for overlap through marginal gains.
  • Guessing the probabilities. Results are very sensitive to the edge probabilities, which in real networks must be estimated from observed cascades. Small systematic errors in them shift which seeds look best.

Frequently asked questions

What is the independent cascade model?
It is a model of information or influence spreading in a network, formalised by Kempe, Kleinberg and Tardos in 2003. A seed set starts active, and each newly activated vertex gets one independent chance to activate each inactive neighbour, with the probability attached to the edge.
What is influence maximisation?
The problem of choosing k seed vertices that maximise the expected number of vertices reached by the cascade. It is NP-hard, but the expected spread is submodular, so the greedy algorithm achieves at least 1 - 1/e of the optimal spread.
Why is the expected spread estimated by simulation?
Computing it exactly is #P-hard under the independent cascade model, because it amounts to a probability over exponentially many live-edge graphs. Averaging a few thousand simulated cascades gives an accurate estimate instead.
What is the difference between the independent cascade and linear threshold models?
In the independent cascade model each active neighbour has its own independent chance to convince a vertex. In the linear threshold model a vertex becomes active only when the total weight of its active neighbours exceeds a personal threshold, so influence accumulates.
Where is the independent cascade model used?
In viral marketing to choose whom to give free samples, in epidemiology to study outbreaks and target vaccination, in tracking the spread of misinformation, and in studying how innovations and opinions move through social networks.

Related algorithms: Personalized PageRank, Breadth-First Search, Betweenness Centrality, Label Propagation

Interactive Controls

Zoom Controls

33%
Nodes: 9
Edges: 13