@pikaa-ai/pikaa 0.3.23 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/assets/brand/orbit-logo-option4-whale.jpg +0 -0
  2. package/assets/brand/orbit-logo.jpg +0 -0
  3. package/assets/brand/orbit-logo.png +0 -0
  4. package/assets/brand/orbit-logo.svg +3 -0
  5. package/dist/cli.js +337 -162
  6. package/dist/index.js +1 -2
  7. package/package.json +1 -2
  8. package/skills/adaptyv/SKILL.md +0 -240
  9. package/skills/aeon/SKILL.md +0 -402
  10. package/skills/analytical-method-validation/SKILL.md +0 -299
  11. package/skills/anndata/SKILL.md +0 -431
  12. package/skills/arbor/SKILL.md +0 -152
  13. package/skills/arboreto/SKILL.md +0 -267
  14. package/skills/astropy/SKILL.md +0 -353
  15. package/skills/autoskill/SKILL.md +0 -233
  16. package/skills/benchling-integration/SKILL.md +0 -229
  17. package/skills/bgpt-paper-search/SKILL.md +0 -75
  18. package/skills/bids/SKILL.md +0 -237
  19. package/skills/biopython/SKILL.md +0 -472
  20. package/skills/bioservices/SKILL.md +0 -399
  21. package/skills/bulk-rnaseq/SKILL.md +0 -198
  22. package/skills/cellxgene-census/SKILL.md +0 -283
  23. package/skills/cirq/SKILL.md +0 -370
  24. package/skills/citation-management/SKILL.md +0 -329
  25. package/skills/clinical-decision-support/SKILL.md +0 -238
  26. package/skills/clinical-decision-support/references/README.md +0 -62
  27. package/skills/clinical-reports/SKILL.md +0 -248
  28. package/skills/clinical-reports/references/README.md +0 -34
  29. package/skills/cobrapy/SKILL.md +0 -496
  30. package/skills/consciousness-council/SKILL.md +0 -151
  31. package/skills/dask/SKILL.md +0 -482
  32. package/skills/database-lookup/SKILL.md +0 -386
  33. package/skills/datamol/SKILL.md +0 -200
  34. package/skills/deepchem/SKILL.md +0 -244
  35. package/skills/deepspot-m/SKILL.md +0 -175
  36. package/skills/deeptools/SKILL.md +0 -412
  37. package/skills/depmap/SKILL.md +0 -301
  38. package/skills/dhdna-profiler/SKILL.md +0 -184
  39. package/skills/diffdock/SKILL.md +0 -488
  40. package/skills/dnanexus-integration/SKILL.md +0 -325
  41. package/skills/docx/SKILL.md +0 -99
  42. package/skills/esm/SKILL.md +0 -334
  43. package/skills/etetoolkit/SKILL.md +0 -327
  44. package/skills/exa-search/SKILL.md +0 -102
  45. package/skills/executing-plans/SKILL.md +0 -14
  46. package/skills/experimental-design/SKILL.md +0 -234
  47. package/skills/exploratory-data-analysis/SKILL.md +0 -280
  48. package/skills/flowio/SKILL.md +0 -310
  49. package/skills/fluidsim/SKILL.md +0 -279
  50. package/skills/frontend-design/SKILL.md +0 -100
  51. package/skills/generate-image/SKILL.md +0 -304
  52. package/skills/geniml/SKILL.md +0 -310
  53. package/skills/genomic-coordinates/SKILL.md +0 -189
  54. package/skills/genomic-intelligence/SKILL.md +0 -243
  55. package/skills/geomaster/README.md +0 -105
  56. package/skills/geomaster/SKILL.md +0 -366
  57. package/skills/geopandas/SKILL.md +0 -250
  58. package/skills/get-available-resources/SKILL.md +0 -260
  59. package/skills/gget/SKILL.md +0 -153
  60. package/skills/ginkgo-cloud-lab/SKILL.md +0 -106
  61. package/skills/glycoengineering/SKILL.md +0 -339
  62. package/skills/gtars/SKILL.md +0 -282
  63. package/skills/guardian-rails/SKILL.md +0 -54
  64. package/skills/histolab/SKILL.md +0 -243
  65. package/skills/hugging-science/SKILL.md +0 -132
  66. package/skills/hypogenic/SKILL.md +0 -290
  67. package/skills/hypothesis-generation/SKILL.md +0 -264
  68. package/skills/imaging-data-commons/SKILL.md +0 -496
  69. package/skills/infographics/SKILL.md +0 -315
  70. package/skills/iso-standards-readiness/SKILL.md +0 -352
  71. package/skills/lab-hardware-cad/SKILL.md +0 -372
  72. package/skills/labarchive-integration/SKILL.md +0 -216
  73. package/skills/lamindb/SKILL.md +0 -408
  74. package/skills/latchbio-integration/SKILL.md +0 -227
  75. package/skills/latex-posters/SKILL.md +0 -369
  76. package/skills/latex-posters/references/README.md +0 -439
  77. package/skills/liteparse/SKILL.md +0 -295
  78. package/skills/literature-review/SKILL.md +0 -263
  79. package/skills/markdown-mermaid-writing/SKILL.md +0 -322
  80. package/skills/market-research-reports/SKILL.md +0 -337
  81. package/skills/markitdown/SKILL.md +0 -264
  82. package/skills/matchms/SKILL.md +0 -276
  83. package/skills/matlab/SKILL.md +0 -274
  84. package/skills/matplotlib/SKILL.md +0 -378
  85. package/skills/medchem/SKILL.md +0 -321
  86. package/skills/modal/SKILL.md +0 -468
  87. package/skills/molecular-dynamics/SKILL.md +0 -458
  88. package/skills/molfeat/SKILL.md +0 -348
  89. package/skills/ncats-arax/SKILL.md +0 -178
  90. package/skills/networkx/SKILL.md +0 -440
  91. package/skills/neurokit2/SKILL.md +0 -323
  92. package/skills/neuropixels-analysis/SKILL.md +0 -412
  93. package/skills/nextflow/SKILL.md +0 -195
  94. package/skills/omero-integration/SKILL.md +0 -222
  95. package/skills/onekgpd/SKILL.md +0 -371
  96. package/skills/ontology-term-resolution/SKILL.md +0 -147
  97. package/skills/open-notebook/SKILL.md +0 -297
  98. package/skills/openpiv/SKILL.md +0 -469
  99. package/skills/opentrons-integration/SKILL.md +0 -322
  100. package/skills/optimize-for-gpu/SKILL.md +0 -176
  101. package/skills/owasp-top10/SKILL.md +0 -48
  102. package/skills/pacsomatic/LICENSE +0 -21
  103. package/skills/pacsomatic/SKILL.md +0 -150
  104. package/skills/paper-lookup/SKILL.md +0 -263
  105. package/skills/paperclip/SKILL.md +0 -413
  106. package/skills/paperzilla/SKILL.md +0 -159
  107. package/skills/parallel-web/SKILL.md +0 -128
  108. package/skills/pathml/SKILL.md +0 -222
  109. package/skills/pathogen-variant-surveillance/SKILL.md +0 -208
  110. package/skills/pathway-enrichment/SKILL.md +0 -194
  111. package/skills/pdf/SKILL.md +0 -322
  112. package/skills/peer-review/SKILL.md +0 -288
  113. package/skills/penetration-testing/SKILL.md +0 -31
  114. package/skills/pennylane/SKILL.md +0 -240
  115. package/skills/phylogenetics/SKILL.md +0 -409
  116. package/skills/pi-agent/SKILL.md +0 -83
  117. package/skills/pkpd-modeling/SKILL.md +0 -381
  118. package/skills/polars/SKILL.md +0 -393
  119. package/skills/polars-bio/SKILL.md +0 -379
  120. package/skills/ponytail/SKILL.md +0 -31
  121. package/skills/ponytail-audit/SKILL.md +0 -18
  122. package/skills/pptx/SKILL.md +0 -246
  123. package/skills/pptx-posters/SKILL.md +0 -258
  124. package/skills/primekg/SKILL.md +0 -99
  125. package/skills/protocolsio-integration/SKILL.md +0 -236
  126. package/skills/pufferlib/SKILL.md +0 -328
  127. package/skills/pydeseq2/SKILL.md +0 -369
  128. package/skills/pydicom/SKILL.md +0 -381
  129. package/skills/pyhealth/SKILL.md +0 -124
  130. package/skills/pylabrobot/SKILL.md +0 -216
  131. package/skills/pymatgen/SKILL.md +0 -404
  132. package/skills/pymc/SKILL.md +0 -310
  133. package/skills/pymoo/SKILL.md +0 -276
  134. package/skills/pyopenms/SKILL.md +0 -179
  135. package/skills/pysam/SKILL.md +0 -330
  136. package/skills/pytdc/SKILL.md +0 -297
  137. package/skills/pytorch-lightning/SKILL.md +0 -191
  138. package/skills/pyzotero/SKILL.md +0 -137
  139. package/skills/qiskit/SKILL.md +0 -259
  140. package/skills/qutip/SKILL.md +0 -317
  141. package/skills/rdkit/SKILL.md +0 -94
  142. package/skills/relsa-severity-assessment/SKILL.md +0 -354
  143. package/skills/research-grants/SKILL.md +0 -296
  144. package/skills/research-grants/references/README.md +0 -287
  145. package/skills/research-lookup/README.md +0 -106
  146. package/skills/research-lookup/SKILL.md +0 -338
  147. package/skills/rowan/SKILL.md +0 -398
  148. package/skills/scanpy/SKILL.md +0 -303
  149. package/skills/scholar-evaluation/SKILL.md +0 -296
  150. package/skills/scientific-brainstorming/SKILL.md +0 -282
  151. package/skills/scientific-critical-thinking/SKILL.md +0 -180
  152. package/skills/scientific-schematics/SKILL.md +0 -370
  153. package/skills/scientific-slides/SKILL.md +0 -379
  154. package/skills/scientific-visualization/SKILL.md +0 -285
  155. package/skills/scientific-writing/SKILL.md +0 -356
  156. package/skills/scikit-bio/SKILL.md +0 -470
  157. package/skills/scikit-learn/SKILL.md +0 -324
  158. package/skills/scikit-survival/SKILL.md +0 -313
  159. package/skills/scvelo/SKILL.md +0 -328
  160. package/skills/scvi-tools/SKILL.md +0 -201
  161. package/skills/seaborn/SKILL.md +0 -254
  162. package/skills/security-auditor/SKILL.md +0 -37
  163. package/skills/shap/SKILL.md +0 -282
  164. package/skills/simpy/SKILL.md +0 -283
  165. package/skills/stable-baselines3/SKILL.md +0 -325
  166. package/skills/statistical-analysis/SKILL.md +0 -446
  167. package/skills/statistical-power/SKILL.md +0 -200
  168. package/skills/statsmodels/SKILL.md +0 -238
  169. package/skills/sympy/SKILL.md +0 -354
  170. package/skills/systematic-debugging/SKILL.md +0 -35
  171. package/skills/tamarind/SKILL.md +0 -285
  172. package/skills/tdd/SKILL.md +0 -26
  173. package/skills/tiledbvcf/SKILL.md +0 -456
  174. package/skills/timesfm-forecasting/SKILL.md +0 -408
  175. package/skills/timesfm-forecasting/examples/global-temperature/README.md +0 -178
  176. package/skills/torch-geometric/SKILL.md +0 -458
  177. package/skills/torchdrug/SKILL.md +0 -241
  178. package/skills/transformers/SKILL.md +0 -195
  179. package/skills/treatment-plans/SKILL.md +0 -174
  180. package/skills/treatment-plans/references/README.md +0 -19
  181. package/skills/umap-learn/SKILL.md +0 -488
  182. package/skills/uncertainty-and-units/SKILL.md +0 -384
  183. package/skills/usfiscaldata/SKILL.md +0 -171
  184. package/skills/vaex/SKILL.md +0 -204
  185. package/skills/venue-templates/SKILL.md +0 -269
  186. package/skills/verification-before-completion/SKILL.md +0 -22
  187. package/skills/waypoint-bio/SKILL.md +0 -273
  188. package/skills/what-if-oracle/SKILL.md +0 -184
  189. package/skills/writing-plans/SKILL.md +0 -15
  190. package/skills/xlsx/SKILL.md +0 -110
  191. package/skills/zarr-python/SKILL.md +0 -241
