terraproof 0.0.0-stage → 0.4.0

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 (182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +356 -2
  3. package/bin/terraproof.js +4 -0
  4. package/dist/router/apply.js +147 -0
  5. package/dist/router/classify.js +111 -0
  6. package/dist/router/explain.js +9 -0
  7. package/dist/router/index.js +272 -0
  8. package/dist/router/resolve.js +239 -0
  9. package/dist/router/score.js +60 -0
  10. package/dist/router/types.js +1 -0
  11. package/dist/router/validate.js +81 -0
  12. package/instructions/engineering.md +14 -0
  13. package/instructions/security.md +14 -0
  14. package/instructions/simplicity.md +13 -0
  15. package/package.json +65 -4
  16. package/routing/DOMAIN_ROUTING.md +161 -0
  17. package/routing/ROUTER_DESIGN.md +173 -0
  18. package/routing/SKILL_MANIFEST.md +86 -0
  19. package/routing/checks.json +121 -0
  20. package/routing/collections.json +47 -0
  21. package/routing/registry.json +2211 -0
  22. package/routing/rules.json +64 -0
  23. package/skills/accuracy-assessment/SKILL.md +213 -0
  24. package/skills/accuracy-assessment/UPSTREAM.md +7 -0
  25. package/skills/accuracy-assessment/references/stratified-estimator.md +127 -0
  26. package/skills/accuracy-assessment/skill.json +103 -0
  27. package/skills/brainstorming/SKILL.md +250 -0
  28. package/skills/brainstorming/UPSTREAM.md +29 -0
  29. package/skills/brainstorming/scripts/frame-template.html +213 -0
  30. package/skills/brainstorming/scripts/helper.js +167 -0
  31. package/skills/brainstorming/scripts/server.cjs +723 -0
  32. package/skills/brainstorming/scripts/start-server.sh +209 -0
  33. package/skills/brainstorming/scripts/stop-server.sh +120 -0
  34. package/skills/brainstorming/skill.json +73 -0
  35. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  36. package/skills/brainstorming/visual-companion.md +299 -0
  37. package/skills/crs-and-units/SKILL.md +200 -0
  38. package/skills/crs-and-units/UPSTREAM.md +7 -0
  39. package/skills/crs-and-units/skill.json +74 -0
  40. package/skills/design-postgis-tables/SKILL.md +494 -0
  41. package/skills/design-postgis-tables/UPSTREAM.md +21 -0
  42. package/skills/design-postgis-tables/skill.json +90 -0
  43. package/skills/gdal/SKILL.md +125 -0
  44. package/skills/gdal/UPSTREAM.md +22 -0
  45. package/skills/gdal/references/gdal-recipes.md +103 -0
  46. package/skills/gdal/skill.json +66 -0
  47. package/skills/geomaster/README.md +105 -0
  48. package/skills/geomaster/SKILL.md +366 -0
  49. package/skills/geomaster/UPSTREAM.md +21 -0
  50. package/skills/geomaster/references/advanced-gis.md +376 -0
  51. package/skills/geomaster/references/big-data.md +363 -0
  52. package/skills/geomaster/references/code-examples.md +531 -0
  53. package/skills/geomaster/references/coordinate-systems.md +364 -0
  54. package/skills/geomaster/references/core-libraries.md +273 -0
  55. package/skills/geomaster/references/data-sources.md +330 -0
  56. package/skills/geomaster/references/gis-software.md +369 -0
  57. package/skills/geomaster/references/industry-applications.md +420 -0
  58. package/skills/geomaster/references/machine-learning.md +462 -0
  59. package/skills/geomaster/references/programming-languages.md +456 -0
  60. package/skills/geomaster/references/remote-sensing.md +370 -0
  61. package/skills/geomaster/references/scientific-domains.md +416 -0
  62. package/skills/geomaster/references/specialized-topics.md +428 -0
  63. package/skills/geomaster/references/troubleshooting.md +439 -0
  64. package/skills/geomaster/skill.json +157 -0
  65. package/skills/geopandas/SKILL.md +250 -0
  66. package/skills/geopandas/UPSTREAM.md +22 -0
  67. package/skills/geopandas/references/crs-management.md +231 -0
  68. package/skills/geopandas/references/data-io.md +323 -0
  69. package/skills/geopandas/references/data-structures.md +207 -0
  70. package/skills/geopandas/references/geometric-operations.md +262 -0
  71. package/skills/geopandas/references/spatial-analysis.md +294 -0
  72. package/skills/geopandas/references/visualization.md +230 -0
  73. package/skills/geopandas/scripts/_common.py +605 -0
  74. package/skills/geopandas/scripts/crs_reprojection_plan.py +210 -0
  75. package/skills/geopandas/scripts/export_plan.py +305 -0
  76. package/skills/geopandas/scripts/geometry_validity_report.py +227 -0
  77. package/skills/geopandas/scripts/sensitive_coordinates_checklist.py +230 -0
  78. package/skills/geopandas/scripts/spatial_join_audit.py +368 -0
  79. package/skills/geopandas/scripts/vector_inventory.py +140 -0
  80. package/skills/geopandas/skill.json +116 -0
  81. package/skills/geoparquet-validation/SKILL.md +125 -0
  82. package/skills/geoparquet-validation/UPSTREAM.md +24 -0
  83. package/skills/geoparquet-validation/references/distribution-best-practices.md +118 -0
  84. package/skills/geoparquet-validation/references/gpio-commands.md +264 -0
  85. package/skills/geoparquet-validation/references/tool-comparison.md +155 -0
  86. package/skills/geoparquet-validation/skill.json +71 -0
  87. package/skills/geospatial-data-discovery/SKILL.md +49 -0
  88. package/skills/geospatial-data-discovery/UPSTREAM.md +15 -0
  89. package/skills/geospatial-data-discovery/skill.json +51 -0
  90. package/skills/geospatial-frontend/SKILL.md +86 -0
  91. package/skills/geospatial-frontend/UPSTREAM.md +23 -0
  92. package/skills/geospatial-frontend/references/design-system.md +283 -0
  93. package/skills/geospatial-frontend/references/user-preferences.md +96 -0
  94. package/skills/geospatial-frontend/skill.json +87 -0
  95. package/skills/geozarr/SKILL.md +244 -0
  96. package/skills/geozarr/UPSTREAM.md +21 -0
  97. package/skills/geozarr/skill.json +97 -0
  98. package/skills/networkx/SKILL.md +440 -0
  99. package/skills/networkx/UPSTREAM.md +22 -0
  100. package/skills/networkx/references/algorithms.md +384 -0
  101. package/skills/networkx/references/generators.md +385 -0
  102. package/skills/networkx/references/graph-basics.md +284 -0
  103. package/skills/networkx/references/io.md +457 -0
  104. package/skills/networkx/references/visualization.md +531 -0
  105. package/skills/networkx/skill.json +93 -0
  106. package/skills/raster-processing/SKILL.md +222 -0
  107. package/skills/raster-processing/UPSTREAM.md +7 -0
  108. package/skills/raster-processing/skill.json +81 -0
  109. package/skills/sar-basics/SKILL.md +202 -0
  110. package/skills/sar-basics/UPSTREAM.md +7 -0
  111. package/skills/sar-basics/references/calibration-lut.md +98 -0
  112. package/skills/sar-basics/skill.json +97 -0
  113. package/skills/satellite-preprocessing/SKILL.md +241 -0
  114. package/skills/satellite-preprocessing/UPSTREAM.md +7 -0
  115. package/skills/satellite-preprocessing/skill.json +84 -0
  116. package/skills/scientific-visualization/SKILL.md +285 -0
  117. package/skills/scientific-visualization/UPSTREAM.md +25 -0
  118. package/skills/scientific-visualization/assets/color_palettes.py +263 -0
  119. package/skills/scientific-visualization/assets/nature.mplstyle +68 -0
  120. package/skills/scientific-visualization/assets/presentation.mplstyle +68 -0
  121. package/skills/scientific-visualization/assets/publication.mplstyle +77 -0
  122. package/skills/scientific-visualization/assets/publisher_profiles.json +269 -0
  123. package/skills/scientific-visualization/references/color_palettes.md +227 -0
  124. package/skills/scientific-visualization/references/journal_requirements.md +169 -0
  125. package/skills/scientific-visualization/references/matplotlib_examples.md +336 -0
  126. package/skills/scientific-visualization/references/publication_guidelines.md +196 -0
  127. package/skills/scientific-visualization/references/sources.md +76 -0
  128. package/skills/scientific-visualization/scripts/_common.py +136 -0
  129. package/skills/scientific-visualization/scripts/export_plan.py +493 -0
  130. package/skills/scientific-visualization/scripts/figure_export.py +642 -0
  131. package/skills/scientific-visualization/scripts/image_metadata.py +731 -0
  132. package/skills/scientific-visualization/scripts/palette_audit.py +327 -0
  133. package/skills/scientific-visualization/scripts/style_presets.py +501 -0
  134. package/skills/scientific-visualization/scripts/style_preview.py +232 -0
  135. package/skills/scientific-visualization/skill.json +95 -0
  136. package/skills/spectral-indices/SKILL.md +235 -0
  137. package/skills/spectral-indices/UPSTREAM.md +7 -0
  138. package/skills/spectral-indices/skill.json +88 -0
  139. package/skills/stac-and-cloud-access/SKILL.md +209 -0
  140. package/skills/stac-and-cloud-access/UPSTREAM.md +7 -0
  141. package/skills/stac-and-cloud-access/references/run-manifest.md +94 -0
  142. package/skills/stac-and-cloud-access/skill.json +98 -0
  143. package/skills/statistical-analysis/SKILL.md +446 -0
  144. package/skills/statistical-analysis/UPSTREAM.md +24 -0
  145. package/skills/statistical-analysis/references/assumptions_and_diagnostics.md +379 -0
  146. package/skills/statistical-analysis/references/bayesian_statistics.md +686 -0
  147. package/skills/statistical-analysis/references/effect_sizes_and_power.md +649 -0
  148. package/skills/statistical-analysis/references/reporting_standards.md +482 -0
  149. package/skills/statistical-analysis/references/test_selection_guide.md +129 -0
  150. package/skills/statistical-analysis/scripts/assumption_checks.py +652 -0
  151. package/skills/statistical-analysis/skill.json +127 -0
  152. package/skills/systematic-debugging/SKILL.md +283 -0
  153. package/skills/systematic-debugging/UPSTREAM.md +28 -0
  154. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  155. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  156. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  157. package/skills/systematic-debugging/find-polluter.sh +72 -0
  158. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  159. package/skills/systematic-debugging/skill.json +88 -0
  160. package/skills/time-series-and-change/SKILL.md +217 -0
  161. package/skills/time-series-and-change/UPSTREAM.md +7 -0
  162. package/skills/time-series-and-change/references/change-methods.md +42 -0
  163. package/skills/time-series-and-change/skill.json +116 -0
  164. package/skills/vector-quality/SKILL.md +204 -0
  165. package/skills/vector-quality/UPSTREAM.md +7 -0
  166. package/skills/vector-quality/skill.json +82 -0
  167. package/skills/verification/SKILL.md +120 -0
  168. package/skills/verification/UPSTREAM.md +31 -0
  169. package/skills/verification/skill.json +67 -0
  170. package/skills/writing-plans/SKILL.md +171 -0
  171. package/skills/writing-plans/UPSTREAM.md +23 -0
  172. package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  173. package/skills/writing-plans/skill.json +80 -0
  174. package/sources/SOURCES.md +374 -0
  175. package/third_party/isaaccorley-geospatial-skills/LICENSE +176 -0
  176. package/third_party/isaaccorley-geospatial-skills/NOTICE.md +17 -0
  177. package/third_party/kdense-scientific-agent-skills/LICENSE +21 -0
  178. package/third_party/kdense-scientific-agent-skills/NOTICE.md +19 -0
  179. package/third_party/superpowers/LICENSE +21 -0
  180. package/third_party/superpowers/NOTICE.md +17 -0
  181. package/third_party/timescale-pg-aiguide/LICENSE +176 -0
  182. package/third_party/timescale-pg-aiguide/NOTICE.md +14 -0
@@ -0,0 +1,531 @@
1
+ # NetworkX Graph Visualization
2
+
3
+ ## Basic Drawing with Matplotlib
4
+
5
+ ### Simple Visualization
6
+ ```python
7
+ import networkx as nx
8
+ import matplotlib.pyplot as plt
9
+
10
+ # Create and draw graph
11
+ G = nx.karate_club_graph()
12
+ nx.draw(G)
13
+ plt.show()
14
+
15
+ # Save to file
16
+ nx.draw(G)
17
+ plt.savefig('graph.png', dpi=300, bbox_inches='tight')
18
+ plt.close()
19
+ ```
20
+
21
+ NetworkX 3.5 added `nx.display(G)`, a newer declarative drawing API that reads visualization attributes (color, size, position) stored directly on nodes and edges. `nx.draw` and the `draw_networkx_*` functions below remain fully supported.
22
+
23
+ ### Drawing with Labels
24
+ ```python
25
+ # Draw with node labels
26
+ nx.draw(G, with_labels=True)
27
+ plt.show()
28
+
29
+ # Custom labels
30
+ labels = {i: f"Node {i}" for i in G.nodes()}
31
+ nx.draw(G, labels=labels, with_labels=True)
32
+ plt.show()
33
+ ```
34
+
35
+ ## Layout Algorithms
36
+
37
+ ### Spring Layout (Force-Directed)
38
+ ```python
39
+ # Fruchterman-Reingold force-directed algorithm
40
+ pos = nx.spring_layout(G, seed=42)
41
+ nx.draw(G, pos=pos, with_labels=True)
42
+ plt.show()
43
+
44
+ # With parameters
45
+ pos = nx.spring_layout(G, k=0.5, iterations=50, seed=42)
46
+ ```
47
+
48
+ ### Circular Layout
49
+ ```python
50
+ # Arrange nodes in circle
51
+ pos = nx.circular_layout(G)
52
+ nx.draw(G, pos=pos, with_labels=True)
53
+ plt.show()
54
+ ```
55
+
56
+ ### Random Layout
57
+ ```python
58
+ # Random positioning
59
+ pos = nx.random_layout(G, seed=42)
60
+ nx.draw(G, pos=pos, with_labels=True)
61
+ plt.show()
62
+ ```
63
+
64
+ ### Shell Layout
65
+ ```python
66
+ # Concentric circles
67
+ pos = nx.shell_layout(G)
68
+ nx.draw(G, pos=pos, with_labels=True)
69
+ plt.show()
70
+
71
+ # With custom shells
72
+ shells = [[0, 1, 2], [3, 4, 5, 6], [7, 8, 9]]
73
+ pos = nx.shell_layout(G, nlist=shells)
74
+ ```
75
+
76
+ ### Spectral Layout
77
+ ```python
78
+ # Use eigenvectors of graph Laplacian
79
+ pos = nx.spectral_layout(G)
80
+ nx.draw(G, pos=pos, with_labels=True)
81
+ plt.show()
82
+ ```
83
+
84
+ ### Kamada-Kawai Layout
85
+ ```python
86
+ # Energy-based layout
87
+ pos = nx.kamada_kawai_layout(G)
88
+ nx.draw(G, pos=pos, with_labels=True)
89
+ plt.show()
90
+ ```
91
+
92
+ ### Planar Layout
93
+ ```python
94
+ # For planar graphs only
95
+ if nx.is_planar(G):
96
+ pos = nx.planar_layout(G)
97
+ nx.draw(G, pos=pos, with_labels=True)
98
+ plt.show()
99
+ ```
100
+
101
+ ### Tree Layouts
102
+ ```python
103
+ # For tree graphs
104
+ if nx.is_tree(G):
105
+ pos = nx.nx_agraph.graphviz_layout(G, prog='dot')
106
+ nx.draw(G, pos=pos, with_labels=True)
107
+ plt.show()
108
+ ```
109
+
110
+ ## Customizing Node Appearance
111
+
112
+ ### Node Colors
113
+ ```python
114
+ # Single color
115
+ nx.draw(G, node_color='red')
116
+
117
+ # Different colors per node
118
+ node_colors = ['red' if G.degree(n) > 5 else 'blue' for n in G.nodes()]
119
+ nx.draw(G, node_color=node_colors)
120
+
121
+ # Color by attribute
122
+ colors = [G.nodes[n].get('value', 0) for n in G.nodes()]
123
+ nx.draw(G, node_color=colors, cmap=plt.cm.viridis)
124
+ plt.colorbar()
125
+ plt.show()
126
+ ```
127
+
128
+ ### Node Sizes
129
+ ```python
130
+ # Size by degree
131
+ node_sizes = [100 * G.degree(n) for n in G.nodes()]
132
+ nx.draw(G, node_size=node_sizes)
133
+
134
+ # Size by centrality
135
+ centrality = nx.degree_centrality(G)
136
+ node_sizes = [3000 * centrality[n] for n in G.nodes()]
137
+ nx.draw(G, node_size=node_sizes)
138
+ ```
139
+
140
+ ### Node Shapes
141
+ ```python
142
+ # Draw nodes separately with different shapes
143
+ pos = nx.spring_layout(G)
144
+
145
+ # Circle nodes
146
+ nx.draw_networkx_nodes(G, pos, nodelist=[0, 1, 2],
147
+ node_shape='o', node_color='red')
148
+
149
+ # Square nodes
150
+ nx.draw_networkx_nodes(G, pos, nodelist=[3, 4, 5],
151
+ node_shape='s', node_color='blue')
152
+
153
+ nx.draw_networkx_edges(G, pos)
154
+ nx.draw_networkx_labels(G, pos)
155
+ plt.show()
156
+ ```
157
+
158
+ ### Node Borders
159
+ ```python
160
+ nx.draw(G, pos=pos,
161
+ node_color='lightblue',
162
+ edgecolors='black', # Node border color
163
+ linewidths=2) # Node border width
164
+ plt.show()
165
+ ```
166
+
167
+ ## Customizing Edge Appearance
168
+
169
+ ### Edge Colors
170
+ ```python
171
+ # Single color
172
+ nx.draw(G, edge_color='gray')
173
+
174
+ # Different colors per edge
175
+ edge_colors = ['red' if G[u][v].get('weight', 1) > 0.5 else 'blue'
176
+ for u, v in G.edges()]
177
+ nx.draw(G, edge_color=edge_colors)
178
+
179
+ # Color by weight
180
+ edges = G.edges()
181
+ weights = [G[u][v].get('weight', 1) for u, v in edges]
182
+ nx.draw(G, edge_color=weights, edge_cmap=plt.cm.Reds)
183
+ ```
184
+
185
+ ### Edge Widths
186
+ ```python
187
+ # Width by weight
188
+ edge_widths = [3 * G[u][v].get('weight', 1) for u, v in G.edges()]
189
+ nx.draw(G, width=edge_widths)
190
+
191
+ # Width by betweenness
192
+ edge_betweenness = nx.edge_betweenness_centrality(G)
193
+ edge_widths = [5 * edge_betweenness[(u, v)] for u, v in G.edges()]
194
+ nx.draw(G, width=edge_widths)
195
+ ```
196
+
197
+ ### Edge Styles
198
+ ```python
199
+ # Dashed edges
200
+ nx.draw(G, style='dashed')
201
+
202
+ # Different styles per edge
203
+ pos = nx.spring_layout(G)
204
+ strong_edges = [(u, v) for u, v in G.edges() if G[u][v].get('weight', 0) > 0.5]
205
+ weak_edges = [(u, v) for u, v in G.edges() if G[u][v].get('weight', 0) <= 0.5]
206
+
207
+ nx.draw_networkx_nodes(G, pos)
208
+ nx.draw_networkx_edges(G, pos, edgelist=strong_edges, style='solid', width=2)
209
+ nx.draw_networkx_edges(G, pos, edgelist=weak_edges, style='dashed', width=1)
210
+ plt.show()
211
+ ```
212
+
213
+ ### Directed Graphs (Arrows)
214
+ ```python
215
+ # Draw directed graph with arrows
216
+ G_directed = nx.DiGraph([(1, 2), (2, 3), (3, 1)])
217
+ pos = nx.spring_layout(G_directed)
218
+
219
+ nx.draw(G_directed, pos=pos, with_labels=True,
220
+ arrows=True,
221
+ arrowsize=20,
222
+ arrowstyle='->',
223
+ connectionstyle='arc3,rad=0.1')
224
+ plt.show()
225
+ ```
226
+
227
+ ## Labels and Annotations
228
+
229
+ ### Node Labels
230
+ ```python
231
+ pos = nx.spring_layout(G)
232
+
233
+ # Custom labels
234
+ labels = {n: f"N{n}" for n in G.nodes()}
235
+ nx.draw_networkx_labels(G, pos, labels=labels, font_size=12, font_color='white')
236
+
237
+ # Font customization
238
+ nx.draw_networkx_labels(G, pos,
239
+ font_size=10,
240
+ font_family='serif',
241
+ font_weight='bold')
242
+ ```
243
+
244
+ ### Edge Labels
245
+ ```python
246
+ pos = nx.spring_layout(G)
247
+ nx.draw_networkx_nodes(G, pos)
248
+ nx.draw_networkx_edges(G, pos)
249
+
250
+ # Edge labels from attributes
251
+ edge_labels = nx.get_edge_attributes(G, 'weight')
252
+ nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)
253
+ plt.show()
254
+
255
+ # Custom edge labels
256
+ edge_labels = {(u, v): f"{u}-{v}" for u, v in G.edges()}
257
+ nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)
258
+ ```
259
+
260
+ ## Advanced Drawing Techniques
261
+
262
+ ### Combining Draw Functions
263
+ ```python
264
+ # Full control by separating components
265
+ pos = nx.spring_layout(G, seed=42)
266
+
267
+ # Draw edges
268
+ nx.draw_networkx_edges(G, pos, alpha=0.3, width=1)
269
+
270
+ # Draw nodes
271
+ nx.draw_networkx_nodes(G, pos,
272
+ node_color='lightblue',
273
+ node_size=500,
274
+ edgecolors='black')
275
+
276
+ # Draw labels
277
+ nx.draw_networkx_labels(G, pos, font_size=10)
278
+
279
+ # Remove axis
280
+ plt.axis('off')
281
+ plt.tight_layout()
282
+ plt.show()
283
+ ```
284
+
285
+ ### Subgraph Highlighting
286
+ ```python
287
+ pos = nx.spring_layout(G)
288
+
289
+ # Identify subgraph to highlight
290
+ subgraph_nodes = [1, 2, 3, 4]
291
+ subgraph = G.subgraph(subgraph_nodes)
292
+
293
+ # Draw main graph
294
+ nx.draw_networkx_nodes(G, pos, node_color='lightgray', node_size=300)
295
+ nx.draw_networkx_edges(G, pos, alpha=0.2)
296
+
297
+ # Highlight subgraph
298
+ nx.draw_networkx_nodes(subgraph, pos, node_color='red', node_size=500)
299
+ nx.draw_networkx_edges(subgraph, pos, edge_color='red', width=2)
300
+
301
+ nx.draw_networkx_labels(G, pos)
302
+ plt.axis('off')
303
+ plt.show()
304
+ ```
305
+
306
+ ### Community Coloring
307
+ ```python
308
+ from networkx.algorithms import community
309
+
310
+ # Detect communities
311
+ communities = community.greedy_modularity_communities(G)
312
+
313
+ # Assign colors
314
+ color_map = {}
315
+ colors = ['red', 'blue', 'green', 'yellow', 'purple', 'orange']
316
+ for i, comm in enumerate(communities):
317
+ for node in comm:
318
+ color_map[node] = colors[i % len(colors)]
319
+
320
+ node_colors = [color_map[n] for n in G.nodes()]
321
+
322
+ pos = nx.spring_layout(G)
323
+ nx.draw(G, pos=pos, node_color=node_colors, with_labels=True)
324
+ plt.show()
325
+ ```
326
+
327
+ ## Creating Publication-Quality Figures
328
+
329
+ ### High Resolution Export
330
+ ```python
331
+ plt.figure(figsize=(12, 8))
332
+ pos = nx.spring_layout(G, seed=42)
333
+
334
+ nx.draw(G, pos=pos,
335
+ node_color='lightblue',
336
+ node_size=500,
337
+ edge_color='gray',
338
+ width=1,
339
+ with_labels=True,
340
+ font_size=10)
341
+
342
+ plt.title('Graph Visualization', fontsize=16)
343
+ plt.axis('off')
344
+ plt.tight_layout()
345
+ plt.savefig('publication_graph.png', dpi=300, bbox_inches='tight')
346
+ plt.savefig('publication_graph.pdf', bbox_inches='tight') # Vector format
347
+ plt.close()
348
+ ```
349
+
350
+ ### Multi-Panel Figures
351
+ ```python
352
+ fig, axes = plt.subplots(1, 3, figsize=(18, 6))
353
+
354
+ # Different layouts
355
+ layouts = [nx.circular_layout(G), nx.spring_layout(G), nx.spectral_layout(G)]
356
+ titles = ['Circular', 'Spring', 'Spectral']
357
+
358
+ for ax, pos, title in zip(axes, layouts, titles):
359
+ nx.draw(G, pos=pos, ax=ax, with_labels=True, node_color='lightblue')
360
+ ax.set_title(title)
361
+ ax.axis('off')
362
+
363
+ plt.tight_layout()
364
+ plt.savefig('layouts_comparison.png', dpi=300)
365
+ plt.close()
366
+ ```
367
+
368
+ ## Interactive Visualization Libraries
369
+
370
+ ### Plotly (Interactive)
371
+ ```python
372
+ import plotly.graph_objects as go
373
+
374
+ # Create positions
375
+ pos = nx.spring_layout(G)
376
+
377
+ # Edge trace
378
+ edge_x = []
379
+ edge_y = []
380
+ for edge in G.edges():
381
+ x0, y0 = pos[edge[0]]
382
+ x1, y1 = pos[edge[1]]
383
+ edge_x.extend([x0, x1, None])
384
+ edge_y.extend([y0, y1, None])
385
+
386
+ edge_trace = go.Scatter(
387
+ x=edge_x, y=edge_y,
388
+ line=dict(width=0.5, color='#888'),
389
+ hoverinfo='none',
390
+ mode='lines')
391
+
392
+ # Node trace
393
+ node_x = [pos[node][0] for node in G.nodes()]
394
+ node_y = [pos[node][1] for node in G.nodes()]
395
+
396
+ node_trace = go.Scatter(
397
+ x=node_x, y=node_y,
398
+ mode='markers',
399
+ hoverinfo='text',
400
+ marker=dict(
401
+ showscale=True,
402
+ colorscale='YlGnBu',
403
+ size=10,
404
+ colorbar=dict(thickness=15, title='Node Connections'),
405
+ line_width=2))
406
+
407
+ # Color by degree
408
+ node_adjacencies = [len(list(G.neighbors(node))) for node in G.nodes()]
409
+ node_trace.marker.color = node_adjacencies
410
+
411
+ fig = go.Figure(data=[edge_trace, node_trace],
412
+ layout=go.Layout(
413
+ showlegend=False,
414
+ hovermode='closest',
415
+ margin=dict(b=0, l=0, r=0, t=0)))
416
+
417
+ fig.show()
418
+ ```
419
+
420
+ ### PyVis (Interactive HTML)
421
+ ```python
422
+ from pyvis.network import Network
423
+
424
+ # Create network
425
+ net = Network(notebook=True, height='750px', width='100%')
426
+
427
+ # Add nodes and edges from NetworkX
428
+ net.from_nx(G)
429
+
430
+ # Customize
431
+ net.show_buttons(filter_=['physics'])
432
+
433
+ # Save
434
+ net.show('graph.html')
435
+ ```
436
+
437
+ ### Graphviz (via pydot)
438
+ ```python
439
+ # Requires graphviz and pydot
440
+ from networkx.drawing.nx_pydot import graphviz_layout
441
+
442
+ pos = graphviz_layout(G, prog='neato') # neato, dot, fdp, sfdp, circo, twopi
443
+ nx.draw(G, pos=pos, with_labels=True)
444
+ plt.show()
445
+
446
+ # Export to graphviz
447
+ nx.drawing.nx_pydot.write_dot(G, 'graph.dot')
448
+ ```
449
+
450
+ ## Bipartite Graph Visualization
451
+
452
+ ### Two-Set Layout
453
+ ```python
454
+ from networkx.algorithms import bipartite
455
+
456
+ # Create bipartite graph
457
+ B = nx.Graph()
458
+ B.add_nodes_from([1, 2, 3, 4], bipartite=0)
459
+ B.add_nodes_from(['a', 'b', 'c', 'd', 'e'], bipartite=1)
460
+ B.add_edges_from([(1, 'a'), (1, 'b'), (2, 'b'), (2, 'c'), (3, 'd'), (4, 'e')])
461
+
462
+ # Layout with two columns
463
+ pos = {}
464
+ top_nodes = [n for n, d in B.nodes(data=True) if d['bipartite'] == 0]
465
+ bottom_nodes = [n for n, d in B.nodes(data=True) if d['bipartite'] == 1]
466
+
467
+ pos.update({node: (0, i) for i, node in enumerate(top_nodes)})
468
+ pos.update({node: (1, i) for i, node in enumerate(bottom_nodes)})
469
+
470
+ nx.draw(B, pos=pos, with_labels=True,
471
+ node_color=['lightblue' if B.nodes[n]['bipartite'] == 0 else 'lightgreen'
472
+ for n in B.nodes()])
473
+ plt.show()
474
+ ```
475
+
476
+ ## 3D Visualization
477
+
478
+ ### 3D Network Plot
479
+ ```python
480
+ import matplotlib.pyplot as plt
481
+ from mpl_toolkits.mplot3d import Axes3D
482
+
483
+ # 3D spring layout
484
+ pos = nx.spring_layout(G, dim=3, seed=42)
485
+
486
+ # Extract coordinates
487
+ node_xyz = np.array([pos[v] for v in G.nodes()])
488
+ edge_xyz = np.array([(pos[u], pos[v]) for u, v in G.edges()])
489
+
490
+ # Create figure
491
+ fig = plt.figure(figsize=(10, 8))
492
+ ax = fig.add_subplot(111, projection='3d')
493
+
494
+ # Plot edges
495
+ for vizedge in edge_xyz:
496
+ ax.plot(*vizedge.T, color='gray', alpha=0.5)
497
+
498
+ # Plot nodes
499
+ ax.scatter(*node_xyz.T, s=100, c='lightblue', edgecolors='black')
500
+
501
+ # Labels
502
+ for i, (x, y, z) in enumerate(node_xyz):
503
+ ax.text(x, y, z, str(i))
504
+
505
+ ax.set_axis_off()
506
+ plt.show()
507
+ ```
508
+
509
+ ## Best Practices
510
+
511
+ ### Performance
512
+ - For large graphs (>1000 nodes), use simpler layouts (circular, random)
513
+ - Use `alpha` parameter to make dense edges more visible
514
+ - Consider downsampling or showing subgraphs for very large networks
515
+
516
+ ### Aesthetics
517
+ - Use consistent color schemes
518
+ - Scale node sizes meaningfully (e.g., by degree or importance)
519
+ - Keep labels readable (adjust font size and position)
520
+ - Use white space effectively (adjust figure size)
521
+
522
+ ### Reproducibility
523
+ - Always set random seeds for layouts: `nx.spring_layout(G, seed=42)`
524
+ - Save layout positions for consistency across multiple plots
525
+ - Document color/size mappings in legends or captions
526
+
527
+ ### File Formats
528
+ - PNG for raster images (web, presentations)
529
+ - PDF for vector graphics (publications, scalable)
530
+ - SVG for web and interactive applications
531
+ - HTML for interactive visualizations
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "networkx",
3
+ "layer": "domain",
4
+ "domains": [
5
+ "data"
6
+ ],
7
+ "capabilities": [
8
+ "graph-algorithms",
9
+ "centrality",
10
+ "community-detection",
11
+ "network-topology",
12
+ "shortest-path"
13
+ ],
14
+ "triggers": [
15
+ "networkx",
16
+ "graph analysis",
17
+ "network graph",
18
+ "centrality",
19
+ "community detection",
20
+ "shortest path graph",
21
+ "nodes edges",
22
+ "network topology"
23
+ ],
24
+ "recommended": [
25
+ "verification"
26
+ ],
27
+ "requires": [],
28
+ "conflicts": [],
29
+ "explanation": "Executes graph analysis, centrality metrics, and community detection algorithms.",
30
+ "sections": [
31
+ {
32
+ "id": "overview",
33
+ "title": "Overview",
34
+ "source": "SKILL.md#overview"
35
+ },
36
+ {
37
+ "id": "when-to-use-this-skill",
38
+ "title": "When to Use This Skill",
39
+ "source": "SKILL.md#when-to-use-this-skill"
40
+ },
41
+ {
42
+ "id": "core-capabilities",
43
+ "title": "Core Capabilities",
44
+ "source": "SKILL.md#core-capabilities"
45
+ },
46
+ {
47
+ "id": "working-with-networkx",
48
+ "title": "Working with NetworkX",
49
+ "source": "SKILL.md#working-with-networkx"
50
+ },
51
+ {
52
+ "id": "quick-reference",
53
+ "title": "Quick Reference",
54
+ "source": "SKILL.md#quick-reference"
55
+ },
56
+ {
57
+ "id": "resources",
58
+ "title": "Resources",
59
+ "source": "SKILL.md#resources"
60
+ },
61
+ {
62
+ "id": "additional-resources",
63
+ "title": "Additional Resources",
64
+ "source": "SKILL.md#additional-resources"
65
+ },
66
+ {
67
+ "id": "algorithms",
68
+ "title": "NetworkX Graph Algorithms",
69
+ "source": "references/algorithms.md"
70
+ },
71
+ {
72
+ "id": "generators",
73
+ "title": "NetworkX Graph Generators",
74
+ "source": "references/generators.md"
75
+ },
76
+ {
77
+ "id": "graph-basics",
78
+ "title": "NetworkX Graph Basics",
79
+ "source": "references/graph-basics.md"
80
+ },
81
+ {
82
+ "id": "io",
83
+ "title": "NetworkX Input/Output",
84
+ "source": "references/io.md"
85
+ },
86
+ {
87
+ "id": "visualization",
88
+ "title": "NetworkX Graph Visualization",
89
+ "source": "references/visualization.md"
90
+ }
91
+ ],
92
+ "checks": []
93
+ }