📖 Scenario: You are working as a network engineer. You want to find critical computers in a network. If these computers fail, the network breaks into disconnected parts. These critical computers are called articulation points.The network is represented as a graph where each computer is a node and connections are edges.
🎯 Goal: Build a TypeScript program to find all articulation points in a given undirected graph using DFS and low-link values.
📋 What You'll Learn
Create a graph as an adjacency list with exact nodes and edges
Add a variable to track discovery time of nodes
Implement DFS to find articulation points using discovery and low arrays
Print the list of articulation points found in the graph
💡 Why This Matters
🌍 Real World
Finding articulation points helps identify critical nodes in networks like computer networks, social networks, or transportation systems where failure of these nodes disrupts connectivity.
💼 Career
Network engineers, system architects, and software developers use articulation point algorithms to design robust and fault-tolerant systems.
Progress0 / 4 steps
1
Create the graph as an adjacency list
Create a variable called graph as a Map<number, number[]> with these exact edges: 0 connected to 1 and 2, 1 connected to 0, 2, and 3, 2 connected to 0 and 1, 3 connected to 1 and 4, 4 connected to 3 and 5, 5 connected to 4
DSA Typescript
Hint
Use new Map() with an array of key-value pairs where keys are node numbers and values are arrays of connected nodes.
2
Add discovery time and low arrays
Create two arrays called disc and low of length 6 filled with -1. Also create a boolean array called visited of length 6 filled with false. Create a variable time and set it to 0.
DSA Typescript
Hint
Use Array(6).fill(-1) for disc and low, and Array(6).fill(false) for visited.
3
Implement DFS to find articulation points
Write a function called dfs with parameters u: number, parent: number | null, and ap: boolean[]. Inside, mark visited[u] as true, set disc[u] and low[u] to time, then increment time. Use a variable children set to 0. For each v in graph.get(u) || [], if v is not visited, increment children, call dfs(v, u, ap), update low[u] to Math.min(low[u], low[v]). If parent !== null and low[v] >= disc[u], set ap[u] to true. Else if v !== parent, update low[u] to Math.min(low[u], disc[v]). After the loop, if parent === null and children > 1, set ap[u] to true.
DSA Typescript
Hint
Follow the standard DFS articulation point algorithm using discovery and low arrays.
4
Find and print articulation points
Create a boolean array called ap of length 6 filled with false. Loop i from 0 to 5, if visited[i] is false, call dfs(i, null, ap). Then create an array result containing all indices i where ap[i] is true. Finally, print result.
DSA Typescript
Hint
Run DFS from all unvisited nodes, collect articulation points in ap, then print their indices.
Practice
(1/5)
1. What is an articulation point (or cut vertex) in a graph?
easy
A. A vertex that, when removed, increases the number of connected components
B. A vertex with the highest degree in the graph
C. A vertex connected to all other vertices
D. A vertex that has no edges connected to it
Solution
Step 1: Understand the definition of articulation point
An articulation point is a vertex that, if removed, breaks the graph into more pieces (connected components).
Step 2: Compare options with definition
Only A vertex that, when removed, increases the number of connected components matches this definition exactly.
Final Answer:
A vertex that, when removed, increases the number of connected components -> Option A
Quick Check:
Articulation point = vertex increasing components when removed [OK]
Hint: Articulation point breaks graph connectivity when removed [OK]
Common Mistakes:
Confusing articulation point with highest degree vertex
Thinking articulation point connects to all vertices
Assuming isolated vertex is articulation point
2. Which of the following is the correct TypeScript function signature to find articulation points in an undirected graph represented as adjacency list?
easy
A. function findArticulationPoints(graph: number): number[]
B. function findArticulationPoints(graph: number[][]): void
C. function findArticulationPoints(graph: string): number[]
D. function findArticulationPoints(graph: Map): number[]
Solution
Step 1: Identify the graph representation type
An adjacency list is best represented as a Map from node number to array of connected nodes.
Step 2: Check function signature compatibility
function findArticulationPoints(graph: Map): number[] uses Map and returns number[] which fits the problem.
Final Answer:
function findArticulationPoints(graph: Map<number, number[]>): number[] -> Option D
Quick Check:
Adjacency list as Map with number arrays returns number array [OK]
Hint: Use Map for adjacency list in TypeScript [OK]
Common Mistakes:
Using string type for graph input
Returning void instead of list of articulation points
Passing graph as a single number
3. Given the following TypeScript code snippet to find articulation points, what will be the output for the graph edges: [[0,1],[1,2],[2,0],[1,3]]?
The graph has a triangle between 0,1,2 and a leaf node 3 connected to 1.
Step 2: Identify articulation points
Removing node 1 disconnects node 3 from the rest, so 1 is an articulation point. Nodes 0 and 2 are part of a cycle, so not articulation points. Node 3 is a leaf, not articulation point.
Final Answer:
[1] -> Option C
Quick Check:
Only node 1 disconnects graph when removed [OK]
Hint: Check if removing node splits graph into more parts [OK]
Common Mistakes:
Thinking nodes in cycle are articulation points
Including leaf nodes as articulation points
Ignoring connectivity after removal
4. The following TypeScript code attempts to find articulation points but has a bug. What is the bug?
function dfs(u: number, parent: number) {
visited[u] = true;
disc[u] = time;
low[u] = time;
time++;
let children = 0;
for (const v of graph.get(u) || []) {
if (!visited[v]) {
children++;
dfs(v, u);
low[u] = Math.min(low[u], low[v]);
if (parent !== -1 && low[v] >= disc[u]) {
articulationPoints.add(u);
}
} else if (v !== parent) {
low[u] = Math.min(low[u], disc[v]);
}
}
if (parent === -1 && children > 1) {
articulationPoints.add(u);
}
}
medium
A. The 'visited' array is not initialized before DFS
B. The root node condition for articulation point is checked after the loop
C. The variable 'time' is not incremented correctly
D. The condition 'low[v] >= disc[u]' should be 'low[v] > disc[u]'
Solution
Step 1: Review DFS variables initialization
The code uses 'visited' array but does not show its initialization before DFS calls.
Step 2: Identify missing initialization impact
If 'visited' is not initialized to false for all nodes, DFS may skip nodes or behave incorrectly.
Final Answer:
The 'visited' array is not initialized before DFS -> Option A
Hint: Always initialize visited array before DFS traversal [OK]
Common Mistakes:
Assuming time increments incorrectly
Misunderstanding root node articulation condition
Changing condition from >= to > incorrectly
5. You have a network of computers represented as an undirected graph. You want to find all critical computers whose failure would split the network. The graph has 7 nodes with edges: [[0,1],[1,2],[2,0],[1,3],[3,4],[4,5],[5,3],[4,6]]. Which nodes are articulation points?
hard
A. [0, 2, 5]
B. [1, 3, 4]
C. [3, 5, 6]
D. [1, 4, 6]
Solution
Step 1: Analyze graph components and cycles
Nodes 0,1,2 form a triangle (cycle). Nodes 3,4,5 form another cycle. Node 6 is connected only to 4.
Step 2: Identify articulation points
Removing 1 disconnects node 3 and its cycle from 0,2. Removing 3 disconnects 4,5,6 from 1. Removing 4 disconnects node 6 from rest. So articulation points are 1, 3, and 4.
Final Answer:
[1, 3, 4] -> Option B
Quick Check:
Nodes connecting cycles and leaf nodes are articulation points [OK]
Hint: Look for nodes connecting cycles or leaf nodes [OK]
Common Mistakes:
Including nodes inside cycles as articulation points
Missing nodes connecting leaf nodes
Confusing leaf nodes as articulation points
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.