NetworkX is a Python graph-processing library for creating, loading, manipulating, analyzing, and visualizing network structures. It is especially practical for small graphs, exploratory data analysis, and preparing graph data for learning workflows. section 2.1.1 section 8.3.3
A typical NetworkX workflow moves from raw relationships to an inspectable graph:
- Load an edge list, adjacency list, or GML file into a graph object. section 2.1.1 section 8.3.3
- Attach node attributes such as identifiers, industries, job types, labels, or weights. section 2.1.1 section 8.3.3
- Check node and edge counts, inspect connected components, and isolate a useful subgraph. section 8.3.3
- Visualize structure with layouts, nodes, edges, degree plots, histograms, or adjacency matrices. section 8.3.3
- Pass the prepared graph to downstream tools such as Node2Vec or PyTorch Geometric. section 2.1.1 section 8.0
Preparing a social graph
A recruiting network can be loaded from an adjacency list, enriched with candidate attributes, and checked for disconnected components. If one large component contains the meaningful relationships, NetworkX can extract it for visualization and later graph-learning steps. section 8.3.3 section 8.0
Listing 8.3 Create an edge list from the relationship dictionary
social_graph = nx.read_adjlist('adjacency_list_candidates.txt')
nx.set_node_attributes(social_graph, attribute_dict)
print(social_graph.number_of_nodes(), social_graph.number_of_edges())
>> 1933 12239
Inspect a compact implementation that loads an adjacency list, sets node attributes, and reports graph size. section 8.3.3

