Strongly Connected Components
Groups of nodes in a directed graph where every node can reach every other node in the group by following the arrows — used in quant systems to spot circular dependencies and feedback loops in code, data pipelines, or trading relationships.
In a directed graph — arrows, not plain lines, connecting nodes — a strongly connected component (SCC) is a maximal set of nodes where you can get from any node in the set to any other node in the set by following the arrows, in both directions if needed. A single node is trivially its own SCC if it has no cycle through it; a group of nodes all pointing around in a loop (A → B → C → A) forms one SCC of size three.
The standard use case is dependency analysis: if module A imports module B, draw an arrow A → B. Tarjan's or Kosaraju's algorithm finds all SCCs in linear time, and any SCC with more than one node is a circular dependency — a group of modules that can't be built, tested, or reasoned about independently because each ultimately depends on the others.
Worked example. A codebase's import graph has modules pricing, risk, data, utils. If pricing imports risk, risk imports data, and data imports pricing back, those three form one SCC — a cycle that means you cannot understand pricing in isolation from risk or data. Running Tarjan's algorithm on the full import graph flags this three-module cycle instantly, even buried among hundreds of files, letting you refactor to break the loop (typically by extracting the shared piece both sides depend on into its own module) before it causes an unpredictable build order or a subtle circular-import bug.
A strongly connected component is a set of nodes in a directed graph mutually reachable from one another; any SCC larger than one node is a cycle, and finding all of them (via Tarjan's or Kosaraju's algorithm) is the standard way to detect circular dependencies in code or data pipelines.
Related concepts
Practice in interviews
Further reading
- Cormen et al., Introduction to Algorithms, ch. 22