@@ -1,440 +0,0 @@
1
- ---
2
- name: networkx
3
- description: Create, analyze, and visualize complex networks and graphs in Python with NetworkX. Use when working with network/graph data structures, computing graph algorithms (shortest paths, centrality, clustering), detecting communities, generating synthetic networks (random, scale-free, small-world), reading/writing graph file formats, or drawing network topologies. Common applications include social, biological, transportation, and citation networks.
4
- license: 3-clause BSD license
5
- metadata:
6
- version: "1.1"
7
- skill-author: K-Dense Inc.
8
- ---
9
-
10
- # NetworkX
11
-
12
- ## Overview
13
-
14
- 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.
15
-
16
- This skill targets NetworkX 3.x (current stable: 3.6, which requires Python >= 3.11). Several pre-3.0 APIs (`nx.info`, `nx.write_gpickle`, `nx.read_shp`) and the 3.4-era `nx.random_tree` no longer exist — current replacements are used throughout this skill.
17
-
18
- ## When to Use This Skill
19
-
20
- Invoke this skill when tasks involve:
21
-
22
- - **Creating graphs**: Building network structures from data, adding nodes and edges with attributes
23
- - **Graph analysis**: Computing centrality measures, finding shortest paths, detecting communities, measuring clustering
24
- - **Graph algorithms**: Running standard algorithms like Dijkstra's, PageRank, minimum spanning trees, maximum flow
25
- - **Network generation**: Creating synthetic networks (random, scale-free, small-world models) for testing or simulation
26
- - **Graph I/O**: Reading from or writing to various formats (edge lists, GraphML, JSON, CSV, adjacency matrices)
27
- - **Visualization**: Drawing and customizing network visualizations with matplotlib or interactive libraries
28
- - **Network comparison**: Checking isomorphism, computing graph metrics, analyzing structural properties
29
-
30
- ## Core Capabilities
31
-
32
- ### 1. Graph Creation and Manipulation
33
-
34
- NetworkX supports four main graph types:
35
- - **Graph**: Undirected graphs with single edges
36
- - **DiGraph**: Directed graphs with one-way connections
37
- - **MultiGraph**: Undirected graphs allowing multiple edges between nodes
38
- - **MultiDiGraph**: Directed graphs with multiple edges
39
-
40
- Create graphs by:
41
- ```python
42
- import networkx as nx
43
-
44
- # Create empty graph
45
- G = nx.Graph()
46
-
47
- # Add nodes (can be any hashable type)
48
- G.add_node(1)
49
- G.add_nodes_from([2, 3, 4])
50
- G.add_node("protein_A", type='enzyme', weight=1.5)
51
-
52
- # Add edges
53
- G.add_edge(1, 2)
54
- G.add_edges_from([(1, 3), (2, 4)])
55
- G.add_edge(1, 4, weight=0.8, relation='interacts')
56
- ```
57
-
58
- **Reference**: See `references/graph-basics.md` for comprehensive guidance on creating, modifying, examining, and managing graph structures, including working with attributes and subgraphs.
59
-
60
- ### 2. Graph Algorithms
61
-
62
- NetworkX provides extensive algorithms for network analysis:
63
-
64
- **Shortest Paths**:
65
- ```python
66
- # Find shortest path
67
- path = nx.shortest_path(G, source=1, target=5)
68
- length = nx.shortest_path_length(G, source=1, target=5, weight='weight')
69
- ```
70
-
71
- **Centrality Measures**:
72
- ```python
73
- # Degree centrality
74
- degree_cent = nx.degree_centrality(G)
75
-
76
- # Betweenness centrality
77
- betweenness = nx.betweenness_centrality(G)
78
-
79
- # PageRank
80
- pagerank = nx.pagerank(G)
81
- ```
82
-
83
- **Community Detection**:
84
- ```python
85
- from networkx.algorithms import community
86
-
87
- # Detect communities
88
- communities = community.greedy_modularity_communities(G)
89
- ```
90
-
91
- **Connectivity**:
92
- ```python
93
- # Check connectivity
94
- is_connected = nx.is_connected(G)
95
-
96
- # Find connected components
97
- components = list(nx.connected_components(G))
98
- ```
99
-
100
- **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.
101
-
102
- ### 3. Graph Generators
103
-
104
- Create synthetic networks for testing, simulation, or modeling:
105
-
106
- **Classic Graphs**:
107
- ```python
108
- # Complete graph
109
- G = nx.complete_graph(n=10)
110
-
111
- # Cycle graph
112
- G = nx.cycle_graph(n=20)
113
-
114
- # Known graphs
115
- G = nx.karate_club_graph()
116
- G = nx.petersen_graph()
117
- ```
118
-
119
- **Random Networks**:
120
- ```python
121
- # Erdős-Rényi random graph
122
- G = nx.erdos_renyi_graph(n=100, p=0.1, seed=42)
123
-
124
- # Barabási-Albert scale-free network
125
- G = nx.barabasi_albert_graph(n=100, m=3, seed=42)
126
-
127
- # Watts-Strogatz small-world network
128
- G = nx.watts_strogatz_graph(n=100, k=6, p=0.1, seed=42)
129
- ```
130
-
131
- **Structured Networks**:
132
- ```python
133
- # Grid graph
134
- G = nx.grid_2d_graph(m=5, n=7)
135
-
136
- # Random tree (random_tree was removed in NetworkX 3.4)
137
- G = nx.random_labeled_tree(100, seed=42)
138
- ```
139
-
140
- **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.
141
-
142
- ### 4. Reading and Writing Graphs
143
-
144
- NetworkX supports numerous file formats and data sources:
145
-
146
- **File Formats**:
147
- ```python
148
- # Edge list
149
- G = nx.read_edgelist('graph.edgelist')
150
- nx.write_edgelist(G, 'graph.edgelist')
151
-
152
- # GraphML (preserves attributes)
153
- G = nx.read_graphml('graph.graphml')
154
- nx.write_graphml(G, 'graph.graphml')
155
-
156
- # GML
157
- G = nx.read_gml('graph.gml')
158
- nx.write_gml(G, 'graph.gml')
159
-
160
- # JSON (node-link format; edge list is stored under the "edges" key
161
- # since NetworkX 3.6 — older files may use "links", see references/io.md)
162
- data = nx.node_link_data(G)
163
- G = nx.node_link_graph(data)
164
- ```
165
-
166
- **Pandas Integration**:
167
- ```python
168
- import pandas as pd
169
-
170
- # From DataFrame
171
- df = pd.DataFrame({'source': [1, 2, 3], 'target': [2, 3, 4], 'weight': [0.5, 1.0, 0.75]})
172
- G = nx.from_pandas_edgelist(df, 'source', 'target', edge_attr='weight')
173
-
174
- # To DataFrame
175
- df = nx.to_pandas_edgelist(G)
176
- ```
177
-
178
- **Matrix Formats**:
179
- ```python
180
- import numpy as np
181
-
182
- # Adjacency matrix
183
- A = nx.to_numpy_array(G)
184
- G = nx.from_numpy_array(A)
185
-
186
- # Sparse matrix
187
- A = nx.to_scipy_sparse_array(G)
188
- G = nx.from_scipy_sparse_array(A)
189
- ```
190
-
191
- **Reference**: See `references/io.md` for complete documentation on all I/O formats including CSV, SQL databases, Cytoscape, DOT, and guidance on format selection for different use cases.
192
-
193
- ### 5. Visualization
194
-
195
- Create clear and informative network visualizations:
196
-
197
- **Basic Visualization**:
198
- ```python
199
- import matplotlib.pyplot as plt
200
-
201
- # Simple draw
202
- nx.draw(G, with_labels=True)
203
- plt.show()
204
-
205
- # With layout
206
- pos = nx.spring_layout(G, seed=42)
207
- nx.draw(G, pos=pos, with_labels=True, node_color='lightblue', node_size=500)
208
- plt.show()
209
- ```
210
-
211
- **Customization**:
212
- ```python
213
- # Color by degree
214
- node_colors = [G.degree(n) for n in G.nodes()]
215
- nx.draw(G, node_color=node_colors, cmap=plt.cm.viridis)
216
-
217
- # Size by centrality
218
- centrality = nx.betweenness_centrality(G)
219
- node_sizes = [3000 * centrality[n] for n in G.nodes()]
220
- nx.draw(G, node_size=node_sizes)
221
-
222
- # Edge weights
223
- edge_widths = [3 * G[u][v].get('weight', 1) for u, v in G.edges()]
224
- nx.draw(G, width=edge_widths)
225
- ```
226
-
227
- **Layout Algorithms**:
228
- ```python
229
- # Spring layout (force-directed)
230
- pos = nx.spring_layout(G, seed=42)
231
-
232
- # Circular layout
233
- pos = nx.circular_layout(G)
234
-
235
- # Kamada-Kawai layout
236
- pos = nx.kamada_kawai_layout(G)
237
-
238
- # Spectral layout
239
- pos = nx.spectral_layout(G)
240
- ```
241
-
242
- **Publication Quality**:
243
- ```python
244
- plt.figure(figsize=(12, 8))
245
- pos = nx.spring_layout(G, seed=42)
246
- nx.draw(G, pos=pos, node_color='lightblue', node_size=500,
247
- edge_color='gray', with_labels=True, font_size=10)
248
- plt.title('Network Visualization', fontsize=16)
249
- plt.axis('off')
250
- plt.tight_layout()
251
- plt.savefig('network.png', dpi=300, bbox_inches='tight')
252
- plt.savefig('network.pdf', bbox_inches='tight') # Vector format
253
- ```
254
-
255
- **Reference**: See `references/visualization.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.
256
-
257
- ## Working with NetworkX
258
-
259
- ### Installation
260
-
261
- Ensure NetworkX is installed:
262
- ```python
263
- # Check if installed
264
- import networkx as nx
265
- print(nx.__version__)
266
-
267
- # Install if needed (via bash)
268
- # uv pip install networkx
269
- # uv pip install networkx[default] # With optional dependencies
270
- ```
271
-
272
- ### Common Workflow Pattern
273
-
274
- Most NetworkX tasks follow this pattern:
275
-
276
- 1. **Create or Load Graph**:
277
- ```python
278
- # From scratch
279
- G = nx.Graph()
280
- G.add_edges_from([(1, 2), (2, 3), (3, 4)])
281
-
282
- # Or load from file/data
283
- G = nx.read_edgelist('data.txt')
284
- ```
285
-
286
- 2. **Examine Structure**:
287
- ```python
288
- print(f"Nodes: {G.number_of_nodes()}")
289
- print(f"Edges: {G.number_of_edges()}")
290
- print(f"Density: {nx.density(G)}")
291
- print(f"Connected: {nx.is_connected(G)}")
292
- ```
293
-
294
- 3. **Analyze**:
295
- ```python
296
- # Compute metrics
297
- degree_cent = nx.degree_centrality(G)
298
- avg_clustering = nx.average_clustering(G)
299
-
300
- # Find paths
301
- path = nx.shortest_path(G, source=1, target=4)
302
-
303
- # Detect communities
304
- communities = community.greedy_modularity_communities(G)
305
- ```
306
-
307
- 4. **Visualize**:
308
- ```python
309
- pos = nx.spring_layout(G, seed=42)
310
- nx.draw(G, pos=pos, with_labels=True)
311
- plt.show()
312
- ```
313
-
314
- 5. **Export Results**:
315
- ```python
316
- # Save graph
317
- nx.write_graphml(G, 'analyzed_network.graphml')
318
-
319
- # Save metrics
320
- df = pd.DataFrame({
321
- 'node': list(degree_cent.keys()),
322
- 'centrality': list(degree_cent.values())
323
- })
324
- df.to_csv('centrality_results.csv', index=False)
325
- ```
326
-
327
- ### Important Considerations
328
-
329
- **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/maximum computations.
330
-
331
- **Memory and Performance**: Each time a script runs, graph data must be loaded into memory. For large networks:
332
- - Use appropriate data structures (sparse matrices for large sparse graphs)
333
- - Consider loading only necessary subgraphs
334
- - Use efficient file formats (pickle for Python objects, compressed formats)
335
- - Leverage approximate algorithms for very large networks (e.g., `k` parameter in centrality calculations)
336
- - For heavy workloads, NetworkX 3.x supports drop-in accelerated backends via the `backend=` keyword or `nx.config.backend_priority` — e.g. `nx-cugraph` (GPU), `nx-parallel` (multicore), `graphblas-algorithms` (sparse linear algebra). Install the backend package and pass `backend="cugraph"` (or similar) to supported functions; no algorithm code changes needed.
337
-
338
- **Node and Edge Types**:
339
- - Nodes can be any hashable Python object (numbers, strings, tuples, custom objects)
340
- - Use meaningful identifiers for clarity
341
- - When removing nodes, all incident edges are automatically removed
342
-
343
- **Random Seeds**: Always set random seeds for reproducibility in random graph generation and force-directed layouts:
344
- ```python
345
- G = nx.erdos_renyi_graph(n=100, p=0.1, seed=42)
346
- pos = nx.spring_layout(G, seed=42)
347
- ```
348
-
349
- ## Quick Reference
350
-
351
- ### Basic Operations
352
- ```python
353
- # Create
354
- G = nx.Graph()
355
- G.add_edge(1, 2)
356
-
357
- # Query
358
- G.number_of_nodes()
359
- G.number_of_edges()
360
- G.degree(1)
361
- list(G.neighbors(1))
362
-
363
- # Check
364
- G.has_node(1)
365
- G.has_edge(1, 2)
366
- nx.is_connected(G)
367
-
368
- # Modify
369
- G.remove_node(1)
370
- G.remove_edge(1, 2)
371
- G.clear()
372
- ```
373
-
374
- ### Essential Algorithms
375
- ```python
376
- # Paths
377
- nx.shortest_path(G, source, target)
378
- nx.all_pairs_shortest_path(G)
379
-
380
- # Centrality
381
- nx.degree_centrality(G)
382
- nx.betweenness_centrality(G)
383
- nx.closeness_centrality(G)
384
- nx.pagerank(G)
385
-
386
- # Clustering
387
- nx.clustering(G)
388
- nx.average_clustering(G)
389
-
390
- # Components
391
- nx.connected_components(G)
392
- nx.strongly_connected_components(G) # Directed
393
-
394
- # Community
395
- community.greedy_modularity_communities(G)
396
- ```
397
-
398
- ### File I/O Quick Reference
399
- ```python
400
- # Read
401
- nx.read_edgelist('file.txt')
402
- nx.read_graphml('file.graphml')
403
- nx.read_gml('file.gml')
404
-
405
- # Write
406
- nx.write_edgelist(G, 'file.txt')
407
- nx.write_graphml(G, 'file.graphml')
408
- nx.write_gml(G, 'file.gml')
409
-
410
- # Pandas
411
- nx.from_pandas_edgelist(df, 'source', 'target')
412
- nx.to_pandas_edgelist(G)
413
- ```
414
-
415
- ## Resources
416
-
417
- This skill includes comprehensive reference documentation:
418
-
419
- ### references/graph-basics.md
420
- Detailed guide on graph types, creating and modifying graphs, adding nodes and edges, managing attributes, examining structure, and working with subgraphs.
421
-
422
- ### references/algorithms.md
423
- Complete coverage of NetworkX algorithms including shortest paths, centrality measures, connectivity, clustering, community detection, flow algorithms, tree algorithms, matching, coloring, isomorphism, and graph traversal.
424
-
425
- ### references/generators.md
426
- Comprehensive 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.
427
-
428
- ### references/io.md
429
- Complete 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.
430
-
431
- ### references/visualization.md
432
- Extensive 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.
433
-
434
- ## Additional Resources
435
-
436
- - **Official Documentation**: https://networkx.org/documentation/latest/
437
- - **Tutorial**: https://networkx.org/documentation/latest/tutorial.html
438
- - **Gallery**: https://networkx.org/documentation/latest/auto_examples/index.html
439
- - **GitHub**: https://github.com/networkx/networkx
440
-