okstra 0.130.4 → 0.131.1

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 (365) hide show
  1. package/README.md +0 -1
  2. package/docs/architecture.md +2 -2
  3. package/docs/cli.md +1 -1
  4. package/docs/for-ai/README.md +0 -2
  5. package/docs/for-ai/skills/okstra-run.md +13 -2
  6. package/docs/for-ai/skills/okstra-setup.md +4 -1
  7. package/docs/project-structure-overview.md +5 -4
  8. package/docs/task-process/implementation-planning.md +13 -0
  9. package/docs/task-process/implementation.md +17 -2
  10. package/package.json +1 -1
  11. package/runtime/BUILD.json +2 -2
  12. package/runtime/agents/workers/report-writer-worker.md +7 -0
  13. package/runtime/bin/lib/okstra/usage.sh +4 -4
  14. package/runtime/prompts/lead/okstra-lead-contract.md +2 -2
  15. package/runtime/prompts/lead/plan-body-verification.md +26 -5
  16. package/runtime/prompts/lead/report-writer.md +6 -2
  17. package/runtime/prompts/profiles/_common-contract.md +2 -1
  18. package/runtime/prompts/profiles/_implementation-deliverable.md +6 -1
  19. package/runtime/prompts/profiles/_implementation-executor.md +2 -2
  20. package/runtime/prompts/profiles/_implementation-verifier.md +33 -10
  21. package/runtime/prompts/profiles/final-verification.md +21 -6
  22. package/runtime/prompts/profiles/implementation-planning.md +16 -4
  23. package/runtime/python/okstra_ctl/codex_dispatch.py +31 -0
  24. package/runtime/python/okstra_ctl/conformance.py +49 -11
  25. package/runtime/python/okstra_ctl/report_finalize.py +52 -1
  26. package/runtime/python/okstra_ctl/run.py +15 -3
  27. package/runtime/python/okstra_ctl/worker_prompt_contract.py +14 -6
  28. package/runtime/python/okstra_ctl/worker_prompt_policy.py +19 -1
  29. package/runtime/python/okstra_vendor/__init__.py +0 -44
  30. package/runtime/schemas/final-report-v1.0.schema.json +99 -5
  31. package/runtime/skills/okstra-run/SKILL.md +11 -4
  32. package/runtime/skills/okstra-setup/SKILL.md +3 -2
  33. package/runtime/skills/okstra-setup/references/project-config.md +16 -7
  34. package/runtime/templates/reports/final-report.template.md +15 -9
  35. package/runtime/templates/reports/i18n/en.json +1 -0
  36. package/runtime/templates/reports/i18n/ko.json +1 -0
  37. package/runtime/validators/lib/fixtures.sh +6 -0
  38. package/runtime/validators/validate-run.py +2019 -96
  39. package/src/cli-registry.mjs +0 -7
  40. package/src/commands/lifecycle/doctor.mjs +0 -9
  41. package/src/lib/skill-catalog.mjs +0 -1
  42. package/docs/for-ai/skills/okstra-graphify.md +0 -64
  43. package/runtime/python/okstra_ctl/graphify_cmd.py +0 -225
  44. package/runtime/python/okstra_vendor/graphify/.vendored-version +0 -1
  45. package/runtime/python/okstra_vendor/graphify/__init__.py +0 -28
  46. package/runtime/python/okstra_vendor/graphify/__main__.py +0 -1371
  47. package/runtime/python/okstra_vendor/graphify/analyze.py +0 -540
  48. package/runtime/python/okstra_vendor/graphify/benchmark.py +0 -129
  49. package/runtime/python/okstra_vendor/graphify/build.py +0 -107
  50. package/runtime/python/okstra_vendor/graphify/cache.py +0 -169
  51. package/runtime/python/okstra_vendor/graphify/cluster.py +0 -137
  52. package/runtime/python/okstra_vendor/graphify/detect.py +0 -510
  53. package/runtime/python/okstra_vendor/graphify/export.py +0 -1014
  54. package/runtime/python/okstra_vendor/graphify/extract.py +0 -3277
  55. package/runtime/python/okstra_vendor/graphify/hooks.py +0 -220
  56. package/runtime/python/okstra_vendor/graphify/ingest.py +0 -297
  57. package/runtime/python/okstra_vendor/graphify/manifest.py +0 -4
  58. package/runtime/python/okstra_vendor/graphify/report.py +0 -175
  59. package/runtime/python/okstra_vendor/graphify/security.py +0 -203
  60. package/runtime/python/okstra_vendor/graphify/serve.py +0 -373
  61. package/runtime/python/okstra_vendor/graphify/skill-aider.md +0 -1184
  62. package/runtime/python/okstra_vendor/graphify/skill-claw.md +0 -1184
  63. package/runtime/python/okstra_vendor/graphify/skill-codex.md +0 -1242
  64. package/runtime/python/okstra_vendor/graphify/skill-copilot.md +0 -1268
  65. package/runtime/python/okstra_vendor/graphify/skill-droid.md +0 -1239
  66. package/runtime/python/okstra_vendor/graphify/skill-kiro.md +0 -1183
  67. package/runtime/python/okstra_vendor/graphify/skill-opencode.md +0 -1238
  68. package/runtime/python/okstra_vendor/graphify/skill-trae.md +0 -1208
  69. package/runtime/python/okstra_vendor/graphify/skill-vscode.md +0 -253
  70. package/runtime/python/okstra_vendor/graphify/skill-windows.md +0 -1245
  71. package/runtime/python/okstra_vendor/graphify/skill.md +0 -1319
  72. package/runtime/python/okstra_vendor/graphify/transcribe.py +0 -182
  73. package/runtime/python/okstra_vendor/graphify/validate.py +0 -72
  74. package/runtime/python/okstra_vendor/graphify/watch.py +0 -188
  75. package/runtime/python/okstra_vendor/graphify/wiki.py +0 -214
  76. package/runtime/python/okstra_vendor/networkx/__init__.py +0 -62
  77. package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +0 -134
  78. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +0 -26
  79. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +0 -259
  80. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +0 -71
  81. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +0 -412
  82. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +0 -396
  83. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +0 -150
  84. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +0 -149
  85. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +0 -369
  86. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +0 -44
  87. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +0 -143
  88. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +0 -53
  89. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +0 -265
  90. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +0 -1508
  91. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +0 -255
  92. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +0 -83
  93. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +0 -5
  94. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +0 -122
  95. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +0 -302
  96. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +0 -255
  97. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +0 -160
  98. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +0 -127
  99. package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +0 -164
  100. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +0 -88
  101. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +0 -322
  102. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +0 -290
  103. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +0 -289
  104. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +0 -57
  105. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +0 -360
  106. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +0 -105
  107. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +0 -603
  108. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +0 -316
  109. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +0 -590
  110. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +0 -232
  111. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +0 -526
  112. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +0 -112
  113. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +0 -69
  114. package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +0 -168
  115. package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +0 -205
  116. package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +0 -164
  117. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +0 -20
  118. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +0 -591
  119. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +0 -236
  120. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +0 -282
  121. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +0 -364
  122. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +0 -227
  123. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +0 -96
  124. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +0 -150
  125. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +0 -107
  126. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +0 -357
  127. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +0 -130
  128. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +0 -787
  129. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +0 -88
  130. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +0 -331
  131. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +0 -150
  132. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +0 -200
  133. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +0 -128
  134. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +0 -209
  135. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +0 -141
  136. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +0 -361
  137. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +0 -181
  138. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +0 -95
  139. package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +0 -172
  140. package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +0 -443
  141. package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +0 -818
  142. package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +0 -732
  143. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +0 -4
  144. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +0 -505
  145. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +0 -565
  146. package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +0 -163
  147. package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +0 -28
  148. package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +0 -153
  149. package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +0 -354
  150. package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +0 -171
  151. package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +0 -30
  152. package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +0 -216
  153. package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +0 -79
  154. package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +0 -338
  155. package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +0 -162
  156. package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +0 -220
  157. package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +0 -384
  158. package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +0 -227
  159. package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +0 -452
  160. package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +0 -347
  161. package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +0 -6
  162. package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +0 -115
  163. package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +0 -394
  164. package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +0 -282
  165. package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +0 -71
  166. package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +0 -359
  167. package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +0 -196
  168. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +0 -11
  169. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +0 -811
  170. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +0 -616
  171. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +0 -408
  172. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +0 -1270
  173. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +0 -592
  174. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +0 -220
  175. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +0 -235
  176. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +0 -152
  177. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +0 -88
  178. package/runtime/python/okstra_vendor/networkx/algorithms/core.py +0 -588
  179. package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +0 -142
  180. package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +0 -416
  181. package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +0 -1234
  182. package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +0 -677
  183. package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +0 -1392
  184. package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +0 -1095
  185. package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +0 -272
  186. package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +0 -142
  187. package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +0 -268
  188. package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +0 -167
  189. package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +0 -470
  190. package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +0 -11
  191. package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +0 -370
  192. package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +0 -407
  193. package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +0 -238
  194. package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +0 -241
  195. package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +0 -178
  196. package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +0 -611
  197. package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +0 -356
  198. package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +0 -662
  199. package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +0 -425
  200. package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +0 -300
  201. package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +0 -194
  202. package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +0 -435
  203. package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +0 -483
  204. package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +0 -57
  205. package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +0 -196
  206. package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +0 -107
  207. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +0 -7
  208. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +0 -1306
  209. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +0 -336
  210. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +0 -1262
  211. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +0 -352
  212. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +0 -308
  213. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +0 -264
  214. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +0 -1102
  215. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +0 -192
  216. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +0 -2
  217. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +0 -337
  218. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +0 -498
  219. package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +0 -687
  220. package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +0 -280
  221. package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +0 -1148
  222. package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +0 -27
  223. package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +0 -738
  224. package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +0 -78
  225. package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +0 -59
  226. package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +0 -219
  227. package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +0 -155
  228. package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +0 -4
  229. package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +0 -324
  230. package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +0 -468
  231. package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +0 -633
  232. package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +0 -77
  233. package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +0 -73
  234. package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +0 -464
  235. package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +0 -1463
  236. package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +0 -306
  237. package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +0 -98
  238. package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +0 -167
  239. package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +0 -138
  240. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +0 -5
  241. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +0 -239
  242. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +0 -264
  243. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +0 -716
  244. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +0 -625
  245. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +0 -2542
  246. package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +0 -2107
  247. package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +0 -966
  248. package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +0 -404
  249. package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +0 -30
  250. package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +0 -296
  251. package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +0 -374
  252. package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +0 -564
  253. package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +0 -406
  254. package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +0 -981
  255. package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +0 -142
  256. package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +0 -406
  257. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +0 -5
  258. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +0 -90
  259. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +0 -576
  260. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +0 -529
  261. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +0 -185
  262. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +0 -182
  263. package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +0 -7
  264. package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +0 -1042
  265. package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +0 -413
  266. package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +0 -88
  267. package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +0 -219
  268. package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +0 -1281
  269. package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +0 -106
  270. package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +0 -273
  271. package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +0 -500
  272. package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +0 -76
  273. package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +0 -86
  274. package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +0 -77
  275. package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +0 -278
  276. package/runtime/python/okstra_vendor/networkx/classes/__init__.py +0 -13
  277. package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +0 -435
  278. package/runtime/python/okstra_vendor/networkx/classes/digraph.py +0 -1363
  279. package/runtime/python/okstra_vendor/networkx/classes/filters.py +0 -95
  280. package/runtime/python/okstra_vendor/networkx/classes/function.py +0 -1549
  281. package/runtime/python/okstra_vendor/networkx/classes/graph.py +0 -2082
  282. package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +0 -269
  283. package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +0 -977
  284. package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +0 -1294
  285. package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +0 -1447
  286. package/runtime/python/okstra_vendor/networkx/convert.py +0 -502
  287. package/runtime/python/okstra_vendor/networkx/convert_matrix.py +0 -1314
  288. package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +0 -7
  289. package/runtime/python/okstra_vendor/networkx/drawing/layout.py +0 -2036
  290. package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +0 -470
  291. package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +0 -570
  292. package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +0 -361
  293. package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +0 -2978
  294. package/runtime/python/okstra_vendor/networkx/exception.py +0 -131
  295. package/runtime/python/okstra_vendor/networkx/generators/__init__.py +0 -34
  296. package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
  297. package/runtime/python/okstra_vendor/networkx/generators/atlas.py +0 -227
  298. package/runtime/python/okstra_vendor/networkx/generators/classic.py +0 -1091
  299. package/runtime/python/okstra_vendor/networkx/generators/cographs.py +0 -68
  300. package/runtime/python/okstra_vendor/networkx/generators/community.py +0 -1070
  301. package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +0 -886
  302. package/runtime/python/okstra_vendor/networkx/generators/directed.py +0 -572
  303. package/runtime/python/okstra_vendor/networkx/generators/duplication.py +0 -174
  304. package/runtime/python/okstra_vendor/networkx/generators/ego.py +0 -66
  305. package/runtime/python/okstra_vendor/networkx/generators/expanders.py +0 -499
  306. package/runtime/python/okstra_vendor/networkx/generators/geometric.py +0 -1037
  307. package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +0 -163
  308. package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +0 -443
  309. package/runtime/python/okstra_vendor/networkx/generators/intersection.py +0 -125
  310. package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +0 -70
  311. package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +0 -664
  312. package/runtime/python/okstra_vendor/networkx/generators/lattice.py +0 -405
  313. package/runtime/python/okstra_vendor/networkx/generators/line.py +0 -501
  314. package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +0 -110
  315. package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +0 -259
  316. package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +0 -117
  317. package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +0 -1416
  318. package/runtime/python/okstra_vendor/networkx/generators/small.py +0 -1070
  319. package/runtime/python/okstra_vendor/networkx/generators/social.py +0 -554
  320. package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +0 -120
  321. package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +0 -54
  322. package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +0 -131
  323. package/runtime/python/okstra_vendor/networkx/generators/time_series.py +0 -74
  324. package/runtime/python/okstra_vendor/networkx/generators/trees.py +0 -1070
  325. package/runtime/python/okstra_vendor/networkx/generators/triads.py +0 -94
  326. package/runtime/python/okstra_vendor/networkx/lazy_imports.py +0 -188
  327. package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +0 -13
  328. package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +0 -650
  329. package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +0 -466
  330. package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +0 -77
  331. package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +0 -168
  332. package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +0 -512
  333. package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +0 -166
  334. package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +0 -186
  335. package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +0 -17
  336. package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +0 -330
  337. package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +0 -489
  338. package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +0 -1084
  339. package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +0 -879
  340. package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +0 -427
  341. package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +0 -1053
  342. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +0 -19
  343. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +0 -156
  344. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +0 -190
  345. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +0 -261
  346. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +0 -137
  347. package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +0 -108
  348. package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +0 -393
  349. package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +0 -113
  350. package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +0 -286
  351. package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +0 -379
  352. package/runtime/python/okstra_vendor/networkx/readwrite/text.py +0 -851
  353. package/runtime/python/okstra_vendor/networkx/relabel.py +0 -285
  354. package/runtime/python/okstra_vendor/networkx/utils/__init__.py +0 -8
  355. package/runtime/python/okstra_vendor/networkx/utils/backends.py +0 -2171
  356. package/runtime/python/okstra_vendor/networkx/utils/configs.py +0 -396
  357. package/runtime/python/okstra_vendor/networkx/utils/decorators.py +0 -1233
  358. package/runtime/python/okstra_vendor/networkx/utils/heaps.py +0 -338
  359. package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +0 -297
  360. package/runtime/python/okstra_vendor/networkx/utils/misc.py +0 -703
  361. package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +0 -198
  362. package/runtime/python/okstra_vendor/networkx/utils/rcm.py +0 -159
  363. package/runtime/python/okstra_vendor/networkx/utils/union_find.py +0 -106
  364. package/runtime/skills/okstra-graphify/SKILL.md +0 -169
  365. package/src/commands/graphify.mjs +0 -32
