Articulation points
Advanced · 11 min · code in PHP, JavaScript, Java and Go
Where you will meet this in real life
An articulation point is a single node, such as a server, station or user, whose removal splits the network. Finding them shows which one item everything depends on, so you can add redundancy before it fails.
Practical use cases
- Web app: Which server must never go down. An ops dashboard maps services and their connections. A database proxy that sits between the web tier and three data stores shows up as an articulation point, which is why it should be replicated first.
- Web app: Influencer or admin dependency. In a small community network, one member may be the only link between two groups. The app flags them as a key connector, useful for moderation or outreach. Moderators can then make sure that member has a backup contact, so the two groups do not drift apart if they leave the site.
- Web app: Metro interchange stress test. A transit planner finds the stations whose closure would cut the network in two. It helps decide where to keep service running during maintenance.
- System: Fault-tolerant network design. Network architects check that no single router, switch or data centre is the only link between parts of the system. The key question is whether anything is left stranded when one node is removed, and one walk answers it for every node at once.
The story: The Station Everybody Needs
Raju's uncle worked at the railway control room. One afternoon a single junction station had a signal failure, and half the country's trains stopped. "Why does one station matter so much?" Mira asked. "Because every route between two big regions passes through it," he said. "There is no other way around."
Mira drew the network and wondered: could we find all such stations before they fail? Trying to close every station and run a search each time felt like closing every shop in the market one at a time to see which one holds everybody together.
This time she re-used the bridges trick. Walk through the network once, noting a discovery number and a low number for every station. Look at a station U and its child V. If V's side can only climb back to U itself or lower down (low[V] ≥ disc[U]), then without U that side is stranded. One exception: the starting station has nobody above it, so it only matters if it has two or more separate branches.
Such a station is an articulation point (or cut vertex). Where a bridge is a critical road, an articulation point is a critical junction.
How to spot this problem, and where you need it
You need to find the single item in a network whose failure would break it into disconnected parts, so you can protect it or add a second route.
Signs you need it
- Language like "single point of failure", "critical node", "if this server dies, what else stops?".
- One machine, hub or person appears on every path between two groups.
- Testing "remove each node and recheck" works on paper but is too slow for the real network.
Where to use it in a project
- Service dependency and uptime maps that must highlight what to replicate first.
- Transit, logistics or social network analysis to find key junctions or connectors.
The solution
Run one DFS with discovery and low numbers. A non-root node u is an articulation point if some child v has low of v at least as big as the discovery number of u, meaning that child subtree cannot reach above u without going through u. The start node is one if it has two or more separate DFS children. One walk finds every critical node.
Payoff: Before: a single proxy failing and taking down the whole shop for 20 minutes. After: it is flagged in advance and replicated, so the failure goes unnoticed.
Explain it like I am 8
Imagine a group of friends holding hands to cross a river, but one friend is the only one holding the two halves together. If that friend lets go, the chain breaks into two. That friend is the articulation point.
How it works, step by step
- Run a DFS and record discovery and low numbers, just like for bridges.
- For a non-root node
Uwith a childV: iflow[V] >= disc[U], then U is an articulation point. - For the root, count its children in the DFS tree. Two or more means it is an articulation point.
- Note the difference from bridges: here it is >= (V can reach U itself but not above, and closing U still strands V).
- Collect every node that satisfied the test (use a set so nobody is listed twice).
The code in four languages
PHP
<?php
// Find articulation points (cut vertices) with one DFS
function articulationPoints(int $n, array $edges): array {
$adj = array_fill(0, $n, []);
foreach ($edges as [$a, $b]) { $adj[$a][] = $b; $adj[$b][] = $a; }
$disc = array_fill(0, $n, -1);
$low = array_fill(0, $n, 0);
$isCut = array_fill(0, $n, false);
$time = 0;
$visit = function (int $u, int $parent) use (&$visit, &$disc, &$low, &$isCut, &$time, $adj): void {
$disc[$u] = $low[$u] = $time++;
$children = 0;
foreach ($adj[$u] as $v) {
if ($v === $parent) continue;
if ($disc[$v] >= 0) {
$low[$u] = min($low[$u], $disc[$v]); // back road to an older station
} else {
$children++;
$visit($v, $u);
$low[$u] = min($low[$u], $low[$v]);
if ($parent !== -1 && $low[$v] >= $disc[$u]) {
$isCut[$u] = true; // v's side cannot get above u
}
}
}
if ($parent === -1 && $children > 1) $isCut[$u] = true; // root with 2+ branches
};
for ($i = 0; $i < $n; $i++) if ($disc[$i] < 0) $visit($i, -1);
$result = [];
foreach ($isCut as $i => $yes) if ($yes) $result[] = $i;
return $result;
}
// stations A..F = 0..5
$tracks = [[0,1],[1,2],[2,0],[2,3],[3,4],[4,5],[5,3]];
echo 'Articulation points: ' . implode(', ', articulationPoints(6, $tracks)) . PHP_EOL;JavaScript
// Find articulation points (cut vertices) with one DFS
function articulationPoints(n, edges) {
const adj = Array.from({ length: n }, () => []);
for (const [a, b] of edges) { adj[a].push(b); adj[b].push(a); }
const disc = new Array(n).fill(-1);
const low = new Array(n).fill(0);
const isCut = new Array(n).fill(false);
let time = 0;
function visit(u, parent) {
disc[u] = low[u] = time++;
let children = 0;
for (const v of adj[u]) {
if (v === parent) continue;
if (disc[v] >= 0) {
low[u] = Math.min(low[u], disc[v]); // back road to an older station
} else {
children++;
visit(v, u);
low[u] = Math.min(low[u], low[v]);
if (parent !== -1 && low[v] >= disc[u]) {
isCut[u] = true; // v's side cannot get above u
}
}
}
if (parent === -1 && children > 1) isCut[u] = true; // root with 2+ branches
}
for (let i = 0; i < n; i++) if (disc[i] < 0) visit(i, -1);
return isCut.map((yes, i) => (yes ? i : -1)).filter(i => i >= 0);
}
// stations A..F = 0..5
const tracks = [[0,1],[1,2],[2,0],[2,3],[3,4],[4,5],[5,3]];
console.log('Articulation points: ' + articulationPoints(6, tracks).join(', '));Java
import java.util.*;
public class Main {
static List<List<Integer>> adj;
static int[] disc, low;
static boolean[] isCut;
static int time = 0;
static void visit(int u, int parent) {
disc[u] = low[u] = time++;
int children = 0;
for (int v : adj.get(u)) {
if (v == parent) continue;
if (disc[v] >= 0) {
low[u] = Math.min(low[u], disc[v]); // back road to an older station
} else {
children++;
visit(v, u);
low[u] = Math.min(low[u], low[v]);
if (parent != -1 && low[v] >= disc[u]) {
isCut[u] = true; // v's side cannot get above u
}
}
}
if (parent == -1 && children > 1) isCut[u] = true; // root with 2+ branches
}
// Find articulation points (cut vertices) with one DFS
static List<Integer> articulationPoints(int n, int[][] edges) {
adj = new ArrayList<>();
for (int i = 0; i < n; i++) adj.add(new ArrayList<>());
for (int[] e : edges) { adj.get(e[0]).add(e[1]); adj.get(e[1]).add(e[0]); }
disc = new int[n];
Arrays.fill(disc, -1);
low = new int[n];
isCut = new boolean[n];
for (int i = 0; i < n; i++) if (disc[i] < 0) visit(i, -1);
List<Integer> result = new ArrayList<>();
for (int i = 0; i < n; i++) if (isCut[i]) result.add(i);
return result;
}
public static void main(String[] args) {
// stations A..F = 0..5
int[][] tracks = {{0, 1}, {1, 2}, {2, 0}, {2, 3}, {3, 4}, {4, 5}, {5, 3}};
List<String> words = new ArrayList<>();
for (int p : articulationPoints(6, tracks)) words.add(String.valueOf(p));
System.out.println("Articulation points: " + String.join(", ", words));
}
}Go
package main
import (
"fmt"
"strconv"
"strings"
)
// articulationPoints finds the cut vertices with one DFS.
func articulationPoints(n int, edges [][2]int) []int {
adj := make([][]int, n)
for _, e := range edges {
adj[e[0]] = append(adj[e[0]], e[1])
adj[e[1]] = append(adj[e[1]], e[0])
}
disc := make([]int, n)
for i := range disc {
disc[i] = -1
}
low := make([]int, n)
isCut := make([]bool, n)
time := 0
var visit func(u, parent int)
visit = func(u, parent int) {
disc[u], low[u] = time, time
time++
children := 0
for _, v := range adj[u] {
if v == parent {
continue
}
if disc[v] >= 0 {
low[u] = min(low[u], disc[v]) // back road to an older station
} else {
children++
visit(v, u)
low[u] = min(low[u], low[v])
if parent != -1 && low[v] >= disc[u] {
isCut[u] = true // v's side cannot get above u
}
}
}
if parent == -1 && children > 1 {
isCut[u] = true // root with 2+ branches
}
}
for i := 0; i < n; i++ {
if disc[i] < 0 {
visit(i, -1)
}
}
var result []int
for i, yes := range isCut {
if yes {
result = append(result, i)
}
}
return result
}
func main() {
// stations A..F = 0..5
tracks := [][2]int{{0, 1}, {1, 2}, {2, 0}, {2, 3}, {3, 4}, {4, 5}, {5, 3}}
var words []string
for _, p := range articulationPoints(6, tracks) {
words = append(words, strconv.Itoa(p))
}
fmt.Println("Articulation points: " + strings.Join(words, ", "))
}Time: O(V + E) · Extra space: O(V + E). Just one DFS over the network.
Watch out for
- Applying the "two children" rule to every node. It is only for the root; other nodes use the low-number test.
- Using
>(the bridge rule) instead of>=for non-root nodes. - Listing the same station twice because several children satisfy the test. Use a flag array or a set.
Quick check
- A DFS root has only ONE child in the DFS tree. Is it an articulation point?
- Only if it has back roads
- Yes, roots always are
- No, one branch means nothing is cut off
- For a non-root node U with child V, what makes U an articulation point?
- V has no children
- low[V] >= disc[U]
- low[V] < disc[U]
- disc[V] == 0
- How is an articulation point different from a bridge?
- It is a node, not a road
- It is a road, not a node
- They are exactly the same