Chuyển đến nội dung
Skillpedia
Học máy48k · #5292

networkx

Skill này làm gì

NetworkX là công cụ để tạo, phân tích và trực quan hóa mạng và đồ thị. Hãy nghĩ đến mạng xã hội, bản đồ giao thông hay bất cứ thứ gì có các kết nối giữa các mục.

Khi nào nên dùng

  • ✓Khi tạo bản đồ kết nối giữa bạn bè.
  • ✓Khi phân tích đường đi ngắn nhất giữa hai điểm trên bản đồ.
  • ✓Khi tạo một mạng xã hội hư cấu cho trò chơi.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/networkx/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/networkx/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tạo một đồ thị thể hiện các kết nối giữa các thành phố trên tuyến xe buýt, thêm thời gian di chuyển làm thuộc tính cạnh.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Bạn mô tả các mục (nút) và cách chúng kết nối (cạnh). NetworkX dùng thông tin này để xây dựng mạng và cho phép bạn phân tích theo nhiều cách.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Bundled upstream support

Supporting files are included at skill-relative paths. See UPSTREAM-NOTICE.md for their pinned sources, licenses, hashes, and import changes.

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.

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:

# Find shortest path
path = nx.shortest_path(G, source=1, target=5)
length = nx.shortest_path_length(G, source=1, target=5, weight='weight')

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

# Detect communities
communities = community.greedy_modularity_communities(G)

Connectivity:

# Check connectivity
is_connected = nx.is_connected(G)

# Find connected components
components = list(nx.connected_components(G))

Reference: See references/algorithms.md for detailed documentation on all available 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:

# Erdős-Rényi random graph
G = nx.erdos_renyi_graph(n=100, p=0.1, seed=42)

# Barabási-Albert scale-free network
G = nx.barabasi_albert_graph(n=100, m=3, seed=42)

# Watts-Strogatz small-world network
G = nx.watts_strogatz_graph(n=100, k=6, p=0.1, seed=42)

Structured Networks:

# Grid graph
G = nx.grid_2d_graph(m=5, n=7)

# Random tree
G = nx.random_tree(n=100, seed=42)

Reference: See references/generators.md for comprehensive coverage of all graph generators including classic, random, lattice, bipartite, and specialized network models with detailed parameters and use cases.

4. Reading and Writing Graphs

NetworkX supports numerous file formats and data sources:

File Formats:

# Edge list
G = nx.read_edgelist('graph.edgelist')
nx.write_edgelist(G, 'graph.edgelist')

# GraphML (preserves attributes)

…
Câu hỏi thường gặp

Node và edge là gì?

Node là các mục riêng lẻ trong mạng (như người trong mạng xã hội), còn edge là các kết nối giữa chúng (như tình bạn).

Tôi có thể thêm thông tin vào các kết nối không?

Có, bạn có thể thêm 'thuộc tính' cho edge, như trọng số, khoảng cách hoặc loại quan hệ.

NetworkX có vẽ được mạng không?

Có, nó có thể tạo hình ảnh trực quan của mạng, giúp bạn hiểu cấu trúc và các kết nối.

Chi tiết

Mô tả gốc của tác giả

NetworkX is a Python package for creating, manipulating, and analyzing complex networks and graphs.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5292
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự