A connected component is a maximal set of graph nodes in which every pair is joined by a path. Finding components reveals whether a graph is one network or several disconnected groups, helping identify data issues and decide which subgraphs to model. section 4.2.3 section 8.3.3
A practical component-analysis workflow is:
- Create a NetworkX graph from an edge list or adjacency list, then check node and edge counts against expectations. section 8.3.3
- Generate components with nx.connected_components and count them to measure graph fragmentation. section 8.3.3
- Compare component sizes and inspect related metrics such as density, average degree, and clustering coefficient. section 4.2.3
- Extract the largest component with subgraph when disconnected nodes or tiny components are outside the modeling objective. section 8.3.3
Fraud and social-network EDA
A fraud graph has 45,954 nodes, 3,892,933 edges, and 26 components; component 3 contains 45,900 nodes and nearly every edge. A social graph has 219 components, including one component with 1,698 nodes and many singleton candidates, so analysis proceeds on the large component. section 4.2.3 section 8.3.3
connected_component = nx.connected_components(social_graph
Gcc = social_graph.subgraph(sorted(connected ),
key=len,
reverse=True)[0]
)
Inspect the NetworkX subgraph expression used to select the largest connected component for visualization and subsequent analysis. section 8.3.3