@@ -1,703 +0,0 @@
1
- """
2
- Miscellaneous Helpers for NetworkX.
3
-
4
- These are not imported into the base networkx namespace but
5
- can be accessed, for example, as
6
-
7
- >>> import networkx as nx
8
- >>> nx.utils.make_list_of_ints({1, 2, 3})
9
- [1, 2, 3]
10
- >>> nx.utils.arbitrary_element({5, 1, 7}) # doctest: +SKIP
11
- 1
12
- """
13
-
14
- import itertools
15
- import random
16
- import warnings
17
- from collections import defaultdict
18
- from collections.abc import Iterable, Iterator, Sized
19
- from itertools import chain, tee, zip_longest
20
-
21
- import networkx as nx
22
-
23
- __all__ = [
24
- "flatten",
25
- "make_list_of_ints",
26
- "dict_to_numpy_array",
27
- "arbitrary_element",
28
- "pairwise",
29
- "groups",
30
- "create_random_state",
31
- "create_py_random_state",
32
- "PythonRandomInterface",
33
- "PythonRandomViaNumpyBits",
34
- "nodes_equal",
35
- "edges_equal",
36
- "graphs_equal",
37
- "_clear_cache",
38
- ]
39
-
40
-
41
- # some cookbook stuff
42
- # used in deciding whether something is a bunch of nodes, edges, etc.
43
- # see G.add_nodes and others in Graph Class in networkx/base.py
44
-
45
-
46
- def flatten(obj, result=None):
47
- """Return flattened version of (possibly nested) iterable object."""
48
- if not isinstance(obj, Iterable | Sized) or isinstance(obj, str):
49
- return obj
50
- if result is None:
51
- result = []
52
- for item in obj:
53
- if not isinstance(item, Iterable | Sized) or isinstance(item, str):
54
- result.append(item)
55
- else:
56
- flatten(item, result)
57
- return tuple(result)
58
-
59
-
60
- def make_list_of_ints(sequence):
61
- """Return list of ints from sequence of integral numbers.
62
-
63
- All elements of the sequence must satisfy int(element) == element
64
- or a ValueError is raised. Sequence is iterated through once.
65
-
66
- If sequence is a list, the non-int values are replaced with ints.
67
- So, no new list is created
68
- """
69
- if not isinstance(sequence, list):
70
- result = []
71
- for i in sequence:
72
- errmsg = f"sequence is not all integers: {i}"
73
- try:
74
- ii = int(i)
75
- except ValueError:
76
- raise nx.NetworkXError(errmsg) from None
77
- if ii != i:
78
- raise nx.NetworkXError(errmsg)
79
- result.append(ii)
80
- return result
81
- # original sequence is a list... in-place conversion to ints
82
- for indx, i in enumerate(sequence):
83
- errmsg = f"sequence is not all integers: {i}"
84
- if isinstance(i, int):
85
- continue
86
- try:
87
- ii = int(i)
88
- except ValueError:
89
- raise nx.NetworkXError(errmsg) from None
90
- if ii != i:
91
- raise nx.NetworkXError(errmsg)
92
- sequence[indx] = ii
93
- return sequence
94
-
95
-
96
- def dict_to_numpy_array(d, mapping=None):
97
- """Convert a dictionary of dictionaries to a numpy array
98
- with optional mapping."""
99
- try:
100
- return _dict_to_numpy_array2(d, mapping)
101
- except (AttributeError, TypeError):
102
- # AttributeError is when no mapping was provided and v.keys() fails.
103
- # TypeError is when a mapping was provided and d[k1][k2] fails.
104
- return _dict_to_numpy_array1(d, mapping)
105
-
106
-
107
- def _dict_to_numpy_array2(d, mapping=None):
108
- """Convert a dictionary of dictionaries to a 2d numpy array
109
- with optional mapping.
110
-
111
- """
112
- import numpy as np
113
-
114
- if mapping is None:
115
- s = set(d.keys())
116
- for k, v in d.items():
117
- s.update(v.keys())
118
- mapping = dict(zip(s, range(len(s))))
119
- n = len(mapping)
120
- a = np.zeros((n, n))
121
- for k1, i in mapping.items():
122
- for k2, j in mapping.items():
123
- try:
124
- a[i, j] = d[k1][k2]
125
- except KeyError:
126
- pass
127
- return a
128
-
129
-
130
- def _dict_to_numpy_array1(d, mapping=None):
131
- """Convert a dictionary of numbers to a 1d numpy array with optional mapping."""
132
- import numpy as np
133
-
134
- if mapping is None:
135
- s = set(d.keys())
136
- mapping = dict(zip(s, range(len(s))))
137
- n = len(mapping)
138
- a = np.zeros(n)
139
- for k1, i in mapping.items():
140
- i = mapping[k1]
141
- a[i] = d[k1]
142
- return a
143
-
144
-
145
- def arbitrary_element(iterable):
146
- """Returns an arbitrary element of `iterable` without removing it.
147
-
148
- This is most useful for "peeking" at an arbitrary element of a set,
149
- but can be used for any list, dictionary, etc., as well.
150
-
151
- Parameters
152
- ----------
153
- iterable : `abc.collections.Iterable` instance
154
- Any object that implements ``__iter__``, e.g. set, dict, list, tuple,
155
- etc.
156
-
157
- Returns
158
- -------
159
- The object that results from ``next(iter(iterable))``
160
-
161
- Raises
162
- ------
163
- ValueError
164
- If `iterable` is an iterator (because the current implementation of
165
- this function would consume an element from the iterator).
166
-
167
- Examples
168
- --------
169
- Arbitrary elements from common Iterable objects:
170
-
171
- >>> nx.utils.arbitrary_element([1, 2, 3]) # list
172
- 1
173
- >>> nx.utils.arbitrary_element((1, 2, 3)) # tuple
174
- 1
175
- >>> nx.utils.arbitrary_element({1, 2, 3}) # set
176
- 1
177
- >>> d = {k: v for k, v in zip([1, 2, 3], [3, 2, 1])}
178
- >>> nx.utils.arbitrary_element(d) # dict_keys
179
- 1
180
- >>> nx.utils.arbitrary_element(d.values()) # dict values
181
- 3
182
-
183
- `str` is also an Iterable:
184
-
185
- >>> nx.utils.arbitrary_element("hello")
186
- 'h'
187
-
188
- :exc:`ValueError` is raised if `iterable` is an iterator:
189
-
190
- >>> iterator = iter([1, 2, 3]) # Iterator, *not* Iterable
191
- >>> nx.utils.arbitrary_element(iterator)
192
- Traceback (most recent call last):
193
- ...
194
- ValueError: cannot return an arbitrary item from an iterator
195
-
196
- Notes
197
- -----
198
- This function does not return a *random* element. If `iterable` is
199
- ordered, sequential calls will return the same value::
200
-
201
- >>> l = [1, 2, 3]
202
- >>> nx.utils.arbitrary_element(l)
203
- 1
204
- >>> nx.utils.arbitrary_element(l)
205
- 1
206
-
207
- """
208
- if isinstance(iterable, Iterator):
209
- raise ValueError("cannot return an arbitrary item from an iterator")
210
- # Another possible implementation is ``for x in iterable: return x``.
211
- return next(iter(iterable))
212
-
213
-
214
- def pairwise(iterable, cyclic=False):
215
- """Return successive overlapping pairs taken from an input iterable.
216
-
217
- Parameters
218
- ----------
219
- iterable : iterable
220
- An iterable from which to generate pairs.
221
-
222
- cyclic : bool, optional (default=False)
223
- If `True`, a pair with the last and first items is included at the end.
224
-
225
- Returns
226
- -------
227
- iterator
228
- An iterator over successive overlapping pairs from the `iterable`.
229
-
230
- See Also
231
- --------
232
- itertools.pairwise
233
-
234
- Examples
235
- --------
236
- >>> list(nx.utils.pairwise([1, 2, 3, 4]))
237
- [(1, 2), (2, 3), (3, 4)]
238
-
239
- >>> list(nx.utils.pairwise([1, 2, 3, 4], cyclic=True))
240
- [(1, 2), (2, 3), (3, 4), (4, 1)]
241
- """
242
- if not cyclic:
243
- return itertools.pairwise(iterable)
244
- a, b = tee(iterable)
245
- first = next(b, None)
246
- return zip(a, chain(b, (first,)))
247
-
248
-
249
- def groups(many_to_one):
250
- """Converts a many-to-one mapping into a one-to-many mapping.
251
-
252
- `many_to_one` must be a dictionary whose keys and values are all
253
- :term:`hashable`.
254
-
255
- The return value is a dictionary mapping values from `many_to_one`
256
- to sets of keys from `many_to_one` that have that value.
257
-
258
- Examples
259
- --------
260
- >>> from networkx.utils import groups
261
- >>> many_to_one = {"a": 1, "b": 1, "c": 2, "d": 3, "e": 3}
262
- >>> groups(many_to_one) # doctest: +SKIP
263
- {1: {'a', 'b'}, 2: {'c'}, 3: {'e', 'd'}}
264
- """
265
- one_to_many = defaultdict(set)
266
- for v, k in many_to_one.items():
267
- one_to_many[k].add(v)
268
- return dict(one_to_many)
269
-
270
-
271
- def create_random_state(random_state=None):
272
- """Returns a numpy.random.RandomState or numpy.random.Generator instance
273
- depending on input.
274
-
275
- Parameters
276
- ----------
277
- random_state : int or NumPy RandomState or Generator instance, optional (default=None)
278
- If int, return a numpy.random.RandomState instance set with seed=int.
279
- if `numpy.random.RandomState` instance, return it.
280
- if `numpy.random.Generator` instance, return it.
281
- if None or numpy.random, return the global random number generator used
282
- by numpy.random.
283
- """
284
- import numpy as np
285
-
286
- if random_state is None or random_state is np.random:
287
- return np.random.mtrand._rand
288
- if isinstance(random_state, np.random.RandomState):
289
- return random_state
290
- if isinstance(random_state, int):
291
- return np.random.RandomState(random_state)
292
- if isinstance(random_state, np.random.Generator):
293
- return random_state
294
- msg = (
295
- f"{random_state} cannot be used to create a numpy.random.RandomState or\n"
296
- "numpy.random.Generator instance"
297
- )
298
- raise ValueError(msg)
299
-
300
-
301
- class PythonRandomViaNumpyBits(random.Random):
302
- """Provide the random.random algorithms using a numpy.random bit generator
303
-
304
- The intent is to allow people to contribute code that uses Python's random
305
- library, but still allow users to provide a single easily controlled random
306
- bit-stream for all work with NetworkX. This implementation is based on helpful
307
- comments and code from Robert Kern on NumPy's GitHub Issue #24458.
308
-
309
- This implementation supersedes that of `PythonRandomInterface` which rewrote
310
- methods to account for subtle differences in API between `random` and
311
- `numpy.random`. Instead this subclasses `random.Random` and overwrites
312
- the methods `random`, `getrandbits`, `getstate`, `setstate` and `seed`.
313
- It makes them use the rng values from an input numpy `RandomState` or `Generator`.
314
- Those few methods allow the rest of the `random.Random` methods to provide
315
- the API interface of `random.random` while using randomness generated by
316
- a numpy generator.
317
- """
318
-
319
- def __init__(self, rng=None):
320
- try:
321
- import numpy as np
322
- except ImportError:
323
- msg = "numpy not found, only random.random available."
324
- warnings.warn(msg, ImportWarning)
325
-
326
- if rng is None:
327
- self._rng = np.random.mtrand._rand
328
- else:
329
- self._rng = rng
330
-
331
- # Not necessary, given our overriding of gauss() below, but it's
332
- # in the superclass and nominally public, so initialize it here.
333
- self.gauss_next = None
334
-
335
- def random(self):
336
- """Get the next random number in the range 0.0 <= X < 1.0."""
337
- return self._rng.random()
338
-
339
- def getrandbits(self, k):
340
- """getrandbits(k) -> x. Generates an int with k random bits."""
341
- if k < 0:
342
- raise ValueError("number of bits must be non-negative")
343
- numbytes = (k + 7) // 8 # bits / 8 and rounded up
344
- x = int.from_bytes(self._rng.bytes(numbytes), "big")
345
- return x >> (numbytes * 8 - k) # trim excess bits
346
-
347
- def getstate(self):
348
- return self._rng.__getstate__()
349
-
350
- def setstate(self, state):
351
- self._rng.__setstate__(state)
352
-
353
- def seed(self, *args, **kwds):
354
- "Do nothing override method."
355
- raise NotImplementedError("seed() not implemented in PythonRandomViaNumpyBits")
356
-
357
-
358
- ##################################################################
359
- class PythonRandomInterface:
360
- """PythonRandomInterface is included for backward compatibility
361
- New code should use PythonRandomViaNumpyBits instead.
362
- """
363
-
364
- def __init__(self, rng=None):
365
- try:
366
- import numpy as np
367
- except ImportError:
368
- msg = "numpy not found, only random.random available."
369
- warnings.warn(msg, ImportWarning)
370
-
371
- if rng is None:
372
- self._rng = np.random.mtrand._rand
373
- else:
374
- self._rng = rng
375
-
376
- def random(self):
377
- return self._rng.random()
378
-
379
- def uniform(self, a, b):
380
- return a + (b - a) * self._rng.random()
381
-
382
- def randrange(self, a, b=None):
383
- import numpy as np
384
-
385
- if b is None:
386
- a, b = 0, a
387
- if b > 9223372036854775807: # from np.iinfo(np.int64).max
388
- tmp_rng = PythonRandomViaNumpyBits(self._rng)
389
- return tmp_rng.randrange(a, b)
390
-
391
- if isinstance(self._rng, np.random.Generator):
392
- return self._rng.integers(a, b)
393
- return self._rng.randint(a, b)
394
-
395
- # NOTE: the numpy implementations of `choice` don't support strings, so
396
- # this cannot be replaced with self._rng.choice
397
- def choice(self, seq):
398
- import numpy as np
399
-
400
- if isinstance(self._rng, np.random.Generator):
401
- idx = self._rng.integers(0, len(seq))
402
- else:
403
- idx = self._rng.randint(0, len(seq))
404
- return seq[idx]
405
-
406
- def gauss(self, mu, sigma):
407
- return self._rng.normal(mu, sigma)
408
-
409
- def shuffle(self, seq):
410
- return self._rng.shuffle(seq)
411
-
412
- # Some methods don't match API for numpy RandomState.
413
- # Commented out versions are not used by NetworkX
414
-
415
- def sample(self, seq, k):
416
- return self._rng.choice(list(seq), size=(k,), replace=False)
417
-
418
- def randint(self, a, b):
419
- import numpy as np
420
-
421
- if b > 9223372036854775807: # from np.iinfo(np.int64).max
422
- tmp_rng = PythonRandomViaNumpyBits(self._rng)
423
- return tmp_rng.randint(a, b)
424
-
425
- if isinstance(self._rng, np.random.Generator):
426
- return self._rng.integers(a, b + 1)
427
- return self._rng.randint(a, b + 1)
428
-
429
- # exponential as expovariate with 1/argument,
430
- def expovariate(self, scale):
431
- return self._rng.exponential(1 / scale)
432
-
433
- # pareto as paretovariate with argument,
434
- def paretovariate(self, shape):
435
- return self._rng.pareto(shape)
436
-
437
-
438
- # weibull as weibullvariate multiplied by beta,
439
- # def weibullvariate(self, alpha, beta):
440
- # return self._rng.weibull(alpha) * beta
441
- #
442
- # def triangular(self, low, high, mode):
443
- # return self._rng.triangular(low, mode, high)
444
- #
445
- # def choices(self, seq, weights=None, cum_weights=None, k=1):
446
- # return self._rng.choice(seq
447
-
448
-
449
- def create_py_random_state(random_state=None):
450
- """Returns a random.Random instance depending on input.
451
-
452
- Parameters
453
- ----------
454
- random_state : int or random number generator or None (default=None)
455
- - If int, return a `random.Random` instance set with seed=int.
456
- - If `random.Random` instance, return it.
457
- - If None or the `np.random` package, return the global random number
458
- generator used by `np.random`.
459
- - If an `np.random.Generator` instance, or the `np.random` package, or
460
- the global numpy random number generator, then return it.
461
- wrapped in a `PythonRandomViaNumpyBits` class.
462
- - If a `PythonRandomViaNumpyBits` instance, return it.
463
- - If a `PythonRandomInterface` instance, return it.
464
- - If a `np.random.RandomState` instance and not the global numpy default,
465
- return it wrapped in `PythonRandomInterface` for backward bit-stream
466
- matching with legacy code.
467
-
468
- Notes
469
- -----
470
- - A diagram intending to illustrate the relationships behind our support
471
- for numpy random numbers is called
472
- `NetworkX Numpy Random Numbers <https://excalidraw.com/#room=b5303f2b03d3af7ccc6a,e5ZDIWdWWCTTsg8OqoRvPA>`_.
473
- - More discussion about this support also appears in
474
- `gh-6869#comment <https://github.com/networkx/networkx/pull/6869#issuecomment-1944799534>`_.
475
- - Wrappers of numpy.random number generators allow them to mimic the Python random
476
- number generation algorithms. For example, Python can create arbitrarily large
477
- random ints, and the wrappers use Numpy bit-streams with CPython's random module
478
- to choose arbitrarily large random integers too.
479
- - We provide two wrapper classes:
480
- `PythonRandomViaNumpyBits` is usually what you want and is always used for
481
- `np.Generator` instances. But for users who need to recreate random numbers
482
- produced in NetworkX 3.2 or earlier, we maintain the `PythonRandomInterface`
483
- wrapper as well. We use it only used if passed a (non-default) `np.RandomState`
484
- instance pre-initialized from a seed. Otherwise the newer wrapper is used.
485
- """
486
- if random_state is None or random_state is random:
487
- return random._inst
488
- if isinstance(random_state, random.Random):
489
- return random_state
490
- if isinstance(random_state, int):
491
- return random.Random(random_state)
492
-
493
- try:
494
- import numpy as np
495
- except ImportError:
496
- pass
497
- else:
498
- if isinstance(random_state, PythonRandomInterface | PythonRandomViaNumpyBits):
499
- return random_state
500
- if isinstance(random_state, np.random.Generator):
501
- return PythonRandomViaNumpyBits(random_state)
502
- if random_state is np.random:
503
- return PythonRandomViaNumpyBits(np.random.mtrand._rand)
504
-
505
- if isinstance(random_state, np.random.RandomState):
506
- if random_state is np.random.mtrand._rand:
507
- return PythonRandomViaNumpyBits(random_state)
508
- # Only need older interface if specially constructed RandomState used
509
- return PythonRandomInterface(random_state)
510
-
511
- msg = f"{random_state} cannot be used to generate a random.Random instance"
512
- raise ValueError(msg)
513
-
514
-
515
- def nodes_equal(nodes1, nodes2):
516
- """Check if nodes are equal.
517
-
518
- Equality here means equal as Python objects.
519
- Node data must match if included.
520
- The order of nodes is not relevant.
521
-
522
- Parameters
523
- ----------
524
- nodes1, nodes2 : iterables of nodes, or (node, datadict) tuples
525
-
526
- Returns
527
- -------
528
- bool
529
- True if nodes are equal, False otherwise.
530
- """
531
- nlist1 = list(nodes1)
532
- nlist2 = list(nodes2)
533
- try:
534
- d1 = dict(nlist1)
535
- d2 = dict(nlist2)
536
- except (ValueError, TypeError):
537
- d1 = dict.fromkeys(nlist1)
538
- d2 = dict.fromkeys(nlist2)
539
- return d1 == d2
540
-
541
-
542
- def edges_equal(edges1, edges2, *, directed=False):
543
- """Return whether edgelists are equal.
544
-
545
- Equality here means equal as Python objects. Edge data must match
546
- if included. Ordering of edges in an edgelist is not relevant;
547
- ordering of nodes in an edge is only relevant if ``directed == True``.
548
-
549
- Parameters
550
- ----------
551
- edges1, edges2 : iterables of tuples
552
- Each tuple can be
553
- an edge tuple ``(u, v)``, or
554
- an edge tuple with data `dict` s ``(u, v, d)``, or
555
- an edge tuple with keys and data `dict` s ``(u, v, k, d)``.
556
-
557
- directed : bool, optional (default=False)
558
- If `True`, edgelists are treated as coming from directed
559
- graphs.
560
-
561
- Returns
562
- -------
563
- bool
564
- `True` if edgelists are equal, `False` otherwise.
565
-
566
- Examples
567
- --------
568
- >>> G1 = nx.complete_graph(3)
569
- >>> G2 = nx.cycle_graph(3)
570
- >>> edges_equal(G1.edges, G2.edges)
571
- True
572
-
573
- Edge order is not taken into account:
574
-
575
- >>> G1 = nx.Graph([(0, 1), (1, 2)])
576
- >>> G2 = nx.Graph([(1, 2), (0, 1)])
577
- >>> edges_equal(G1.edges, G2.edges)
578
- True
579
-
580
- The `directed` parameter controls whether edges are treated as
581
- coming from directed graphs.
582
-
583
- >>> DG1 = nx.DiGraph([(0, 1)])
584
- >>> DG2 = nx.DiGraph([(1, 0)])
585
- >>> edges_equal(DG1.edges, DG2.edges, directed=False) # Not recommended.
586
- True
587
- >>> edges_equal(DG1.edges, DG2.edges, directed=True)
588
- False
589
-
590
- This function is meant to be used on edgelists (i.e. the output of a
591
- ``G.edges()`` call), and can give unexpected results on unprocessed
592
- lists of edges:
593
-
594
- >>> l1 = [(0, 1)]
595
- >>> l2 = [(0, 1), (1, 0)]
596
- >>> edges_equal(l1, l2) # Not recommended.
597
- False
598
- >>> G1 = nx.Graph(l1)
599
- >>> G2 = nx.Graph(l2)
600
- >>> edges_equal(G1.edges, G2.edges)
601
- True
602
- >>> DG1 = nx.DiGraph(l1)
603
- >>> DG2 = nx.DiGraph(l2)
604
- >>> edges_equal(DG1.edges, DG2.edges, directed=True)
605
- False
606
- """
607
- d1 = defaultdict(list)
608
- d2 = defaultdict(list)
609
-
610
- for e1, e2 in zip_longest(edges1, edges2, fillvalue=None):
611
- if e1 is None or e2 is None:
612
- return False # One is longer.
613
- for e, d in [(e1, d1), (e2, d2)]:
614
- u, v, *data = e
615
- d[u, v].append(data)
616
- if not directed:
617
- d[v, u].append(data)
618
-
619
- # Can check one direction because lengths are the same.
620
- return all(d1[e].count(data) == d2[e].count(data) for e in d1 for data in d1[e])
621
-
622
-
623
- def graphs_equal(graph1, graph2):
624
- """Check if graphs are equal.
625
-
626
- Equality here means equal as Python objects (not isomorphism).
627
- Node, edge and graph data must match.
628
-
629
- Parameters
630
- ----------
631
- graph1, graph2 : graph
632
-
633
- Returns
634
- -------
635
- bool
636
- True if graphs are equal, False otherwise.
637
- """
638
- return (
639
- graph1.adj == graph2.adj
640
- and graph1.nodes == graph2.nodes
641
- and graph1.graph == graph2.graph
642
- )
643
-
644
-
645
- def _clear_cache(G):
646
- """Clear the cache of a graph (currently stores converted graphs).
647
-
648
- Caching is controlled via ``nx.config.cache_converted_graphs`` configuration.
649
- """
650
- if cache := getattr(G, "__networkx_cache__", None):
651
- cache.clear()
652
-
653
-
654
- def check_create_using(create_using, *, directed=None, multigraph=None, default=None):
655
- """Assert that create_using has good properties
656
-
657
- This checks for desired directedness and multi-edge properties.
658
- It returns `create_using` unless that is `None` when it returns
659
- the optionally specified default value.
660
-
661
- Parameters
662
- ----------
663
- create_using : None, graph class or instance
664
- The input value of create_using for a function.
665
- directed : None or bool
666
- Whether to check `create_using.is_directed() == directed`.
667
- If None, do not assert directedness.
668
- multigraph : None or bool
669
- Whether to check `create_using.is_multigraph() == multigraph`.
670
- If None, do not assert multi-edge property.
671
- default : None or graph class
672
- The graph class to return if create_using is None.
673
-
674
- Returns
675
- -------
676
- create_using : graph class or instance
677
- The provided graph class or instance, or if None, the `default` value.
678
-
679
- Raises
680
- ------
681
- NetworkXError
682
- When `create_using` doesn't match the properties specified by `directed`
683
- or `multigraph` parameters.
684
- """
685
- if default is None:
686
- default = nx.Graph
687
- G = create_using if create_using is not None else default
688
-
689
- G_directed = G.is_directed(None) if isinstance(G, type) else G.is_directed()
690
- G_multigraph = G.is_multigraph(None) if isinstance(G, type) else G.is_multigraph()
691
-
692
- if directed is not None:
693
- if directed and not G_directed:
694
- raise nx.NetworkXError("create_using must be directed")
695
- if not directed and G_directed:
696
- raise nx.NetworkXError("create_using must not be directed")
697
-
698
- if multigraph is not None:
699
- if multigraph and not G_multigraph:
700
- raise nx.NetworkXError("create_using must be a multi-graph")
701
- if not multigraph and G_multigraph:
702
- raise nx.NetworkXError("create_using must not be a multi-graph")
703
- return G