networkx
Build, analyze, and visualize networks and graphs using NetworkX (Python). Use this skill whenever the user wants to: create graphs or networks, analyze graph properties, compute centrality measures, find shortest paths, detect communities, run graph algorithms, convert graphs to/from matrices or dataframes, visualize networks with matplotlib, import/export graph files (GML, GraphML, GEXF, edgelist, etc.), work with directed or undirected graphs, weighted or multigraphs, perform social network analysis, or do any graph theory computation. Trigger on keywords: networkx, graph, network, nodes, e
npx skills add SenolIsci/mykg --skill networkx --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Instructs the agent to perform comprehensive graph creation, manipulation, and analysis using NetworkX. It covers choosing the correct graph class, building graphs (adding nodes and edges with attributes), removing elements, and setting graph-level attributes. It includes inspecting graphs (nodes, edges, degree, adjacency), handling multi-graphs, and working with directed/undirected, weighted or unweighted graphs.
It details operations for graph views, subgraphs, and typical graph generators (classic, random, social network datasets, geometric). It prescribes computing shortest paths, centrality measures, and various community detection methods. It lists numerous graph analysis algorithms (connectivity, spanning trees, cycles, DAG operations, cliques, flows, matching, properties, coloring, link prediction, graph operators, traversal).
The skill instructs on converting graphs between representations (NumPy arrays, SciPy sparse, Pandas DataFrame/edgelist, dicts, lists, edge lists) and on Graph I/O formats (GraphML, GML, GEXF, edge lists).
Overall, it guides the agent to implement graph analytics workflows entirely within NetworkX, using explicit function calls and class choices to match user tasks.
How it works
The agent should: import networkx as nx, select the appropriate class (nx.Graph, nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph) depending on social networks, web graphs, or multiple edges; add nodes with add_node(s) and edges with add_edge(s), possibly with attributes; inspect graphs via number_of_nodes, number_of_edges, nodes, edges, adj; manage node/edge attributes with get/set; create subgraphs, views, and reverse DiGraph; use nx.add_path, nx.add_cycle, nx.add_star for structural additions; generate graphs using nx.complete_graph, nx.erdos_renyi_graph, etc.; compute shortest paths with nx.shortest_path and related functions; compute centrality with degree_centrality, betweenness_centrality, etc.; detect communities via community module functions; run graph analysis algorithms like is_connected, is_tree, minimum_spanning_tree, topological_sort, and many others; convert between representations using nx.to_numpy_array, nx.from_numpy_array, nx.to_pandas_adjacency, nx.from_pandas_adjacency, and others; read/write formats with nx.write_graphml, nx.read_graphml, nx.write_gml, nx.read_gml, nx.write_gexf, nx.read_gexf, and edge list forms.
When to use it
Use when the user needs to create, analyze, or visualize graphs, compute centrality or shortest paths, detect communities, run graph algorithms, or convert/import/export graphs across formats, for both directed and undirected, weighted or unweighted, including multi-graphs.
What it can touch
The skill uses allowed-tools: Bash Read Write Edit. It prescribes using NetworkX functions via Python code, including nx.* calls for graph construction, inspection, analysis, conversion, and I/O. It touches file I/O for GraphML, GML, GEXF, and edgelist formats.
Caveats
License: MIT. The skill emphasizes explicit, step-by-step explicit code over clever tricks and references external algorithm/docs for details.
# NetworkX Skill — Create and Manipulate Networks NetworkX (v3.6+) is the standard Python library for graph analysis. This skill covers everything from basic graph creation to advanced algorithms. When in doubt, prefer simple explicit code over clever one-liners — graphs are complex enough on their own. **References:** - [algorithms.md](references/algorithms.md) — Algorithm reference by category (centrality, community, flow, etc.) - [io.md](references/io.md) — File I/O and format conversion reference --- ## 1. Choosing a Graph Class Pick the right class first — it cannot easily be changed after construction. ```python import networkx as nx G = nx.Graph() # undirected, no parallel edges DG = nx.DiGraph() # directed, no parallel edges MG = nx.MultiGraph() # undirected + parallel edges allowed MD = nx.MultiDiGraph() # directed + parallel edges allowed ``` | Need | Class | |---|---| | Social networks, protein interactions | `Graph` | | Web graphs, citation networks, DAGs | `DiGraph` | | Transport networks (multiple routes) | `MultiGraph` | | Dependency graphs with typed edges | `MultiDiGraph` | Convert between types: ```python DG = G.to_directed() # Graph → DiGraph (each edge becomes t
- 1. Choosing a Graph Class
- 2. Building Graphs
- Add Nodes
- Add Edges
- Remove Nodes and Edges
- Graph-Level Attributes
- 3. Inspecting a Graph
- Node/Edge Membership
- 4. Attributes: Read and Write
- 5. Graph Views and Subgraphs
- 6. Graph Generators
- Classic
- Random
- Social Network Datasets
pip install networkx pip install networkx[default] # includes matplotlib, scipy, numpy, pandas pip install networkx[extra] # adds pydot, lxml, gdal
What does the networkx skill do?
Build, analyze, and visualize networks and graphs using NetworkX (Python). Use this skill whenever the user wants to: create graphs or networks, analyze graph properties, compute centrality measures, find shortest paths, detect communities, run graph algorithms, convert graphs to/from matrices or dataframes, visualize networks with matplotlib, import/export graph files (GML, GraphML, GEXF, edgelist, etc.), work with directed or undirected graphs, weighted or multigraphs, perform social network analysis, or do any graph theory computation. Trigger on keywords: networkx, graph, network, nodes, e
How do I install it?
Run `npx skills add SenolIsci/mykg --skill networkx --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From SenolIsci/mykg, a repository with 63 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
