HomeInternet & NetworksNetwork Topology Generator: Random Graphs & Small Worlds

🕸️ Network Topology Generator: Random Graphs & Small Worlds

Generate real Erdős-Rényi, Watts-Strogatz and Barabási-Albert graphs, watch a live force-directed 3D layout settle, and measure real clustering, path length and degree distribution.

Internet & Networks2DAdvanced60 FPS
network-topology-generator ↗ Open standalone

About Random-Graph Models

Not every graph with the same number of nodes and edges looks — or behaves — the same. The Erdős–Rényi model includes every possible edge independently at random, producing degrees that cluster tightly around the average with no real structure. The Watts–Strogatz model starts from a ring lattice and rewires a small fraction of edges, which is enough to collapse the average path length while barely disturbing the ring's high local clustering — the genuine, measurable "small-world" effect behind the "six degrees of separation" idea. The Barabási–Albert model grows the graph one node at a time, with new nodes preferentially attaching to already well-connected ones, which produces a real power-law degree distribution with a handful of dominant hubs.

This simulation genuinely builds all three graphs from their real construction rules — nothing here is pre-drawn. Pick a model, tune its parameters, and watch a real physics-based force-directed layout (nodes repel each other, connected nodes attract) settle into a readable 3D shape as it iterates. The live stats panel runs a real local-triangle-density clustering-coefficient calculation and a real BFS-based shortest-path calculation on whatever graph is currently on screen, so you can directly verify the claims: BA's hub nodes are visibly larger and the max-degree stat spikes, while WS holds high clustering and a short average path length at the same time that ER never does.

Frequently Asked Questions

What is an Erdős–Rényi random graph?

In the Erdős–Rényi G(n,p) model, every one of the N(N−1)/2 possible edges between N nodes is included independently with probability p. The resulting degree distribution is binomial, well approximated by a Poisson distribution for large N — most nodes have a degree close to the average, and none stand out as structurally special hubs. It's the natural mathematical baseline against which more realistic network models are compared.

What is the Watts–Strogatz small-world model and why is it special?

Watts and Strogatz (1998) start with a ring lattice where each node connects to its k nearest neighbors — a highly clustered but slow-to-traverse structure — then rewire each edge to a random target with probability β. Even a small β introduces a few long-range "shortcuts" that collapse the average shortest-path length toward the small value typical of a random graph, while the clustering coefficient barely drops from the ring's high value. That combination — high clustering plus short paths — is the real, measurable small-world effect.

What is Barabási–Albert preferential attachment and why does it create hubs?

The Barabási–Albert model (1999) grows a graph node by node: each new node makes m connections, and the probability of connecting to an existing node is proportional to that node's current degree — "the rich get richer." Nodes that happen to gain a few extra early connections become disproportionately more likely to gain future ones, producing a small number of very high-degree hub nodes alongside many low-degree nodes, rather than the narrow degree spread seen in Erdős–Rényi graphs.

What is "six degrees of separation" and is it really observed in real networks?

"Six degrees of separation" is the popular name for the empirical observation — going back to Stanley Milgram's 1960s small-world experiments and later confirmed at internet scale (e.g. Microsoft Messenger and Facebook studies finding average distances around 5–6) — that most pairs of people in a huge social network are connected by a surprisingly short chain of acquaintances. It's exactly what the Watts–Strogatz model reproduces mathematically: a network can be enormous and still have a tiny average shortest-path length once a few long-range shortcuts exist.

What is a power-law degree distribution and how do you recognize one?

A power-law degree distribution means the fraction of nodes with degree k falls off as roughly k⁻ᵞ rather than clustering around a mean — so while most nodes have very few connections, a small but non-negligible number have very many, with no natural "typical" scale (hence "scale-free"). In this simulation's histogram it shows up as a long, thin tail stretching out toward the max-degree stat for Barabási–Albert graphs, in sharp visual contrast to the narrow, bell-shaped histograms produced by Erdős–Rényi or Watts–Strogatz.

Why are real-world networks better modeled by small-world or scale-free models than a uniform random graph?

Measured internet AS-level topology, the web's hyperlink graph, and most social networks all show both high clustering and short average path lengths together with heavy-tailed, often power-law-like degree distributions — properties an Erdős–Rényi graph with the same node and edge count essentially cannot produce, because independence washes out both clustering and hub structure. Small-world and scale-free generative models were specifically developed because they reproduce these measured statistical signatures, not just the raw node and edge counts.

Why are scale-free networks resilient to random failures but vulnerable to targeted attacks?

This is a well-documented, published network-science result (Albert, Jeong & Barabási, 2000): because most nodes in a scale-free network have low degree, removing nodes at random overwhelmingly hits low-degree nodes and barely dents overall connectivity. But removing the handful of high-degree hubs — the same nodes this simulation visibly enlarges for Barabási–Albert graphs — fragments the network far faster than removing random nodes would, which is exactly why hub nodes (major internet routers, key social-network accounts) are both the internet's greatest strength against random outages and its clearest structural vulnerability against deliberate, targeted attack.

What is the clustering coefficient and how is it computed?

A node's local clustering coefficient is the fraction of pairs among its neighbors that are themselves directly connected — literally, how many triangles it participates in relative to how many are possible. This simulation computes it exactly for every node (counting real edges among each node's neighbor set) and averages across all nodes to get the network-wide clustering coefficient shown in the stats panel, which is the standard definition used throughout graph-theory literature.

⚙ Under the hood

Generate real Erdős-Rényi, Watts-Strogatz and Barabási-Albert graphs, watch a live force-directed 3D layout settle, and measure real clustering, path length and degree distribution.

graph-theoryrandom-graphssmall-world-networksscale-free-networksnetwork-scienceforce-directed-layout

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)