Skip to content

5.2 Find the edges and nodes whose removal splits a graph

You find the bridges and articulation points: the edges and nodes whose removal splits a component of a graph read as undirected.

You want to know which single edge or single node a graph cannot lose, because some nodes would no longer be connected to the others. The direction of the edges does not matter for this, so the graph is read as undirected. An edge whose removal splits a component in two is called a bridge. A node whose removal splits a component is called an articulation point. You need this to find:

  • a cable or a router whose failure cuts a network in two;
  • a single call that is all that connects two areas of a program;
  • a module through which every path between two halves of a system passes.

The example graph calls models the calls between the methods of a small program. It has an edge from each method to each method it calls. Here, the graph is read as undirected. Without which single call, and without which method, are some methods no longer connected to the others?

The calls, read as undirected
Bridges and articulation points
0: main1: parseArgs2: run3: load4: save5: show6: parse7: format8: read9: write
0: main1: parseArgs2: run3: load4: save5: show6: parse7: format8: read9: write
Context
  • Call on a cycle
Output
  • Articulation point
  • Bridge

In the picture after, the bridges and the articulation points are green. The orange edges lie on a cycle, and none of them is a bridge. Four of them are the calls through run, save, format and show. The other two are the self-loops of parse and format, and each of these is a cycle of its own.

The analysis follows the edges in both directions, so it takes a BiAdjacentGraphBiAdjacentGraphBiAdjacentGraphBiAdjacentGraph, which BiAdjacentGraph.ofBiAdjacentGraph::ofBiAdjacentGraph.ofBiAdjacentGraph.Of builds from the graph:

// The analysis reads the edges as undirected and follows them both ways, so it takes
// a BiAdjacentGraph.
Biconnectivity biconnectivity =
Components.biconnectivityOf(BiAdjacentGraph.of(calls));
Edges bridges = biconnectivity.bridges();
// bridges: main -> parseArgs, main -> run, run -> load, load -> parse, load -> read,
// save -> write
SortedIntView articulationPoints = biconnectivity.articulationPoints();
// articulationPoints: [0, 2, 3, 4] - main, run, load and save
Full example
// The analysis reads the edges as undirected and follows them both ways, so it takes
// a BiAdjacentGraph.
let biconnectivity = components::biconnectivity_of(&BiAdjacentGraph::of(&calls));
let bridges = biconnectivity.bridges();
// bridges: main -> parseArgs, main -> run, run -> load, load -> parse, load -> read,
// save -> write
let articulation_points = biconnectivity.articulation_points();
// articulation_points: [0, 2, 3, 4] - main, run, load and save
Full example
// The analysis reads the edges as undirected and follows them both ways, so it takes
// a BiAdjacentGraph.
const biconnectivity = Components.biconnectivityOf(BiAdjacentGraph.of(calls));
const bridges = biconnectivity.bridges;
// bridges: main -> parseArgs, main -> run, run -> load, load -> parse, load -> read,
// save -> write
const articulationPoints = biconnectivity.articulationPoints;
// articulationPoints: [0, 2, 3, 4] - main, run, load and save
Full example
// The analysis reads the edges as undirected and follows them both ways, so it
// takes a BiAdjacentGraph.
Biconnectivity biconnectivity =
Components.BiconnectivityOf(BiAdjacentGraph.Of(calls));
Edges bridges = biconnectivity.Bridges;
// bridges: main -> parseArgs, main -> run, run -> load, load -> parse,
// load -> read, save -> write
SortedIntView articulationPoints = biconnectivity.ArticulationPoints;
// articulationPoints: [0, 2, 3, 4] - main, run, load and save
Full example

Six calls are bridges: every call between two different methods except the four on the cycle through run, save, format and show. Four methods are articulation points:

  • Without main, parseArgs is connected to no other method.
  • Without run, main and parseArgs are no longer connected to the rest.
  • Without load, neither parse nor read is connected to another method.
  • Without save, write is connected to no other method.