🌐

Networks & Graph Theory

The mathematics of connections: shortest paths, optimal tours, spanning trees, and viruses spreading across social graphs. Visualise algorithms one step at a time.

6 simulations Canvas 2D · WebGL Shortest Path · TSP · SIR

Category Simulations

Graphs, paths, flows and spreading processes

Graph theory underpins the modern world — routing packets across the Internet, mapping protein interactions, scheduling airline connections and modelling how information (or disease) spreads through a social network. Here you can interact with the core algorithms step by step.

🌐
★★★ Advanced New
TCP Congestion Control
The TCP congestion window in action: slow-start doubling, AIMD additive increase, multiplicative decrease on loss (Tahoe/Reno/CUBIC). Watch the cwnd sawtooth and a bottleneck buffer fill and drop.
TCPCongestion ControlAIMDCanvas 2D
🔗
★★★ Advanced
PageRank — How Google Ranked the Web
Google's original ranking algorithm: a page's score equals (1−d)/N plus d times inbound contributions. Watch power iteration converge — or simulate a random surfer hitting the same stationary distribution.
Canvas 2D PageRank Random Surfer Graph
📋
★★★ Advanced
Critical Path Method — CPM & PERT
Model a project as a DAG of tasks: forward and backward pass compute ES/EF/LS/LF and the slack; zero-slack tasks form the critical path. PERT adds 3-point estimates and P(T ≤ deadline).
Canvas 2D CPM PERT DAG
🌐
★★★ Advanced
Internet Routing — DV & Link-State
How routers find paths: distance-vector (Bellman–Ford/RIP) exchanges tables and can count to infinity, while link-state (Dijkstra/OSPF) floods the map. Cut a link and watch the network reconverge.
Canvas 2D Bellman-Ford Dijkstra Routing
🔵
★★★ Advanced
Community Detection — Louvain
Detect communities by greedily maximizing modularity with the Louvain method. Watch local node moves and community aggregation recover planted structure as Q rises.
Canvas 2D Modularity Community Detection Graph
📦
★★★ Advanced
Max-Flow / Min-Cut
Ford–Fulkerson (Edmonds–Karp) step by step: BFS finds augmenting paths, flow is pushed along the residual graph, then the minimum cut is revealed where max-flow = min-cut.
Canvas 2D Ford-Fulkerson Min Cut Graph Theory
🗺️
★★☆ Moderate
Pathfinding Algorithms
Interactive grid where you can paint walls, move start/goal, and compare A*, Dijkstra and BFS side by side — open and closed node sets shown live.
Canvas 2D A* Dijkstra BFS
✈️
★★☆ Moderate
Travelling Salesman Problem
Place cities and watch Nearest-Neighbour, 2-Opt, 3-Opt and simulated annealing compete for the shortest Hamiltonian tour across all nodes.
Canvas 2D TSP 2-Opt Annealing
🧬
★★☆ Moderate
Genetic Algorithm
Evolve solutions on a network-style fitness landscape using selection, crossover and mutation operators. Watch population fitness converge.
Canvas 2D GA Crossover Mutation
🦠
★☆☆ Beginner
Epidemic Spreading (SIR)
SIR / SEIR / SIS compartmental model with interactive β and γ sliders. Watch the infection curve flatten or explode depending on R₀ value.
Canvas 2D SIR ODE R₀
🔗
★★★ Advanced
Force-Directed Graph
Visualise arbitrary graphs with Fruchterman-Reingold spring simulation. Degree-coloured nodes, live degree-distribution chart.
Canvas 2D Force Layout Barabási-Albert
🌲
★★☆ Moderate
Minimum Spanning Tree
Kruskal's and Prim's algorithms animated on a weighted random graph. Toggle between algorithms; edge costs shown on arcs.
Canvas 2D Kruskal Prim
🕸️
★★☆ Moderate
Network Resilience
Barabási–Albert scale-free networks under targeted hub attack vs random failure — watch giant component collapse.
Force Layout Scale-Free Percolation Graph Theory
🌐
★★☆ Moderate New
Small-World Network
Watts-Strogatz rewiring: start from a regular ring lattice and gradually add random long-range links. Watch clustering coefficient stay high while average path length plummets — the hallmark of social networks, the brain and the internet.
Watts-Strogatz Clustering Path Length Canvas 2D
🌐
New ★★☆ Moderate
Network Science
Erdős–Rényi, Barabási–Albert scale-free and Watts–Strogatz small-world graphs with force-directed layout. Live degree distribution histogram, clustering coefficient and giant-component fraction update in real time.
Erdős–Rényi Barabási–Albert Force-Directed

