Skip to content

3.5 Find the edges and nodes whose removal splits a strongly connected component

You find the strong bridges and strong articulation points of a graph, without which a strongly connected component splits into several.

You have a group of nodes in which every node reaches every other, and you want to know which edges and nodes keep it that way. If no further node can join the group, it is an SCC (strongly connected component). Some edges and nodes are indispensable: without one of them, some nodes of the SCC no longer reach the others, and the SCC splits into several. An indispensable edge is called a strong bridge. An indispensable node is called a strong articulation point. You need them wherever an SCC should stay one:

  • a network of one-way connections: they are its single points of failure;
  • a loop of a control-flow graph: they are the edges and blocks without which the blocks of the loop no longer reach each other;
  • a group of modules that depend on each other in a cycle: they are the dependencies and modules whose removal splits the group.

The method loadloadloadLoad of a small program reads the lines of a file and parses each line that is not blank into a note:

List<Note> load(Path file) {
List<String> lines = read(file); // entry
List<Note> notes = new ArrayList<>();
for (int i = 0; i < lines.size(); i++) { // header: i < lines.size()
String line = lines.get(i); // body
if (!line.isBlank()) {
notes.add(parse(line)); // then
}
} // next: i++
return notes; // exit
}
fn load(file: &Path) -> Vec<Note> {
let lines = read(file); // entry
let mut notes = Vec::new();
let mut i = 0;
while i < lines.len() { // header: i < lines.len()
let line = &lines[i]; // body
if !line.trim().is_empty() {
notes.push(parse(line)); // then
}
i += 1; // next
}
notes // exit
}
function load(file: string): Note[] {
const lines = read(file); // entry
const notes: Note[] = [];
for (let i = 0; i < lines.length; i++) { // header: i < lines.length
const line = lines[i]; // body
if (line.trim() !== "") {
notes.push(parse(line)); // then
}
} // next: i++
return notes; // exit
}
List<Note> Load(string file)
{
string[] lines = Read(file); // entry
var notes = new List<Note>();
for (int i = 0; i < lines.Length; i++) // header: i < lines.Length
{
string line = lines[i]; // body
if (!string.IsNullOrWhiteSpace(line))
{
notes.Add(Parse(line)); // then
}
} // next: i++
return notes; // exit
}

The graph cfg holds its control flow. This control-flow graph has a node for each basic block. Its loop consists of header, body, then and next. The loop is an SCC, which is the gray frame. Every edge inside it lies on a cycle and is orange. Which edges and blocks does the loop need so that its blocks still reach each other? The picture after shows the strong bridges as green edges and the strong articulation points as green blocks. body -> next stays orange, since it lies on a cycle but is not a strong bridge.

The control flow and its loop
Strong articulation points and bridges of the loop
1: header2: body3: then4: next0: entry5: exitSCC
1: header2: body3: then4: next0: entry5: exitSCC
Context
  • SCC
  • Edge on a cycle
Output
  • Strong articulation point
  • Strong bridge

The analysis follows edges against their direction as well, so it takes a BiAdjacentGraphBiAdjacentGraphBiAdjacentGraphBiAdjacentGraph, which BiAdjacentGraph.ofBiAdjacentGraph::ofBiAdjacentGraph.ofBiAdjacentGraph.Of builds:

// The loop of cfg - header, body, then, next - is a strongly connected component. The
// analysis follows edges against their direction too.
StrongConnectivity strong = Components.strongConnectivityOf(BiAdjacentGraph.of(cfg));
Edges strongBridges = strong.strongBridges();
// strongBridges: header -> body, body -> then, then -> next, next -> header
SortedIntView strongArticulationPoints = strong.strongArticulationPoints();
// strongArticulationPoints: [1, 2, 4] - header, body and next
Full example
// The loop of cfg - header, body, then, next - is a strongly connected component. The
// analysis follows edges against their direction too.
let strong = components::strong_connectivity_of(&BiAdjacentGraph::of(&cfg));
let strong_bridges = strong.strong_bridges();
// strong_bridges: header -> body, body -> then, then -> next, next -> header
let strong_articulation_points = strong.strong_articulation_points();
// strong_articulation_points: [1, 2, 4] - header, body and next
Full example
// The loop of cfg - header, body, then, next - is a strongly connected component. The
// analysis follows edges against their direction too.
const strong = Components.strongConnectivityOf(BiAdjacentGraph.of(cfg));
const strongBridges = strong.strongBridges;
// strongBridges: header -> body, body -> then, then -> next, next -> header
const strongArticulationPoints = strong.strongArticulationPoints;
// strongArticulationPoints: [1, 2, 4] - header, body and next
Full example
// The loop of cfg - header, body, then, next - is a strongly connected component.
// The analysis follows edges against their direction too.
StrongConnectivity strong =
Components.StrongConnectivityOf(BiAdjacentGraph.Of(cfg));
Edges strongBridges = strong.StrongBridges;
// strongBridges: header -> body, body -> then, then -> next, next -> header
SortedIntView strongArticulationPoints = strong.StrongArticulationPoints;
// strongArticulationPoints: [1, 2, 4] - header, body and next
Full example

The result has four strong bridges and three strong articulation points. They are the green edges and blocks of the picture after. Without any of the four edges of the cycle header -> body -> then -> next -> header, the loop is no longer one SCC. Without body -> next, it still is, since the path body -> then -> next remains. Likewise, without the block then, the other three blocks still reach each other through body -> next. Without header, body or next, they do not.