networkx-social
Social network and graph analysis via NetworkX. Use when: graph analysis, community detection, centrality measures, network visualization, knowledge graphs, bipartite networks, graph I/O. NOT for: large-scale graph processing (>1M nodes), GPU graph analytics (use cuGraph).
Best use case
networkx-social is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Social network and graph analysis via NetworkX. Use when: graph analysis, community detection, centrality measures, network visualization, knowledge graphs, bipartite networks, graph I/O. NOT for: large-scale graph processing (>1M nodes), GPU graph analytics (use cuGraph).
Teams using networkx-social should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/networkx-social/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How networkx-social Compares
| Feature / Agent | networkx-social | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Social network and graph analysis via NetworkX. Use when: graph analysis, community detection, centrality measures, network visualization, knowledge graphs, bipartite networks, graph I/O. NOT for: large-scale graph processing (>1M nodes), GPU graph analytics (use cuGraph).
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# NetworkX Graph Analysis
Graph analysis, community detection, centrality measures, knowledge graphs, bipartite networks, and visualization.
## Graph Creation
```python
import networkx as nx
G = nx.Graph()
G.add_edge('Alice', 'Bob', weight=3)
G.add_edges_from([('Bob', 'Carol'), ('Carol', 'Dave'), ('Alice', 'Dave')])
D = nx.DiGraph() # directed graph
G = nx.read_edgelist('network.txt') # from edge list file
G = nx.from_pandas_edgelist(df, 'source', 'target') # from DataFrame
```
## Knowledge Graph Construction
```python
# Build a knowledge graph from (subject, predicate, object) triples
KG = nx.DiGraph()
triples = [
("Python", "is_a", "Language"), ("Pandas", "depends_on", "Python"),
("NumPy", "depends_on", "Python"), ("Pandas", "depends_on", "NumPy"),
]
for subj, pred, obj in triples:
KG.add_edge(subj, obj, relation=pred)
# Query: all dependencies of Pandas
deps = list(nx.descendants(KG, "Pandas"))
# Subgraph around a node (ego graph)
ego = nx.ego_graph(KG, "Python", radius=2, undirected=True)
```
## Centrality Measures
```python
dc = nx.degree_centrality(G) # fraction of connected nodes
bc = nx.betweenness_centrality(G) # shortest-path intermediary
cc = nx.closeness_centrality(G) # inverse avg distance
ec = nx.eigenvector_centrality(G, max_iter=1000) # neighbor importance
pr = nx.pagerank(D, alpha=0.85) # PageRank (directed)
for node, score in sorted(bc.items(), key=lambda x: -x[1])[:5]:
print(f"{node}: {score:.4f}")
```
## Community Detection
```python
from networkx.algorithms.community import louvain_communities, modularity
from networkx.algorithms.community import label_propagation_communities, greedy_modularity_communities
communities = louvain_communities(G, seed=42) # modularity optimization
communities = list(label_propagation_communities(G)) # fast, non-deterministic
greedy = list(greedy_modularity_communities(G)) # greedy modularity
mod = modularity(G, communities)
print(f"Modularity: {mod:.4f}")
```
## Shortest Paths and Distances
```python
path = nx.shortest_path(G, source='Alice', target='Dave')
length = nx.shortest_path_length(G, source='Alice', target='Dave')
if nx.is_connected(G):
diameter = nx.diameter(G)
avg_path = nx.average_shortest_path_length(G)
```
## Clustering and Connectivity
```python
avg_cc = nx.average_clustering(G)
transitivity = nx.transitivity(G) # global clustering
components = list(nx.connected_components(G))
largest_cc = G.subgraph(max(components, key=len)).copy()
core_numbers = nx.core_number(G)
```
## Bipartite Graphs and Projections
```python
from networkx.algorithms import bipartite
B = nx.Graph()
B.add_nodes_from(["u1", "u2", "u3"], bipartite=0) # users
B.add_nodes_from(["p1", "p2"], bipartite=1) # products
B.add_edges_from([("u1", "p1"), ("u2", "p1"), ("u2", "p2"), ("u3", "p2")])
users = {n for n, d in B.nodes(data=True) if d["bipartite"] == 0}
user_graph = bipartite.projected_graph(B, users) # shared neighbors become edges
weighted_proj = bipartite.weighted_projected_graph(B, users)
```
## Network Visualization
```python
import matplotlib.pyplot as plt
pos = nx.spring_layout(G, seed=42, k=1.5)
node_sizes = [3000 * dc[n] for n in G.nodes()]
color_map = {n: i for i, comm in enumerate(communities) for n in comm}
nx.draw_networkx(G, pos, node_size=node_sizes,
node_color=[color_map.get(n, 0) for n in G.nodes()],
cmap=plt.cm.Set3, edge_color='gray', alpha=0.8, font_size=9)
plt.tight_layout()
plt.savefig('network.png', dpi=150)
plt.close()
# Other layouts: nx.circular_layout, nx.kamada_kawai_layout, nx.shell_layout
```
## Graph I/O
```python
# GraphML (XML-based, preserves attributes)
nx.write_graphml(G, 'graph.graphml')
G = nx.read_graphml('graph.graphml')
# GEXF (Gephi format)
nx.write_gexf(G, 'graph.gexf')
G = nx.read_gexf('graph.gexf')
# JSON (node-link format)
from networkx.readwrite import json_graph
import json
data = json_graph.node_link_data(G)
json.dump(data, open('graph.json', 'w'))
G = json_graph.node_link_graph(json.load(open('graph.json')))
```
## Best Practices
1. Use `G.copy()` before destructive operations (node/edge removal).
2. For large graphs, prefer `louvain_communities` over `girvan_newman`.
3. Set `seed` in layout functions for reproducible visualizations.
4. Check `nx.is_connected(G)` before computing diameter or avg path length.
5. For weighted networks, pass `weight='weight'` to centrality functions.
6. For knowledge graphs, use `DiGraph` and store relation types as edge attributes.
7. Export to GraphML or GEXF for interoperability with Gephi and other tools.Related Skills
social-science-research
Orchestrates a social science research workflow from literature review through data collection, text analysis, statistical modeling, and report generation. Use when conducting empirical social science research, policy analysis, or mixed-methods studies. NOT for pure natural science analysis or clinical trial data.
social-science-analysis
Social science research methods including survey design, qualitative analysis, content analysis, network analysis, psychometrics, and mixed methods. Covers sociology, psychology, political science, education, and communication studies. Use when user designs surveys, analyzes qualitative data, does content analysis, builds scales, or uses mixed methods. Triggers on "survey design", "qualitative analysis", "content analysis", "Likert scale", "thematic analysis", "grounded theory", "factor analysis", "SEM", "structural equation", "psychometrics", "interview coding".
networkx
Comprehensive toolkit for creating, analyzing, and visualizing complex networks and graphs in Python. Use when working with network/graph data structures, analyzing relationships between entities, computing graph algorithms (shortest paths, centrality, clustering), detecting communities, generating synthetic networks, or visualizing network topologies. Applicable to social networks, biological networks, transportation systems, citation networks, and any domain involving pairwise relationships.
xurl
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
xlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.
writing
No description provided.
world-bank-data
World Bank Open Data API for development indicators. Use when: user asks about GDP, population, poverty, health, or education statistics by country. NOT for: real-time financial data or stock prices.
wikipedia-search
Search and fetch structured content from Wikipedia using the MediaWiki API for reliable, encyclopedic information
wikidata-knowledge
Query Wikidata for structured knowledge using SPARQL and entity search. Use when: (1) finding structured facts about entities (people, places, organizations), (2) querying relationships between entities, (3) cross-referencing external identifiers (Wikipedia, VIAF, GND, ORCID), (4) building knowledge graphs from linked data. NOT for: full-text article content (use Wikipedia API), scientific literature (use semantic-scholar), geospatial data (use OpenStreetMap).
weather
Get current weather and forecasts via wttr.in or Open-Meteo. Use when: user asks about weather, temperature, or forecasts for any location. NOT for: historical weather data, severe weather alerts, or detailed meteorological analysis. No API key needed.
wacli
Send WhatsApp messages to other people or search/sync WhatsApp history via the wacli CLI (not for normal user chats).
voice-call
Start voice calls via the OpenClaw voice-call plugin.