Key Concepts

Core graph theory and network science ideas

Graph Representations
Adjacency matrix O(V²) storage, adjacency list O(V+E). Dense graphs favour matrix for O(1) edge lookup; sparse graphs favour lists for traversal. Weighted graphs add cost to each edge — fundamentals for every pathfinding algorithm.
Shortest Path (A*)
f(n) = g(n) + h(n): g is the exact cost from start, h is the heuristic estimate to goal. An admissible (never-overestimating) heuristic guarantees the optimal path. Dijkstra is A* with h=0. Bi-directional search and Jump Point Search speed up grids.
Network Centrality
Degree centrality counts edges per node. Betweenness centrality counts how many shortest paths pass through a node — critical hubs in transport and social networks. PageRank extends eigenvector centrality to directed weighted networks.
Spreading Processes
SIR model on a network: each infected node spreads to each susceptible neighbour with probability β per step. Recovery at rate γ. Basic reproduction number R₀ = β/γ × average degree. Herd immunity threshold 1 − 1/R₀.

Learning Resources

Articles and references about graph algorithms

About Networks & Graph Theory Simulations

Social networks, epidemic spread, random graphs, and connectivity — visualised

Networks and graph theory simulations model the structure and dynamics of interconnected systems. Network-growth simulations implement preferential attachment (the Barabási–Albert model) and show how hubs emerge naturally in real-world networks like the internet, social platforms, and airline routes. SIR epidemic simulations propagate infections across contact networks, demonstrating why highly-connected hubs are disproportionately important for disease control.

Community detection algorithms partition nodes into clusters using spectral methods and label propagation. Shortest-path visualisers run Dijkstra and BFS on weighted graphs with hundreds of nodes, animating the frontier expansion. These tools model the same graph-theory concepts underlying Google's PageRank, Facebook's friend recommendations, power-grid resilience analysis, and epidemiological contact tracing.

Network theory is one of the most cross-disciplinary sciences of the 21st century. The same mathematical frameworks describe the internet, metabolic networks, power grids, social relationships, and ecological food webs. Graph theory originated with Euler's 1736 solution to the Königsberg bridge problem and has since become essential to algorithm design, epidemiology, neuroscience, and the study of complex systems in virtually every domain.

Key Concepts

Topics and algorithms you'll explore in this category

Scale-Free NetworksBarabási-Albert preferential attachment model
Small-World NetworksWatts-Strogatz rewiring: short paths, high clustering
Percolation TheoryCritical connectivity threshold for network resilience
Centrality MeasuresDegree, betweenness, closeness, eigenvector centrality
Epidemic SpreadingSIR dynamics on network topology
Graph Spectral TheoryLaplacian eigenvalues and network properties

Frequently Asked Questions

Common questions about this simulation category

What makes a network scale-free?
A scale-free network follows a power-law degree distribution P(k) ~ k^(-γ). They form through preferential attachment: new nodes connect preferentially to already well-connected nodes ('the rich get richer'). The internet, citation networks, and social networks are all approximately scale-free. The Barabási-Albert simulation shows this growth process in real time.
What is the small-world phenomenon?
The small-world property means most node pairs are connected by a surprisingly short path (low average path length) while most nodes cluster locally (high clustering coefficient). The Watts-Strogatz model generates small-world networks by randomly rewiring a small fraction of a regular lattice's edges — you can watch the average path length collapse while clustering stays high.
How does disease spread on a network?
Network structure dramatically affects epidemic dynamics. Hub nodes (highly connected) are super-spreaders: targeting them with vaccination is far more efficient than random vaccination. The percolation threshold determines the minimum fraction of nodes that must be immunised to prevent a network-wide epidemic.
What is the difference between Dijkstra and A* pathfinding?
Dijkstra explores all directions uniformly from the start, guaranteeing the shortest path but visiting many unnecessary nodes. A* adds a heuristic estimate h(n) of the remaining distance to the goal, focusing the search and typically visiting far fewer nodes. Both are O((V + E) log V) with a priority queue, but A* is much faster in practice on grid maps. You can compare them side by side in the Pathfinding Algorithms simulation.

Other Categories