liveBook · Manning

Connected component

As explained in Graph Neural Networks in Action

A connected component is a maximal set of graph nodes in which every pair of nodes is connected by a path.

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

How Graph Neural Networks in Action covers it

How deep it goes
Explains the definition, counts components, compares their metrics, and demonstrates extraction, without deriving connectivity algorithms.
Examples
Uses fraud, candidate social, and Amazon product co-purchaser graphs for component counts, sparse-graph analysis, and connectivity inspection.
What it assumes
Assumes basic graph nodes and edges, while building component analysis from adjacency-list loading and simple structural metrics.
What you can do after
Apply it via NetworkX to count components, compare their sizes, isolate the largest subgraph, and support graph EDA.
How it connects
Connects components to graph topology, graph density, average degree, clustering coefficient, degree distribution, and graph neural network training.

Also explained in

Compare how 2 books explain connected component →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Neural Networks in Action. The section links point to the parts of the book it draws on.