Guest User
Using app without sign in

Practice book
Graph Theory Through Problems300 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.
Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on AmazonSelect an algorithm and generate steps to begin visualization
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
Select an algorithm and generate steps to begin visualization
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.
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.
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.
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 runsEach 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.
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.
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.
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.
Diffusion models differ in how a vertex decides to adopt. The choice of model changes which seeds look best.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Linear threshold model | Adoption 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 model | Infected vertices stay infectious for some time and then recover, so repeated contacts matter. | O(V + E) per run |
| Greedy with CELF | You need the best k seeds. Lazy evaluation of marginal gains skips most recomputations. | much faster than plain greedy |
| Reverse influence sampling | Influence 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 heuristics | A quick seed choice without simulation. Often reasonable, but hubs in the same area overlap and waste seeds. | O(V + E) |
Read the full article: Applications of Graph Theory in the Real World
Read the full article: Graph Centrality Measures and PageRank
Related algorithms: Personalized PageRank, Breadth-First Search, Betweenness Centrality, Label Propagation