[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BK6FTTATEV70FRJDAFVGS9":3,"skill-same:01M7BK6FTTATEV70FRJDAFVGS9":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7BK6FTTATEV70FRJDAFVGS9","networkx",null,"Comprehensive toolkit for creating, analyzing, and visualizing complex networks and graphs in Python. Use when working with network\u002Fgraph 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.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-code-templates-main\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: networkx\ndescription: Comprehensive toolkit for creating, analyzing, and visualizing complex networks and graphs in Python. Use when working with network\u002Fgraph 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.\n---\n\n# NetworkX\n\n## Overview\n\nNetworkX 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.\n\n## When to Use This Skill\n\nInvoke this skill when tasks involve:\n\n- **Creating graphs**: Building network structures from data, adding nodes and edges with attributes\n- **Graph analysis**: Computing centrality measures, finding shortest paths, detecting communities, measuring clustering\n- **Graph algorithms**: Running standard algorithms like Dijkstra's, PageRank, minimum spanning trees, maximum flow\n- **Network generation**: Creating synthetic networks (random, scale-free, small-world models) for testing or simulation\n- **Graph I\u002FO**: Reading from or writing to various formats (edge lists, GraphML, JSON, CSV, adjacency matrices)\n- **Visualization**: Drawing and customizing network visualizations with matplotlib or interactive libraries\n- **Network comparison**: Checking isomorphism, computing graph metrics, analyzing structural properties\n\n## Core Capabilities\n\n### 1. Graph Creation and Manipulation\n\nNetworkX supports four main graph types:\n- **Graph**: Undirected graphs with single edges\n- **DiGraph**: Directed graphs with one-way connections\n- **MultiGraph**: Undirected graphs allowing multiple edges between nodes\n- **MultiDiGraph**: Directed graphs with multiple edges\n\nCreate graphs by:\n```python\nimport networkx as nx\n\n# Create empty graph\nG = nx.Graph()\n\n# Add nodes (can be any hashable type)\nG.add_node(1)\nG.add_nodes_from([2, 3, 4])\nG.add_node(\"protein_A\", type='enzyme', weight=1.5)\n\n# Add edges\nG.add_edge(1, 2)\nG.add_edges_from([(1, 3), (2, 4)])\nG.add_edge(1, 4, weight=0.8, relation='interacts')\n```\n\n**Reference**: See `references\u002Fgraph-basics.md` for comprehensive guidance on creating, modifying, examining, and managing graph structures, including working with attributes and subgraphs.\n\n### 2. Graph Algorithms\n\nNetworkX provides extensive algorithms for network analysis:\n\n**Shortest Paths**:\n```python\n# Find shortest path\npath = nx.shortest_path(G, source=1, target=5)\nlength = nx.shortest_path_length(G, source=1, target=5, weight='weight')\n```\n\n**Centrality Measures**:\n```python\n# Degree centrality\ndegree_cent = nx.degree_centrality(G)\n\n# Betweenness centrality\nbetweenness = nx.betweenness_centrality(G)\n\n# PageRank\npagerank = nx.pagerank(G)\n```\n\n**Community Detection**:\n```python\nfrom networkx.algorithms import community\n\n# Detect communities\ncommunities = community.greedy_modularity_communities(G)\n```\n\n**Connectivity**:\n```python\n# Check connectivity\nis_connected = nx.is_connected(G)\n\n# Find connected components\ncomponents = list(nx.connected_components(G))\n```\n\n**Reference**: See `references\u002Falgorithms.md` for detailed documentation on all available algorithms including shortest paths, centrality measures, clustering, community detection, flows, matching, tree algorithms, and graph traversal.\n\n### 3. Graph Generators\n\nCreate synthetic networks for testing, simulation, or modeling:\n\n**Classic Graphs**:\n```python\n# Complete graph\nG = nx.complete_graph(n=10)\n\n# Cycle graph\nG = nx.cycle_graph(n=20)\n\n# Known graphs\nG = nx.karate_club_graph()\nG = nx.petersen_graph()\n```\n\n**Random Networks**:\n```python\n# Erdős-Rényi random graph\nG = nx.erdos_renyi_graph(n=100, p=0.1, seed=42)\n\n# Barabási-Albert scale-free network\nG = nx.barabasi_albert_graph(n=100, m=3, seed=42)\n\n# Watts-Strogatz small-world network\nG = nx.watts_strogatz_graph(n=100, k=6, p=0.1, seed=42)\n```\n\n**Structured Networks**:\n```python\n# Grid graph\nG = nx.grid_2d_graph(m=5, n=7)\n\n# Random tree\nG = nx.random_tree(n=100, seed=42)\n```\n\n**Reference**: See `references\u002Fgenerators.md` for comprehensive coverage of all graph generators including classic, random, lattice, bipartite, and specialized network models with detailed parameters and use cases.\n\n### 4. Reading and Writing Graphs\n\nNetworkX supports numerous file formats and data sources:\n\n**File Formats**:\n```python\n# Edge list\nG = nx.read_edgelist('graph.edgelist')\nnx.write_edgelist(G, 'graph.edgelist')\n\n# GraphML (preserves attributes)\nG = nx.read_graphml('graph.graphml')\nnx.write_graphml(G, 'graph.graphml')\n\n# GML\nG = nx.read_gml('graph.gml')\nnx.write_gml(G, 'graph.gml')\n\n# JSON\ndata = nx.node_link_data(G)\nG = nx.node_link_graph(data)\n```\n\n**Pandas Integration**:\n```python\nimport pandas as pd\n\n# From DataFrame\ndf = pd.DataFrame({'source': [1, 2, 3], 'target': [2, 3, 4], 'weight': [0.5, 1.0, 0.75]})\nG = nx.from_pandas_edgelist(df, 'source', 'target', edge_attr='weight')\n\n# To DataFrame\ndf = nx.to_pandas_edgelist(G)\n```\n\n**Matrix Formats**:\n```python\nimport numpy as np\n\n# Adjacency matrix\nA = nx.to_numpy_array(G)\nG = nx.from_numpy_array(A)\n\n# Sparse matrix\nA = nx.to_scipy_sparse_array(G)\nG = nx.from_scipy_sparse_array(A)\n```\n\n**Reference**: See `references\u002Fio.md` for complete documentation on all I\u002FO formats including CSV, SQL databases, Cytoscape, DOT, and guidance on format selection for different use cases.\n\n### 5. Visualization\n\nCreate clear and informative network visualizations:\n\n**Basic Visualization**:\n```python\nimport matplotlib.pyplot as plt\n\n# Simple draw\nnx.draw(G, with_labels=True)\nplt.show()\n\n# With layout\npos = nx.spring_layout(G, seed=42)\nnx.draw(G, pos=pos, with_labels=True, node_color='lightblue', node_size=500)\nplt.show()\n```\n\n**Customization**:\n```python\n# Color by degree\nnode_colors = [G.degree(n) for n in G.nodes()]\nnx.draw(G, node_color=node_colors, cmap=plt.cm.viridis)\n\n# Size by centrality\ncentrality = nx.betweenness_centrality(G)\nnode_sizes = [3000 * centrality[n] for n in G.nodes()]\nnx.draw(G, node_size=node_sizes)\n\n# Edge weights\nedge_widths = [3 * G[u][v].get('weight', 1) for u, v in G.edges()]\nnx.draw(G, width=edge_widths)\n```\n\n**Layout Algorithms**:\n```python\n# Spring layout (force-directed)\npos = nx.spring_layout(G, seed=42)\n\n# Circular layout\npos = nx.circular_layout(G)\n\n# Kamada-Kawai layout\npos = nx.kamada_kawai_layout(G)\n\n# Spectral layout\npos = nx.spectral_layout(G)\n```\n\n**Publication Quality**:\n```python\nplt.figure(figsize=(12, 8))\npos = nx.spring_layout(G, seed=42)\nnx.draw(G, pos=pos, node_color='lightblue', node_size=500,\n        edge_color='gray', with_labels=True, font_size=10)\nplt.title('Network Visualization', fontsize=16)\nplt.axis('off')\nplt.tight_layout()\nplt.savefig('network.png', dpi=300, bbox_inches='tight')\nplt.savefig('network.pdf', bbox_inches='tight')  # Vector format\n```\n\n**Reference**: See `references\u002Fvisualization.md` for extensive documentation on visualization techniques including layout algorithms, customization options, interactive visualizations with Plotly and PyVis, 3D networks, and publication-quality figure creation.\n\n## Working with NetworkX\n\n### Installation\n\nEnsure NetworkX is installed:\n```python\n# Check if installed\nimport networkx as nx\nprint(nx.__version__)\n\n# Install if needed (via bash)\n# uv pip install networkx\n# uv pip install networkx[default]  # With optional dependencies\n```\n\n### Common Workflow Pattern\n\nMost NetworkX tasks follow this pattern:\n\n1. **Create or Load Graph**:\n   ```python\n   # From scratch\n   G = nx.Graph()\n   G.add_edges_from([(1, 2), (2, 3), (3, 4)])\n\n   # Or load from file\u002Fdata\n   G = nx.read_edgelist('data.txt')\n   ```\n\n2. **Examine Structure**:\n   ```python\n   print(f\"Nodes: {G.number_of_nodes()}\")\n   print(f\"Edges: {G.number_of_edges()}\")\n   print(f\"Density: {nx.density(G)}\")\n   print(f\"Connected: {nx.is_connected(G)}\")\n   ```\n\n3. **Analyze**:\n   ```python\n   # Compute metrics\n   degree_cent = nx.degree_centrality(G)\n   avg_clustering = nx.average_clustering(G)\n\n   # Find paths\n   path = nx.shortest_path(G, source=1, target=4)\n\n   # Detect communities\n   communities = community.greedy_modularity_communities(G)\n   ```\n\n4. **Visualize**:\n   ```python\n   pos = nx.spring_layout(G, seed=42)\n   nx.draw(G, pos=pos, with_labels=True)\n   plt.show()\n   ```\n\n5. **Export Results**:\n   ```python\n   # Save graph\n   nx.write_graphml(G, 'analyzed_network.graphml')\n\n   # Save metrics\n   df = pd.DataFrame({\n       'node': list(degree_cent.keys()),\n       'centrality': list(degree_cent.values())\n   })\n   df.to_csv('centrality_results.csv', index=False)\n   ```\n\n### Important Considerations\n\n**Floating Point Precision**: When graphs contain floating-point numbers, all results are inherently approximate due to precision limitations. This can affect algorithm outcomes, particularly in minimum\u002Fmaximum computations.\n\n**Memory and Performance**: Each time a script runs, graph data must be loaded into memory. For large networks:\n- Use appropriate data structures (sparse matrices for large sparse graphs)\n- Consider loading only necessary subgraphs\n- Use efficient file formats (pickle for Python objects, compressed formats)\n- Leverage approximate algorithms for very large networks (e.g., `k` parameter in centrality calculations)\n\n**Node and Edge Types**:\n- Nodes can be any hashable Python object (numbers, strings, tuples, custom objects)\n- Use meaningful identifiers for clarity\n- When removing nodes, all incident edges are automatically removed\n\n**Random Seeds**: Always set random seeds for reproducibility in random graph generation and force-directed layouts:\n```python\nG = nx.erdos_renyi_graph(n=100, p=0.1, seed=42)\npos = nx.spring_layout(G, seed=42)\n```\n\n## Quick Reference\n\n### Basic Operations\n```python\n# Create\nG = nx.Graph()\nG.add_edge(1, 2)\n\n# Query\nG.number_of_nodes()\nG.number_of_edges()\nG.degree(1)\nlist(G.neighbors(1))\n\n# Check\nG.has_node(1)\nG.has_edge(1, 2)\nnx.is_connected(G)\n\n# Modify\nG.remove_node(1)\nG.remove_edge(1, 2)\nG.clear()\n```\n\n### Essential Algorithms\n```python\n# Paths\nnx.shortest_path(G, source, target)\nnx.all_pairs_shortest_path(G)\n\n# Centrality\nnx.degree_centrality(G)\nnx.betweenness_centrality(G)\nnx.closeness_centrality(G)\nnx.pagerank(G)\n\n# Clustering\nnx.clustering(G)\nnx.average_clustering(G)\n\n# Components\nnx.connected_components(G)\nnx.strongly_connected_components(G)  # Directed\n\n# Community\ncommunity.greedy_modularity_communities(G)\n```\n\n### File I\u002FO Quick Reference\n```python\n# Read\nnx.read_edgelist('file.txt')\nnx.read_graphml('file.graphml')\nnx.read_gml('file.gml')\n\n# Write\nnx.write_edgelist(G, 'file.txt')\nnx.write_graphml(G, 'file.graphml')\nnx.write_gml(G, 'file.gml')\n\n# Pandas\nnx.from_pandas_edgelist(df, 'source', 'target')\nnx.to_pandas_edgelist(G)\n```\n\n## Resources\n\nThis skill includes comprehensive reference documentation:\n\n### references\u002Fgraph-basics.md\nDetailed guide on graph types, creating and modifying graphs, adding nodes and edges, managing attributes, examining structure, and working with subgraphs.\n\n### references\u002Falgorithms.md\nComplete coverage of NetworkX algorithms including shortest paths, centrality measures, connectivity, clustering, community detection, flow algorithms, tree algorithms, matching, coloring, isomorphism, and graph traversal.\n\n### references\u002Fgenerators.md\nComprehensive documentation on graph generators including classic graphs, random models (Erdős-Rényi, Barabási-Albert, Watts-Strogatz), lattices, trees, social network models, and specialized generators.\n\n### references\u002Fio.md\nComplete guide to reading and writing graphs in various formats: edge lists, adjacency lists, GraphML, GML, JSON, CSV, Pandas DataFrames, NumPy arrays, SciPy sparse matrices, database integration, and format selection guidelines.\n\n### references\u002Fvisualization.md\nExtensive documentation on visualization techniques including layout algorithms, customizing node and edge appearance, labels, interactive visualizations with Plotly and PyVis, 3D networks, bipartite layouts, and creating publication-quality figures.\n\n## Additional Resources\n\n- **Official Documentation**: https:\u002F\u002Fnetworkx.org\u002Fdocumentation\u002Flatest\u002F\n- **Tutorial**: https:\u002F\u002Fnetworkx.org\u002Fdocumentation\u002Flatest\u002Ftutorial.html\n- **Gallery**: https:\u002F\u002Fnetworkx.org\u002Fdocumentation\u002Flatest\u002Fauto_examples\u002Findex.html\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Fnetworkx\u002Fnetworkx\n","# NetworkX\n\n## Overview\n\nNetworkX 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.\n\n## When to Use This Skill\n\nInvoke this skill when tasks involve:\n\n- **Creating graphs**: Building network structures from data, adding nodes and edges with attributes\n- **Graph analysis**: Computing centrality measures, finding shortest paths, detecting communities, measuring clustering\n- **Graph algorithms**: Running standard algorithms like Dijkstra's, PageRank, minimum spanning trees, maximum flow\n- **Network generation**: Creating synthetic networks (random, scale-free, small-world models) for testing or simulation\n- **Graph I\u002FO**: Reading from or writing to various formats (edge lists, GraphML, JSON, CSV, adjacency matrices)\n- **Visualization**: Drawing and customizing network visualizations with matplotlib or interactive libraries\n- **Network comparison**: Checking isomorphism, computing graph metrics, analyzing structural properties\n\n## Core Capabilities\n\n### 1. Graph Creation and Manipulation\n\nNetworkX supports four main graph types:\n- **Graph**: Undirected graphs with single edges\n- **DiGraph**: Directed graphs with one-way connections\n- **MultiGraph**: Undirected graphs allowing multiple edges between nodes\n- **MultiDiGraph**: Directed graphs with multiple edges\n\nCreate graphs by:\n```python\nimport networkx as nx\n\n# Create empty graph\nG = nx.Graph()\n\n# Add nodes (can be any hashable type)\nG.add_node(1)\nG.add_nodes_from([2, 3, 4])\nG.add_node(\"protein_A\", type='enzyme', weight=1.5)\n\n# Add edges\nG.add_edge(1, 2)\nG.add_edges_from([(1, 3), (2, 4)])\nG.add_edge(1, 4, weight=0.8, relation='interacts')\n```\n\n**Reference**: See `references\u002Fgraph-basics.md` for comprehensive guidance on creating, modifying, examining, and managing graph structures, including working with attributes and subgraphs.\n\n### 2. Graph Algorithms\n\nNetworkX provides extensive algorithms for network analysis:\n\n**Shortest Paths**:\n```python\n# Find shortest path\npath = nx.shortest_path(G, source=1, target=5)\nlength = nx.shortest_path_length(G, source=1, target=5, weight='weight')\n```\n\n**Centrality Measures**:\n```python\n# Degree centrality\ndegree_cent = nx.degree_centrality(G)\n\n# Betweenness centrality\nbetweenness = nx.betweenness_centrality(G)\n\n# PageRank\npagerank = nx.pagerank(G)\n```\n\n**Community Detection**:\n```python\nfrom networkx.algorithms import community\n\n# Detect communities\ncommunities = community.greedy_modularity_communities(G)\n```\n\n**Connectivity**:\n```python\n# Check connectivity\nis_connected = nx.is_connected(G)\n\n# Find connected components\ncomponents = list(nx.connected_components(G))\n```\n\n**Reference**: See `references\u002Falgorithms.md` for detailed documentation on all available algorithms including shortest paths, centrality measures, clustering, community detection, flows, matching, tree algorithms, and graph traversal.\n\n### 3. Graph Generators\n\nCreate synthetic networks for testing, simulation, or modeling:\n\n**Classic Graphs**:\n```python\n# Complete graph\nG = nx.complete_graph(n=10)\n\n# Cycle graph\nG = nx.cycle_graph(n=20)\n\n# Known graphs\nG = nx.karate_club_graph()\nG = nx.petersen_graph()\n```\n\n**Random Networks**:\n```python\n# Erdős-Rényi random graph\nG = nx.erdos_renyi_graph(n=100, p=0.1, seed=42)\n\n# Barabási-Albert scale-free network\nG = nx.barabasi_albert_graph(n=100, m=3, seed=42)\n\n# Watts-Strogatz small-world network\nG = nx.watts_strogatz_graph(n=100, k=6, p=0.1, seed=42)\n```\n\n**Structured Networks**:\n```python\n# Grid graph\nG = nx.grid_2d_graph(m=5, n=7)\n\n# Random tree\nG = nx.random_tree(n=100, seed=42)\n```\n\n**Reference**: See `references\u002Fgenerators.md` for comprehensive coverage of all graph generators including classic, random, lattice, bipartite, and specialized network models with detailed parameters and use cases.\n\n### 4. Reading and Writing Graphs\n\nNetworkX supports numerous file formats and data sources:\n\n**File Formats**:\n```python\n# Edge list\nG = nx.read_edgelist('graph.edgelist')\nnx.write_edgelist(G, 'graph.edgelist')\n\n# GraphML (preserves attributes)\nG = nx.read_graphml('graph.graphml')\nnx.write_graphml(G, 'graph.graphml')\n\n# GML\nG = nx.read_gml('graph.gml')\nnx.write_gml(G, 'graph.gml')\n\n# JSON\ndata = nx.node_link_data(G)\nG = nx.node_link_graph(data)\n```\n\n**Pandas Integration**:\n```python\nimport pandas as pd\n\n# From DataFrame\ndf = pd.DataFrame({'source': [1, 2, 3], 'target': [2, 3, 4], 'weight': [0.5, 1.0, 0.75]})\nG = nx.from_pandas_edgelist(df, 'source', 'target', edge_attr='weight')\n\n# To DataFrame\ndf = nx.to_pandas_edgelist(G)\n```\n\n**Matrix Formats**:\n```python\nimport numpy as np\n\n# Adjacency matrix\nA = nx.to_numpy_array(G)\nG = nx.from_numpy_array(A)\n\n# Sparse matrix\nA = nx.to_scipy_sparse_array(G)\nG = nx.from_scipy_sparse_array(A)\n```\n\n**Reference**: See `references\u002Fio.md` for complete documentation on all I\u002FO formats including CSV, SQL databases, Cytoscape, DOT, and guidance on format selection for different use cases.\n\n### 5. Visualization\n\nCreate clear and informative network visualizations:\n\n**Basic Visualization**:\n```python\nimport matplotlib.pyplot as plt\n\n# Simple draw\nnx.draw(G, with_labels=True)\nplt.show()\n\n# With layout\npos = nx.spring_layout(G, seed=42)\nnx.draw(G, pos=pos, with_labels=True, node_color='lightblue', node_size=500)\nplt.show()\n```\n\n**Customization**:\n```python\n# Color by degree\nnode_colors = [G.degree(n) for n in G.nodes()]\nnx.draw(G, node_color=node_colors, cmap=plt.cm.viridis)\n\n# Size by centrality\ncentrality = nx.betweenness_centrality(G)\nnode_sizes = [3000 * centrality[n] for n in G.nodes()]\nnx.draw(G, node_size=node_sizes)\n\n# Edge weights\nedge_widths = [3 * G[u][v].get('weight', 1) for u, v in G.edges()]\nnx.draw(G, width=edge_widths)\n```\n\n**Layout Algorithms**:\n```python\n# Spring layout (force-directed)\npos = nx.spring_layout(G, seed=42)\n\n# Circular layout\npos = nx.circular_layout(G)\n\n# Kamada-Kawai layout\npos = nx.kamada_kawai_layout(G)\n\n# Spectral layout\npos = nx.spectral_layout(G)\n```\n\n**Publication Quality**:\n```python\nplt.figure(figsize=(12, 8))\npos = nx.spring_layout(G, seed=42)\nnx.draw(G, pos=pos, node_color='lightblue', node_size=500,\n        edge_color='gray', with_labels=True, font_size=10)\nplt.title('Network Visualization', fontsize=16)\nplt.axis('off')\nplt.tight_layout()\nplt.savefig('network.png', dpi=300, bbox_inches='tight')\nplt.savefig('network.pdf', bbox_inches='tight')  # Vector format\n```\n\n**Reference**: See `references\u002Fvisualization.md` for extensive documentation on visualization techniques including layout algorithms, customization options, interactive visualizations with Plotly and PyVis, 3D networks, and publication-quality figure creation.\n\n## Working with NetworkX\n\n### Installation\n\nEnsure NetworkX is installed:\n```python\n# Check if installed\nimport networkx as nx\nprint(nx.__version__)\n\n# Install if needed (via bash)\n# uv pip install networkx\n# uv pip install networkx[default]  # With optional dependencies\n```\n\n### Common Workflow Pattern\n\nMost NetworkX tasks follow this pattern:\n\n1. **Create or Load Graph**:\n   ```python\n   # From scratch\n   G = nx.Graph()\n   G.add_edges_from([(1, 2), (2, 3), (3, 4)])\n\n   # Or load from file\u002Fdata\n   G = nx.read_edgelist('data.txt')\n   ```\n\n2. **Examine Structure**:\n   ```python\n   print(f\"Nodes: {G.number_of_nodes()}\")\n   print(f\"Edges: {G.number_of_edges()}\")\n   print(f\"Density: {nx.density(G)}\")\n   print(f\"Connected: {nx.is_connected(G)}\")\n   ```\n\n3. **Analyze**:\n   ```python\n   # Compute metrics\n   degree_cent = nx.degree_centrality(G)\n   avg_clustering = nx.average_clustering(G)\n\n   # Find paths\n   path = nx.shortest_path(G, source=1, target=4)\n\n   # Detect communities\n   communities = community.greedy_modularity_communities(G)\n   ```\n\n4. **Visualize**:\n   ```python\n   pos = nx.spring_layout(G, seed=42)\n   nx.draw(G, pos=pos, with_labels=True)\n   plt.show()\n   ```\n\n5. **Export Results**:\n   ```python\n   # Save graph\n   nx.write_graphml(G, 'analyzed_network.graphml')\n\n   # Save metrics\n   df = pd.DataFrame({\n       'node': list(degree_cent.keys()),\n       'centrality': list(degree_cent.values())\n   })\n   df.to_csv('centrality_results.csv', index=False)\n   ```\n\n### Important Considerations\n\n**Floating Point Precision**: When graphs contain floating-point numbers, all results are inherently approximate due to precision limitations. This can affect algorithm outcomes, particularly in minimum\u002Fmaximum computations.\n\n**Memory and Performance**: Each time a script runs, graph data must be loaded into memory. For large networks:\n- Use appropriate data structures (sparse matrices for large sparse graphs)\n- Consider loading only necessary subgraphs\n- Use efficient file formats (pickle for Python objects, compressed formats)\n- Leverage approximate algorithms for very large networks (e.g., `k` parameter in centrality calculations)\n\n**Node and Edge Types**:\n- Nodes can be any hashable Python object (numbers, strings, tuples, custom objects)\n- Use meaningful identifiers for clarity\n- When removing nodes, all incident edges are automatically removed\n\n**Random Seeds**: Always set random seeds for reproducibility in random graph generation and force-directed layouts:\n```python\nG = nx.erdos_renyi_graph(n=100, p=0.1, seed=42)\npos = nx.spring_layout(G, seed=42)\n```\n\n## Quick Reference\n\n### Basic Operations\n```python\n# Create\nG = nx.Graph()\nG.add_edge(1, 2)\n\n# Query\nG.number_of_nodes()\nG.number_of_edges()\nG.degree(1)\nlist(G.neighbors(1))\n\n# Check\nG.has_node(1)\nG.has_edge(1, 2)\nnx.is_connected(G)\n\n# Modify\nG.remove_node(1)\nG.remove_edge(1, 2)\nG.clear()\n```\n\n### Essential Algorithms\n```python\n# Paths\nnx.shortest_path(G, source, target)\nnx.all_pairs_shortest_path(G)\n\n# Centrality\nnx.degree_centrality(G)\nnx.betweenness_centrality(G)\nnx.closeness_centrality(G)\nnx.pagerank(G)\n\n# Clustering\nnx.clustering(G)\nnx.average_clustering(G)\n\n# Components\nnx.connected_components(G)\nnx.strongly_connected_components(G)  # Directed\n\n# Community\ncommunity.greedy_modularity_communities(G)\n```\n\n### File I\u002FO Quick Reference\n```python\n# Read\nnx.read_edgelist('file.txt')\nnx.read_graphml('file.graphml')\nnx.read_gml('file.gml')\n\n# Write\nnx.write_edgelist(G, 'file.txt')\nnx.write_graphml(G, 'file.graphml')\nnx.write_gml(G, 'file.gml')\n\n# Pandas\nnx.from_pandas_edgelist(df, 'source', 'target')\nnx.to_pandas_edgelist(G)\n```\n\n## Resources\n\nThis skill includes comprehensive reference documentation:\n\n### references\u002Fgraph-basics.md\nDetailed guide on graph types, creating and modifying graphs, adding nodes and edges, managing attributes, examining structure, and working with subgraphs.\n\n### references\u002Falgorithms.md\nComplete coverage of NetworkX algorithms including shortest paths, centrality measures, connectivity, clustering, community detection, flow algorithms, tree algorithms, matching, coloring, isomorphism, and graph traversal.\n\n### references\u002Fgenerators.md\nComprehensive documentation on graph generators including classic graphs, random models (Erdős-Rényi, Barabási-Albert, Watts-Strogatz), lattices, trees, social network models, and specialized generators.\n\n### references\u002Fio.md\nComplete guide to reading and writing graphs in various formats: edge lists, adjacency lists, GraphML, GML, JSON, CSV, Pandas DataFrames, NumPy arrays, SciPy sparse matrices, database integration, and format selection guidelines.\n\n### references\u002Fvisualization.md\nExtensive documentation on visualization techniques including layout algorithms, customizing node and edge appearance, labels, interactive visualizations with Plotly and PyVis, 3D networks, bipartite layouts, and creating publication-quality figures.\n\n## Additional Resources\n\n- **Official Documentation**: https:\u002F\u002Fnetworkx.org\u002Fdocumentation\u002Flatest\u002F\n- **Tutorial**: https:\u002F\u002Fnetworkx.org\u002Fdocumentation\u002Flatest\u002Ftutorial.html\n- **Gallery**: https:\u002F\u002Fnetworkx.org\u002Fdocumentation\u002Flatest\u002Fauto_examples\u002Findex.html\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Fnetworkx\u002Fnetworkx\n",{"name":5,"description":7},"main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-code-templates-main\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill networkx",{"tool":39,"command":40},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill networkx",{"tool":42,"command":43},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill networkx","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-code-templates-main\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002FSKILL.md",true,[47,53,57,61,65],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"references\u002Falgorithms.md","REFERENCE","参考文档",9170,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-code-templates-main\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Falgorithms.md",{"path":54,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":55,"sourceHtmlUrl":56},"references\u002Fgenerators.md",8228,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-code-templates-main\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Fgenerators.md",{"path":58,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":59,"sourceHtmlUrl":60},"references\u002Fgraph-basics.md",6261,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-code-templates-main\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Fgraph-basics.md",{"path":62,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002Fio.md",9395,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-code-templates-main\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Fio.md",{"path":66,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":67,"sourceHtmlUrl":68},"references\u002Fvisualization.md",12388,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-code-templates-main\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Fvisualization.md",[70,77,84,91,98,105],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]