networkx
Helps your agent create, analyze, and visualize complex networks and graphs. It's useful for understanding connections in data, like social or transportation networks.
What it does
This tool helps create, analyze, and draw complex networks, like social or transportation networks. It allows you to understand the connections between different points.
When to use it
- ✓When analyzing how people connect in a social network.
- ✓When mapping transportation routes and finding the shortest paths.
- ✓When visualizing the structure of relationships between different items.
Example of what to ask your AI
“Create a social network graph from a list of friendships and show me who has the most connections.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
You describe the points (nodes) and the connections (edges) between them. The tool then uses algorithms to calculate information about this network, such as shortest paths or the importance of each point.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add K-Dense-AI/scientific-agent-skills --skill networkxOr download just the file:
curl -L https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/main/skills/networkx/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
NetworkX
Overview
NetworkX is a Python package for creating, manipulating, and analyzing complex networks and graphs. Use this skill when working with network or graph data structures, including social networks, biological networks, transportation systems, citation networks, knowledge graphs, or any system involving relationships between entities.
This skill targets tested NetworkX 3.7 (Python >=3.12, excluding 3.14.1). Several pre-3.0 APIs (nx.info, nx.write_gpickle, nx.read_shp) and the 3.4-era nx.random_tree no longer exist — current replacements are used throughout this skill.
Review sources, executed examples, optional-dependency limits, and reproducibility notes are in references/review.md. Reference snippets are API patterns: supply the stated graph type and input files; they are not one sequential script.
When to Use This Skill
Invoke this skill when tasks involve:
- Creating graphs: Building network structures from data, adding nodes and edges with attributes
- Graph analysis: Computing centrality measures, finding shortest paths, detecting communities, measuring clustering
- Graph algorithms: Running standard algorithms like Dijkstra's, PageRank, minimum spanning trees, maximum flow
- Network generation: Creating synthetic networks (random, scale-free, small-world models) for testing or simulation
- Graph I/O: Reading from or writing to various formats (edge lists, GraphML, JSON, CSV, adjacency matrices)
- Visualization: Drawing and customizing network visualizations with matplotlib or interactive libraries
- Network comparison: Checking isomorphism, computing graph metrics, analyzing structural properties
Core Capabilities
1. Graph Creation and Manipulation
NetworkX supports four main graph types:
- Graph: Undirected graphs with single edges
- DiGraph: Directed graphs with one-way connections
- MultiGraph: Undirected graphs allowing multiple edges between nodes
- MultiDiGraph: Directed graphs with multiple edges
Create graphs by:
import networkx as nx
# Create empty graph
G = nx.Graph()
# Add nodes (can be any hashable type)
G.add_node(1)
G.add_nodes_from([2, 3, 4])
G.add_node("protein_A", type='enzyme', weight=1.5)
# Add edges
G.add_edge(1, 2)
G.add_edges_from([(1, 3), (2, 4)])
G.add_edge(1, 4, weight=0.8, relation='interacts')
Reference: See references/graph-basics.md for comprehensive guidance on creating, modifying, examining, and managing graph structures, including working with attributes and subgraphs.
2. Graph Algorithms
NetworkX provides extensive algorithms for network analysis:
Shortest Paths:
For weighted paths and betweenness, weights represent distances/costs: larger values make a route less favorable. Similarity, correlation, or interaction strength needs an explicit scientifically justified conversion before use as distance. Validate the chosen attribute on every edge and use strictly positive distances for weighted betweenness.
# Same distance model for route and length
G = nx.Graph()
G.add_weighted_edges_from([(1, 2, 1), (2, 5, 1), (1, 5, 5)], weight='distance')
path = nx.shortest_path(G, source=1, target=5, weight='distance')
length = nx.shortest_path_length(G, source=1, target=5, weight='distance')
assert path == [1, 2, 5] and length == 2
Centrality Measures:
# Degree centrality
degree_cent = nx.degree_centrality(G)
# Betweenness centrality
betweenness = nx.betweenness_centrality(G)
# PageRank
pagerank = nx.pagerank(G)
Community Detection:
from networkx.algorithms import community
# Specify weight=None for unweighted topology
communities = community.greedy_modularity_communities(G, weight=None)
Connectivity:
# Check connectivity
is_connected = nx.is_connected(G)
# Find connected components
components = list(nx.connected_components(G))
Reference: See references/algorithms.md for worked API patterns for common algorithms including shortest paths, centrality measures, clustering, community detection, flows, matching, tree algorithms, and graph traversal.
3. Graph Generators
Create synthetic networks for testing, simulation, or modeling:
Classic Graphs:
# Complete graph
G = nx.complete_graph(n=10)
# Cycle graph
G = nx.cycle_graph(n=20)
# Known graphs
G = nx.karate_club_graph()
G = nx.petersen_graph()
Random Networks:
…
FAQ
What are nodes and edges?
Nodes are the individual points in the network (like people in a social network), and edges are the connections between these points (like friendships).
Can I use real-world data?
Yes, you can load data from files like connection lists, CSV, or other formats to create your networks.
Can the tool draw the network?
Yes, it can generate graphical visualizations of the network to help understand its structure.
Details
Original description by the author
Creates, analyzes, and visualizes complex networks and graphs in Python with NetworkX. Use when working with network/graph data structures, computing graph algorithms (shortest paths, centrality, clustering), detecting communities, generating synthetic networks (random, scale-free, small-world), reading/writing graph file formats, or drawing network topologies. Common applications include social,
Popularity
- GitHub stars
- 51k
- Ranking position
- #1911
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
13c-metabolic-flux
Estimates metabolic fluxes using carbon-13 isotope tracing data. It is useful for analyzing cellular metabolism and biochemical pathways.
K-Dense-AI/scientific-agent-skills
adaptyv
Designs protein characterization experiments using the Adaptyv API. It helps estimate costs, submit sequences, and monitor lab results.
K-Dense-AI/scientific-agent-skills
aeon
Performs machine learning tasks on time series data. It is useful for classifying, forecasting, detecting anomalies, and finding patterns in sequential data.
K-Dense-AI/scientific-agent-skills
alphagenome
Looks up precomputed genomic effects for genetic variants. It provides scores and explanations to understand the impact of variants on the genome.
K-Dense-AI/scientific-agent-skills
Similar skills
data-throughput-accelerator
Makes your agent speed up the movement of large data volumes. It finds bottlenecks and ensures data is transferred quickly and correctly.
affaan-m/ECC
inventory-demand-planning
Helps your agent predict product demand in stores. It optimizes stock and plans when to run promotions to sell more.
affaan-m/ECC
market-research
Helps your agent conduct market research and competitive analysis. Provides summaries with source attribution.
affaan-m/ECC