CodeGraph/docs
Section 4.7

Connectivity & Degree Analysis

O(1) measurement of incoming (fan-in) and outgoing (fan-out) node degree, God-node detection, and architectural instability.

Source: server/src/analytics/connectivity/FanInOutAnalyzer.ts

$O(1)$ Edge Counting Algorithm

Because GraphBuilder maintains pre-indexed edge sets, calculating a node's degree requires zero iteration:

server/src/analytics/connectivity/FanInOutAnalyzer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export class FanInOutAnalyzer { constructor(private readonly graph: Graph) {} analyze(nodeId: string): FanInOutResult { const incomingEdges = this.graph.incomingEdges.get(nodeId) ?? new Set(); const outgoingEdges = this.graph.outgoingEdges.get(nodeId) ?? new Set(); return { nodeId, fanIn: incomingEdges.size, // O(1) fanOut: outgoingEdges.size, // O(1) }; } }

Architectural Diagnostic Matrix

Comparing fan-in and fan-out identifies structural archetypes:

PatternFan-InFan-OutArchitectural Assessment
Utility / LeafHighLowIdeal foundational helper. Widely reused, low blast risk.
Entry PointLow / 0HighNormal for top-level bootstrap scripts or main routers.
God Node / HubHighHighArchitectural bottleneck. High coupling, dangerous to modify.
Isolated Node00Dead code candidate. Completely disconnected from the graph.