Guest
Sign in to keep your graphs and progress.
Select an algorithm and generate steps to begin visualization
Peel the weak ties until the dense centre shows
Peels away vertices with fewer than k neighbours, round after round, to give every vertex its core number and reveal the dense centre of a network
Select an algorithm and generate steps to begin visualization
The k-core of a graph is the largest part of it in which every vertex has at least k neighbours inside that part. The 1-core drops isolated vertices, the 2-core also drops the trees hanging off the graph, and higher cores close in on its densest region. The core number of a vertex is the largest k for which it belongs to the k-core, and the largest core number in the graph is its degeneracy. Stephen Seidman introduced k-cores in 1983 to describe cohesive groups in social networks.
The algorithm peels. With the bar at k, any vertex with fewer than k neighbours left is removed, and its neighbours lose one edge each, so some of them may fall below k too and go in the same sweep. When no vertex is below k, what remains is the k-core, and every vertex peeled on the way has core number k − 1. Then the bar rises to k + 1. Batagelj and Zaveršnik showed in 2003 that buckets of vertices of equal degree make the whole decomposition O(n + m). The visualizer shows how many neighbours each vertex has left, greys out peeled edges, writes the core number on each vertex as it goes and colours the shells from the outside in.
Core numbers rank how embedded a vertex is: a study of epidemic spreading found that vertices in the innermost cores spread an infection further than high-degree vertices on the edge of the network. Network visualisations draw the shells as rings, biologists look for the cores of protein interaction networks, and the degeneracy order, peeling one minimum-degree vertex at a time, speeds up clique search and shows that a graph can be coloured greedily with degeneracy + 1 colours. The k-core is also a quick first filter before slower dense-subgraph or community methods.
Peeling with a rising bar. The inner loop is what lets one removal set off others.
CoreNumbers(G):
deg[v] = degree of v for every vertex
k = 1
while vertices remain:
while some remaining v has deg[v] < k:
remove v, core[v] = k - 1
for each remaining neighbour u of v:
deg[u] = deg[u] - 1
// what remains now is the k-core
k = k + 1
return core // degeneracy = max core[v]A vertex removed while the bar is k has fewer than k neighbours among the vertices left, but it survived the bar k − 1, so its core number is k − 1. Batagelj and Zaveršnik avoid the repeated search with buckets of vertices by current degree, always removing from the lowest bucket, which gives O(n + m).
The eleven-vertex example on this page.
Example graph: A, B, C and D form a complete K4. E is joined to A, B and C, D is joined to F, and F, G, H form a triangle. J hangs on E, I hangs on J and K hangs on H.
Degeneracy 3. Core numbers: 3 for A, B, C, D and E, 2 for F, G and H, 1 for I, J and K. Degree alone would mislead: F and H have degree 3, but each relies on neighbours that are peeled before the 3-core forms, so they stay in the 2-shell.
Time: O(n + m) · Space: O(n + m)
Every vertex is removed once and every edge lowers a degree once, so the work is O(n + m) if the next vertex to remove is found in constant time. Buckets indexed by degree do that: a vertex whose degree drops moves one bucket down. The visualizer scans all vertices instead, O(n²), which is easy to follow on small graphs.
Other ways to find the dense part of a network.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Ranking by degree | A quick ranking is enough. It ignores where the neighbours are, so a hub tied to many leaves ranks high although it sits on the edge. | O(n + m) |
| Maximum clique (Bron–Kerbosch) | Everyone in the group must know everyone else. Cliques are much stricter than cores and exponential to find in the worst case. | O(3^(n/3)) worst case |
| Densest subgraph | The subgraph with the highest average degree is wanted exactly. The innermost core is within a factor of 2 of it. | Polynomial, through maximum flow |
Read the full article: Community Detection in Graphs
Read the full article: Graph Centrality Measures and PageRank
Related algorithms: Clustering Coefficient, Betweenness Centrality, Louvain Community Detection, Maximal Clique, Graph Coloring