networkx

Comprehensive toolkit for creating, analyzing, and visualizing complex networks and graphs in Python — covering graph algorithms (shortest paths, centrality, clustering), community detection, synthetic network generation, and network visualization.

Analyze and visualize graph and network data structures

Source K-Dense AI
License MIT
First documented

Trigger phrases

Phrases that activate this skill when typed to Claude Code:

  • analyze this network
  • graph centrality
  • shortest path in a graph
  • community detection
  • networkx visualization

What it does

networkx is a Claude Code skill from K-Dense AI’s scientific-agent-skills repo. It turns Claude into a NetworkX expert covering graph creation (directed, undirected, multigraph, bipartite), graph algorithms (shortest paths, centrality measures, clustering coefficients, community detection), synthetic network generation (Erdős–Rényi, Barabási–Albert, Watts–Strogatz), and visualization with matplotlib layouts.

A session produces Python code that builds, analyzes, and visualizes the graph structure from your data — from a simple node-edge list to a full network analysis pipeline with centrality rankings and community partition.

When to use it

Reach for it when:

  • You have relational data (citation networks, biological networks, social graphs, transportation networks) and want graph-theoretic analysis
  • You need standard graph algorithms: shortest path, betweenness centrality, PageRank, connected components, or community detection
  • You’re teaching or prototyping graph algorithms and want a Pythonic library with good documentation coverage

When not to reach for it:

  • Very large graphs (millions of nodes/edges) where NetworkX’s pure-Python implementation becomes slow — consider igraph or GPU-based graph libraries via optimize-for-gpu
  • Graph neural networks — use torch-geometric

Install

Copy the SKILL.md from K-Dense AI’s networkx folder into .claude/skills/networkx/ in your project.

Trigger phrases: “analyze this network”, “graph centrality”, “shortest path in a graph”, “community detection”, “networkx visualization”.

What a session looks like

A typical session has three phases:

  1. Graph construction. Provide the edge list, adjacency matrix, or DataFrame with source/target columns. Claude constructs the appropriate NetworkX graph type and validates connectivity.
  2. Analysis. Claude runs the requested algorithms — centrality measures, path analysis, clustering, community detection (Louvain, Girvan-Newman, label propagation) — and returns structured results with the top-N nodes or statistics.
  3. Visualization. The graph is drawn with a layout appropriate to the structure (spring layout for small graphs, shell or circular for structured graphs) with node size or color mapped to the computed metric.

Receipts

Where it works well:

  • Citation network analysis — building a graph from a BibTeX file and computing betweenness centrality to find bridging papers takes a dozen lines of NetworkX code
  • Small-to-medium biological networks (protein-protein interaction, metabolic pathways) where the graph fits in memory and standard centrality measures surface meaningful biology

Where it backfires:

  • Graphs with millions of edges become slow or run out of memory in NetworkX’s pure-Python data structures — at that scale, cuGraph (via optimize-for-gpu) or specialized libraries are needed
  • Graph visualization for dense networks produces unreadable hairball plots; NetworkX’s matplotlib integration doesn’t handle graph sparsification automatically

Pattern that works: always check graph size (number of nodes and edges) before running expensive algorithms like betweenness centrality — it scales as O(VE) and will hang on large dense graphs without warning.

Source and attribution

Originally authored by K-Dense Inc.. The canonical SKILL.md lives in the networkx folder of their public scientific-agent-skills repository.

License: MIT. Install, adapt, and redistribute with attribution preserved.

This page documents the skill from a practitioner’s perspective. For the formal spec and any updates, defer to the source repo.