[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6AFGS5KFKGE6WJVVVXQGA4F":3,"skill-same:01M6AFGS5KFKGE6WJVVVXQGA4F":95},{"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":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":52,"repositoryHtmlUrl":53,"repositoryHomepageUrl":54,"ownerHtmlUrl":55,"ownerBlogUrl":56,"ownerDescription":57,"updatedAt":58,"install":59,"resources":72},"01M6AFGS5KFKGE6WJVVVXQGA4F","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.","davila7\u002Fclaude-code-templates","davila7","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6216945?v=4","01M6ADEWWFPS191NFM0Y1EX1JH","Daniel Avila","01M6ADJHGM78PHQRD3XZTFDVKK",33481,"MIT","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[5,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"social","when","graph algorithms","for","detecting","paths","synthetic","data structures","communities","algorithms","domain","python","use","networks","clustering","data","network","analyzing","graph","toolkit","2026-11-10 10:12:30",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","2b749c82b5d11fac39d9a6e021ce3f5b8a541bd1","cli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx",3931,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates","https:\u002F\u002Faitmpl.com","https:\u002F\u002Fgithub.com\u002Fdavila7","https:\u002F\u002Fdanielavila.me","Building AI dev tools with LLMs","2026-11-14 06:14:46",{"source":8,"skillName":5,"commands":60,"prompt":70,"zipAvailable":71},[61,64,67],{"tool":62,"command":63},"npx","npx skills add davila7\u002Fclaude-code-templates --skill networkx",{"tool":65,"command":66},"bunx","bunx skills add davila7\u002Fclaude-code-templates --skill networkx",{"tool":68,"command":69},"pnpm","pnpm dlx skills add davila7\u002Fclaude-code-templates --skill networkx","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002FSKILL.md",true,[73,79,83,87,91],{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Falgorithms.md","REFERENCE","参考文档",9170,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Falgorithms.md",{"path":80,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fgenerators.md",8228,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Fgenerators.md",{"path":84,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fgraph-basics.md",6261,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Fgraph-basics.md",{"path":88,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fio.md",9395,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Fio.md",{"path":92,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Fvisualization.md",12388,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fnetworkx\u002Freferences\u002Fvisualization.md",[96,121,148,181,216,239],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":103,"publishedAt":44},"01M70NHBTQ8BV0A2SCAZXEPHCX","wealthville-pool-scoring","Score DeFi liquidity pools before providing liquidity. Returns a 0-100 pool score and an Enter\u002FHold\u002FExit\u002FReduce\u002FAvoid verdict with calibrated confidence for ~68,800 Solana pools and 575 EVM pools, plus a public miss-inclusive track record. Use when asked whether a pool is worth LPing into, which pools look best right now, or how accurate the scores have actually been.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fweb-data\u002Fwealthville-pool-scoring\u002FSKILL.md",[102],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[104,105,106,107,108,27,109,110,36,25,111,112,113,114,115,116,117,118,119,120],"scoring","pool","wealthville pool scoring","liquidity","which","exit","now","reduce","with","record","track","verdict","evm","solana","how","public","look",{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":128,"publishedAt":44},"01M70MB6VR8ERJ4EM8D5KHBMEV","technical-debt-auditor","Scans a codebase and produces a quantified technical debt report with a prioritized remediation plan. Analyzes dead code, TODO\u002FFIXME\u002FHACK markers, dependency staleness, complexity hotspots, code duplication signals, test coverage gaps, unused exports, and outdated patterns. Use this skill when the user asks to audit their codebase for tech debt, wants a health check of their code quality, says things like \"where should I focus refactoring\", \"find code smells\", \"audit my codebase\", \"what technical debt do we have\", \"prioritize cleanup work\", or asks about code quality metrics. Also trigger when the user mentions \"code rot\", \"legacy cleanup\", \"refactoring priorities\", or wants to understand the overall health of a project before a major effort. Trigger even if the user doesn't say \"technical debt\" explicitly — any request to systematically assess code quality and identify improvement priorities belongs here.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdevelopment\u002Ftechnical-debt-auditor\u002FSKILL.md",[127],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[129,130,131,132,133,134,135,136,137,138,139,25,140,141,142,143,144,145,146,147],"technical debt","debt","technical","technical debt auditor","auditor","coverage","complexity","markers","project","cleanup","unused","code","todo","work","plan","focus","signals","audit","dependency",{"skillNo":149,"name":150,"nameZh":6,"description":151,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":152,"categories":153,"keywords":163,"publishedAt":44},"01M70KPYH9QNHCNME5GJQGE22K","readonly-sql-guard","Make an agent's database access provably read-only. Use when an agent runs caller-supplied SQL against a production\u002FERP\u002Fanalytics database (a \"query\" MCP tool, text-to-SQL, an admin console), or when reviewing DB-access code for write\u002FDDL\u002Fside-effect\u002Ftransaction-escape risks. Checks what a statement CALLS, not just its shape.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdatabase\u002Freadonly-sql-guard\u002FSKILL.md",[154,157,158],{"categoryNo":155,"categoryName":156,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":159,"categoryName":160,"taxonomyType":161,"taxonomyTypeDesc":162},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[164,165,166,167,168,169,170,27,171,172,173,174,175,176,177,36,178,179,25,180],"readonly","guard","sql guard","sql","readonly sql guard","erp","effect","read-only","db","just","tool","calls","only","MCP","access","database","query",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":185,"licenseFileUrl":186,"sourceHtmlUrl":187,"categories":188,"keywords":192,"publishedAt":44},"01M6AFY6F7CC2BBZP1QD6VTNVC","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FSKILL.md",[189],{"categoryNo":190,"categoryName":191,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",[193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,27,215],"artifacts builder","web","web artifacts builder","artifacts","builder","state","routing","state management","component","css","frontend","ui","Tools","file","components","shadcn","react","Tailwind","suite","jsx","html","single-file","ui components",{"skillNo":217,"name":218,"nameZh":6,"description":219,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":185,"licenseFileUrl":220,"sourceHtmlUrl":221,"categories":222,"keywords":227,"publishedAt":44},"01M6AFWF33SFV9Z3SF4PEEE4BF","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FSKILL.md",[223,226],{"categoryNo":224,"categoryName":225,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":190,"categoryName":191,"taxonomyType":21,"taxonomyTypeDesc":22},[228,229,230,231,232,194,233,203,204,234,43,235,236,27,237,112,238],"webapp testing","testing","webapp","browser","playwright","applications","debugging","logs","screenshots","local","behavior",{"skillNo":240,"name":241,"nameZh":6,"description":242,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":185,"licenseFileUrl":243,"sourceHtmlUrl":244,"categories":245,"keywords":253,"publishedAt":44},"01M6AF67Q67JJJ5V51JR2P52KA","discernment-nudge","After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fdiscernment-nudge\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fdiscernment-nudge\u002FSKILL.md",[246,249,250],{"categoryNo":247,"categoryName":248,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":251,"categoryName":252,"taxonomyType":161,"taxonomyTypeDesc":162},"01JBSEEDCAT000000000000036","内容创作者",[254,255,256,257,258,259,39,260,196,261,206,140,262,263,264,265,266,176,267,25,268,269,270,271,272,118,273],"discernment nudge","nudge","interpretation","help","run","reasoning","writing","lookup","content","review","conversation","short","up","invoke","you","analysis","claims","argument","assemble","recommendations"]