技能 networkx
📊

networkx

安全 📁 文件系统访问🌐 网络访问

Create and analyze complex networks

也可从以下获取: K-Dense-AI

Working with network and graph data requires understanding graph algorithms, visualization techniques, and data formats. This skill provides comprehensive guidance on using NetworkX for creating, analyzing, and visualizing complex networks in Python.

支持: Claude Codex Code(CC)
📊 71 充足
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“networkx”。 Create a graph with 5 nodes connected in a cycle and compute the shortest path from node 1 to node 5

预期结果:

Path found: [1, 2, 3, 4, 5] with length 4

正在使用“networkx”。 Find the node with highest betweenness centrality in a social network

预期结果:

User 'alice' has the highest betweenness centrality (0.45), indicating significant influence in connecting different groups

正在使用“networkx”。 Generate a scale-free network with 100 nodes

预期结果:

Generated Barabasi-Albert graph with 100 nodes and 297 edges using preferential attachment

安全审计

安全
v6 • 1/21/2026

All static findings are false positives. The skill is a documentation/reference guide for NetworkX (Python graph library). Static scanner flagged markdown code formatting backticks as 'shell execution' and documentation about file I/O operations as 'filesystem access'. No malicious code, credential access, or command injection exists. The skill provides safe Python graph processing guidance.

7
已扫描文件
6,916
分析行数
2
发现项
6
审计总数
审计者: claude 查看审计历史 →

质量评分

45
架构
100
可维护性
87
内容
20
社区
100
安全
91
规范符合性

你能构建什么

Analyze social network relationships

Build and analyze social network graphs to identify influential users, detect communities, and find connection patterns.

Model biological networks

Create protein interaction networks, gene regulatory networks, or neural connectivity maps for biological research.

Optimize infrastructure routes

Find shortest paths, design efficient transportation networks, and analyze connectivity in infrastructure systems.

试试这些提示

Getting Started
How do I create a basic graph using NetworkX and add nodes and edges with attributes?
Finding Paths
Find the shortest path between two nodes in my graph and calculate the total distance considering edge weights.
Analyzing Influence
Compute centrality measures (betweenness, degree, PageRank) to identify the most influential nodes in my network.
Community Detection
Detect communities in my graph using modularity-based methods and visualize the results with different colors for each community.

最佳实践

  • Set random seeds (seed=42) when generating random graphs or layouts for reproducibility
  • Use appropriate graph types (Graph, DiGraph, MultiGraph) based on whether edges are directed and if multiple edges exist
  • Choose efficient file formats like GraphML for preserving attributes or pickle for large Python objects

避免

  • Avoid using floating-point numbers as node identifiers due to precision comparison issues
  • Do not attempt to draw very large graphs (>1000 nodes) without filtering or clustering first
  • Avoid modifying a graph while iterating over its nodes or edges without creating a copy first

常见问题

What graph types does NetworkX support?
NetworkX supports Graph (undirected), DiGraph (directed), MultiGraph (undirected with multiple edges), and MultiDiGraph (directed with multiple edges).
How do I read a graph from a file?
Use functions like nx.read_edgelist() for simple edge lists, nx.read_graphml() for GraphML format, or nx.read_gml() for GML format.
What algorithms are available for finding important nodes?
Common centrality measures include degree_centrality, betweenness_centrality, closeness_centrality, and PageRank for directed graphs.
How do I detect communities in a network?
Use community.greedy_modularity_communities() or community.louvain_communities() to detect groups of densely connected nodes.
Can I visualize graphs with custom colors and sizes?
Yes, use node_color for colors (based on attributes or degrees), node_size for sizing, and width for edge thickness in nx.draw().
What file formats are supported for graph I/O?
Supported formats include edge lists, GraphML, GML, JSON, CSV, adjacency matrices, Pandas DataFrames, and SQLite databases.