okstra 0.130.3 → 0.131.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 (367) 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 +21 -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/report_views.py +32 -5
  27. package/runtime/python/okstra_ctl/run.py +15 -3
  28. package/runtime/python/okstra_ctl/worker_prompt_contract.py +14 -6
  29. package/runtime/python/okstra_ctl/worker_prompt_policy.py +19 -1
  30. package/runtime/python/okstra_vendor/__init__.py +0 -44
  31. package/runtime/schemas/final-report-v1.0.schema.json +101 -6
  32. package/runtime/skills/okstra-run/SKILL.md +11 -4
  33. package/runtime/skills/okstra-setup/SKILL.md +3 -2
  34. package/runtime/skills/okstra-setup/references/project-config.md +16 -7
  35. package/runtime/templates/reports/final-report.template.md +18 -12
  36. package/runtime/templates/reports/i18n/en.json +1 -0
  37. package/runtime/templates/reports/i18n/ko.json +1 -0
  38. package/runtime/templates/reports/report.css +18 -0
  39. package/runtime/validators/lib/fixtures.sh +6 -0
  40. package/runtime/validators/validate-run.py +1722 -98
  41. package/src/cli-registry.mjs +0 -7
  42. package/src/commands/lifecycle/doctor.mjs +0 -9
  43. package/src/lib/skill-catalog.mjs +0 -1
  44. package/docs/for-ai/skills/okstra-graphify.md +0 -64
  45. package/runtime/python/okstra_ctl/graphify_cmd.py +0 -225
  46. package/runtime/python/okstra_vendor/graphify/.vendored-version +0 -1
  47. package/runtime/python/okstra_vendor/graphify/__init__.py +0 -28
  48. package/runtime/python/okstra_vendor/graphify/__main__.py +0 -1371
  49. package/runtime/python/okstra_vendor/graphify/analyze.py +0 -540
  50. package/runtime/python/okstra_vendor/graphify/benchmark.py +0 -129
  51. package/runtime/python/okstra_vendor/graphify/build.py +0 -107
  52. package/runtime/python/okstra_vendor/graphify/cache.py +0 -169
  53. package/runtime/python/okstra_vendor/graphify/cluster.py +0 -137
  54. package/runtime/python/okstra_vendor/graphify/detect.py +0 -510
  55. package/runtime/python/okstra_vendor/graphify/export.py +0 -1014
  56. package/runtime/python/okstra_vendor/graphify/extract.py +0 -3277
  57. package/runtime/python/okstra_vendor/graphify/hooks.py +0 -220
  58. package/runtime/python/okstra_vendor/graphify/ingest.py +0 -297
  59. package/runtime/python/okstra_vendor/graphify/manifest.py +0 -4
  60. package/runtime/python/okstra_vendor/graphify/report.py +0 -175
  61. package/runtime/python/okstra_vendor/graphify/security.py +0 -203
  62. package/runtime/python/okstra_vendor/graphify/serve.py +0 -373
  63. package/runtime/python/okstra_vendor/graphify/skill-aider.md +0 -1184
  64. package/runtime/python/okstra_vendor/graphify/skill-claw.md +0 -1184
  65. package/runtime/python/okstra_vendor/graphify/skill-codex.md +0 -1242
  66. package/runtime/python/okstra_vendor/graphify/skill-copilot.md +0 -1268
  67. package/runtime/python/okstra_vendor/graphify/skill-droid.md +0 -1239
  68. package/runtime/python/okstra_vendor/graphify/skill-kiro.md +0 -1183
  69. package/runtime/python/okstra_vendor/graphify/skill-opencode.md +0 -1238
  70. package/runtime/python/okstra_vendor/graphify/skill-trae.md +0 -1208
  71. package/runtime/python/okstra_vendor/graphify/skill-vscode.md +0 -253
  72. package/runtime/python/okstra_vendor/graphify/skill-windows.md +0 -1245
  73. package/runtime/python/okstra_vendor/graphify/skill.md +0 -1319
  74. package/runtime/python/okstra_vendor/graphify/transcribe.py +0 -182
  75. package/runtime/python/okstra_vendor/graphify/validate.py +0 -72
  76. package/runtime/python/okstra_vendor/graphify/watch.py +0 -188
  77. package/runtime/python/okstra_vendor/graphify/wiki.py +0 -214
  78. package/runtime/python/okstra_vendor/networkx/__init__.py +0 -62
  79. package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +0 -134
  80. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +0 -26
  81. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +0 -259
  82. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +0 -71
  83. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +0 -412
  84. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +0 -396
  85. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +0 -150
  86. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +0 -149
  87. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +0 -369
  88. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +0 -44
  89. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +0 -143
  90. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +0 -53
  91. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +0 -265
  92. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +0 -1508
  93. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +0 -255
  94. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +0 -83
  95. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +0 -5
  96. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +0 -122
  97. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +0 -302
  98. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +0 -255
  99. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +0 -160
  100. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +0 -127
  101. package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +0 -164
  102. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +0 -88
  103. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +0 -322
  104. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +0 -290
  105. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +0 -289
  106. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +0 -57
  107. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +0 -360
  108. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +0 -105
  109. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +0 -603
  110. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +0 -316
  111. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +0 -590
  112. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +0 -232
  113. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +0 -526
  114. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +0 -112
  115. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +0 -69
  116. package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +0 -168
  117. package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +0 -205
  118. package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +0 -164
  119. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +0 -20
  120. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +0 -591
  121. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +0 -236
  122. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +0 -282
  123. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +0 -364
  124. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +0 -227
  125. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +0 -96
  126. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +0 -150
  127. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +0 -107
  128. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +0 -357
  129. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +0 -130
  130. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +0 -787
  131. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +0 -88
  132. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +0 -331
  133. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +0 -150
  134. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +0 -200
  135. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +0 -128
  136. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +0 -209
  137. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +0 -141
  138. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +0 -361
  139. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +0 -181
  140. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +0 -95
  141. package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +0 -172
  142. package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +0 -443
  143. package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +0 -818
  144. package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +0 -732
  145. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +0 -4
  146. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +0 -505
  147. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +0 -565
  148. package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +0 -163
  149. package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +0 -28
  150. package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +0 -153
  151. package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +0 -354
  152. package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +0 -171
  153. package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +0 -30
  154. package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +0 -216
  155. package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +0 -79
  156. package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +0 -338
  157. package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +0 -162
  158. package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +0 -220
  159. package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +0 -384
  160. package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +0 -227
  161. package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +0 -452
  162. package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +0 -347
  163. package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +0 -6
  164. package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +0 -115
  165. package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +0 -394
  166. package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +0 -282
  167. package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +0 -71
  168. package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +0 -359
  169. package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +0 -196
  170. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +0 -11
  171. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +0 -811
  172. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +0 -616
  173. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +0 -408
  174. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +0 -1270
  175. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +0 -592
  176. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +0 -220
  177. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +0 -235
  178. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +0 -152
  179. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +0 -88
  180. package/runtime/python/okstra_vendor/networkx/algorithms/core.py +0 -588
  181. package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +0 -142
  182. package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +0 -416
  183. package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +0 -1234
  184. package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +0 -677
  185. package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +0 -1392
  186. package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +0 -1095
  187. package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +0 -272
  188. package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +0 -142
  189. package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +0 -268
  190. package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +0 -167
  191. package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +0 -470
  192. package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +0 -11
  193. package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +0 -370
  194. package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +0 -407
  195. package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +0 -238
  196. package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +0 -241
  197. package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +0 -178
  198. package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +0 -611
  199. package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +0 -356
  200. package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +0 -662
  201. package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +0 -425
  202. package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +0 -300
  203. package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +0 -194
  204. package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +0 -435
  205. package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +0 -483
  206. package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +0 -57
  207. package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +0 -196
  208. package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +0 -107
  209. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +0 -7
  210. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +0 -1306
  211. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +0 -336
  212. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +0 -1262
  213. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +0 -352
  214. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +0 -308
  215. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +0 -264
  216. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +0 -1102
  217. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +0 -192
  218. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +0 -2
  219. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +0 -337
  220. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +0 -498
  221. package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +0 -687
  222. package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +0 -280
  223. package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +0 -1148
  224. package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +0 -27
  225. package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +0 -738
  226. package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +0 -78
  227. package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +0 -59
  228. package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +0 -219
  229. package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +0 -155
  230. package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +0 -4
  231. package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +0 -324
  232. package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +0 -468
  233. package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +0 -633
  234. package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +0 -77
  235. package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +0 -73
  236. package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +0 -464
  237. package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +0 -1463
  238. package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +0 -306
  239. package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +0 -98
  240. package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +0 -167
  241. package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +0 -138
  242. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +0 -5
  243. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +0 -239
  244. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +0 -264
  245. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +0 -716
  246. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +0 -625
  247. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +0 -2542
  248. package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +0 -2107
  249. package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +0 -966
  250. package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +0 -404
  251. package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +0 -30
  252. package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +0 -296
  253. package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +0 -374
  254. package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +0 -564
  255. package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +0 -406
  256. package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +0 -981
  257. package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +0 -142
  258. package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +0 -406
  259. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +0 -5
  260. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +0 -90
  261. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +0 -576
  262. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +0 -529
  263. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +0 -185
  264. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +0 -182
  265. package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +0 -7
  266. package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +0 -1042
  267. package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +0 -413
  268. package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +0 -88
  269. package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +0 -219
  270. package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +0 -1281
  271. package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +0 -106
  272. package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +0 -273
  273. package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +0 -500
  274. package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +0 -76
  275. package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +0 -86
  276. package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +0 -77
  277. package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +0 -278
  278. package/runtime/python/okstra_vendor/networkx/classes/__init__.py +0 -13
  279. package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +0 -435
  280. package/runtime/python/okstra_vendor/networkx/classes/digraph.py +0 -1363
  281. package/runtime/python/okstra_vendor/networkx/classes/filters.py +0 -95
  282. package/runtime/python/okstra_vendor/networkx/classes/function.py +0 -1549
  283. package/runtime/python/okstra_vendor/networkx/classes/graph.py +0 -2082
  284. package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +0 -269
  285. package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +0 -977
  286. package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +0 -1294
  287. package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +0 -1447
  288. package/runtime/python/okstra_vendor/networkx/convert.py +0 -502
  289. package/runtime/python/okstra_vendor/networkx/convert_matrix.py +0 -1314
  290. package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +0 -7
  291. package/runtime/python/okstra_vendor/networkx/drawing/layout.py +0 -2036
  292. package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +0 -470
  293. package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +0 -570
  294. package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +0 -361
  295. package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +0 -2978
  296. package/runtime/python/okstra_vendor/networkx/exception.py +0 -131
  297. package/runtime/python/okstra_vendor/networkx/generators/__init__.py +0 -34
  298. package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
  299. package/runtime/python/okstra_vendor/networkx/generators/atlas.py +0 -227
  300. package/runtime/python/okstra_vendor/networkx/generators/classic.py +0 -1091
  301. package/runtime/python/okstra_vendor/networkx/generators/cographs.py +0 -68
  302. package/runtime/python/okstra_vendor/networkx/generators/community.py +0 -1070
  303. package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +0 -886
  304. package/runtime/python/okstra_vendor/networkx/generators/directed.py +0 -572
  305. package/runtime/python/okstra_vendor/networkx/generators/duplication.py +0 -174
  306. package/runtime/python/okstra_vendor/networkx/generators/ego.py +0 -66
  307. package/runtime/python/okstra_vendor/networkx/generators/expanders.py +0 -499
  308. package/runtime/python/okstra_vendor/networkx/generators/geometric.py +0 -1037
  309. package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +0 -163
  310. package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +0 -443
  311. package/runtime/python/okstra_vendor/networkx/generators/intersection.py +0 -125
  312. package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +0 -70
  313. package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +0 -664
  314. package/runtime/python/okstra_vendor/networkx/generators/lattice.py +0 -405
  315. package/runtime/python/okstra_vendor/networkx/generators/line.py +0 -501
  316. package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +0 -110
  317. package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +0 -259
  318. package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +0 -117
  319. package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +0 -1416
  320. package/runtime/python/okstra_vendor/networkx/generators/small.py +0 -1070
  321. package/runtime/python/okstra_vendor/networkx/generators/social.py +0 -554
  322. package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +0 -120
  323. package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +0 -54
  324. package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +0 -131
  325. package/runtime/python/okstra_vendor/networkx/generators/time_series.py +0 -74
  326. package/runtime/python/okstra_vendor/networkx/generators/trees.py +0 -1070
  327. package/runtime/python/okstra_vendor/networkx/generators/triads.py +0 -94
  328. package/runtime/python/okstra_vendor/networkx/lazy_imports.py +0 -188
  329. package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +0 -13
  330. package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +0 -650
  331. package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +0 -466
  332. package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +0 -77
  333. package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +0 -168
  334. package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +0 -512
  335. package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +0 -166
  336. package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +0 -186
  337. package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +0 -17
  338. package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +0 -330
  339. package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +0 -489
  340. package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +0 -1084
  341. package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +0 -879
  342. package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +0 -427
  343. package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +0 -1053
  344. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +0 -19
  345. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +0 -156
  346. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +0 -190
  347. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +0 -261
  348. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +0 -137
  349. package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +0 -108
  350. package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +0 -393
  351. package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +0 -113
  352. package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +0 -286
  353. package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +0 -379
  354. package/runtime/python/okstra_vendor/networkx/readwrite/text.py +0 -851
  355. package/runtime/python/okstra_vendor/networkx/relabel.py +0 -285
  356. package/runtime/python/okstra_vendor/networkx/utils/__init__.py +0 -8
  357. package/runtime/python/okstra_vendor/networkx/utils/backends.py +0 -2171
  358. package/runtime/python/okstra_vendor/networkx/utils/configs.py +0 -396
  359. package/runtime/python/okstra_vendor/networkx/utils/decorators.py +0 -1233
  360. package/runtime/python/okstra_vendor/networkx/utils/heaps.py +0 -338
  361. package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +0 -297
  362. package/runtime/python/okstra_vendor/networkx/utils/misc.py +0 -703
  363. package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +0 -198
  364. package/runtime/python/okstra_vendor/networkx/utils/rcm.py +0 -159
  365. package/runtime/python/okstra_vendor/networkx/utils/union_find.py +0 -106
  366. package/runtime/skills/okstra-graphify/SKILL.md +0 -169
  367. package/src/commands/graphify.mjs +0 -32
@@ -1,572 +0,0 @@
1
- """
2
- Generators for some directed graphs, including growing network (GN) graphs and
3
- scale-free graphs.
4
-
5
- """
6
-
7
- import numbers
8
- from collections import Counter
9
-
10
- import networkx as nx
11
- from networkx.generators.classic import empty_graph
12
- from networkx.utils import (
13
- discrete_sequence,
14
- np_random_state,
15
- py_random_state,
16
- weighted_choice,
17
- )
18
-
19
- __all__ = [
20
- "gn_graph",
21
- "gnc_graph",
22
- "gnr_graph",
23
- "random_k_out_graph",
24
- "scale_free_graph",
25
- ]
26
-
27
-
28
- @py_random_state(3)
29
- @nx._dispatchable(graphs=None, returns_graph=True)
30
- def gn_graph(n, kernel=None, create_using=None, seed=None):
31
- """Returns the growing network (GN) digraph with `n` nodes.
32
-
33
- The GN graph is built by adding nodes one at a time with a link to one
34
- previously added node. The target node for the link is chosen with
35
- probability based on degree. The default attachment kernel is a linear
36
- function of the degree of a node.
37
-
38
- The graph is always a (directed) tree.
39
-
40
- Parameters
41
- ----------
42
- n : int
43
- The number of nodes for the generated graph.
44
- kernel : function
45
- The attachment kernel.
46
- create_using : NetworkX graph constructor, optional (default DiGraph)
47
- Graph type to create. If graph instance, then cleared before populated.
48
- seed : integer, random_state, or None (default)
49
- Indicator of random number generation state.
50
- See :ref:`Randomness<randomness>`.
51
-
52
- Examples
53
- --------
54
- To create the undirected GN graph, use the :meth:`~DiGraph.to_directed`
55
- method::
56
-
57
- >>> D = nx.gn_graph(10) # the GN graph
58
- >>> G = D.to_undirected() # the undirected version
59
-
60
- To specify an attachment kernel, use the `kernel` keyword argument::
61
-
62
- >>> D = nx.gn_graph(10, kernel=lambda x: x**1.5) # A_k = k^1.5
63
-
64
- References
65
- ----------
66
- .. [1] P. L. Krapivsky and S. Redner,
67
- Organization of Growing Random Networks,
68
- Phys. Rev. E, 63, 066123, 2001.
69
- """
70
- G = empty_graph(1, create_using, default=nx.DiGraph)
71
- if not G.is_directed():
72
- raise nx.NetworkXError("create_using must indicate a Directed Graph")
73
-
74
- if kernel is None:
75
-
76
- def kernel(x):
77
- return x
78
-
79
- if n == 1:
80
- return G
81
-
82
- G.add_edge(1, 0) # get started
83
- ds = [1, 1] # degree sequence
84
-
85
- for source in range(2, n):
86
- # compute distribution from kernel and degree
87
- dist = [kernel(d) for d in ds]
88
- # choose target from discrete distribution
89
- target = discrete_sequence(1, distribution=dist, seed=seed)[0]
90
- G.add_edge(source, target)
91
- ds.append(1) # the source has only one link (degree one)
92
- ds[target] += 1 # add one to the target link degree
93
- return G
94
-
95
-
96
- @py_random_state(3)
97
- @nx._dispatchable(graphs=None, returns_graph=True)
98
- def gnr_graph(n, p, create_using=None, seed=None):
99
- """Returns the growing network with redirection (GNR) digraph with `n`
100
- nodes and redirection probability `p`.
101
-
102
- The GNR graph is built by adding nodes one at a time with a link to one
103
- previously added node. The previous target node is chosen uniformly at
104
- random. With probability `p` the link is instead "redirected" to the
105
- successor node of the target.
106
-
107
- The graph is always a (directed) tree.
108
-
109
- Parameters
110
- ----------
111
- n : int
112
- The number of nodes for the generated graph.
113
- p : float
114
- The redirection probability.
115
- create_using : NetworkX graph constructor, optional (default DiGraph)
116
- Graph type to create. If graph instance, then cleared before populated.
117
- seed : integer, random_state, or None (default)
118
- Indicator of random number generation state.
119
- See :ref:`Randomness<randomness>`.
120
-
121
- Examples
122
- --------
123
- To create the undirected GNR graph, use the :meth:`~DiGraph.to_directed`
124
- method::
125
-
126
- >>> D = nx.gnr_graph(10, 0.5) # the GNR graph
127
- >>> G = D.to_undirected() # the undirected version
128
-
129
- References
130
- ----------
131
- .. [1] P. L. Krapivsky and S. Redner,
132
- Organization of Growing Random Networks,
133
- Phys. Rev. E, 63, 066123, 2001.
134
- """
135
- G = empty_graph(1, create_using, default=nx.DiGraph)
136
- if not G.is_directed():
137
- raise nx.NetworkXError("create_using must indicate a Directed Graph")
138
-
139
- if n == 1:
140
- return G
141
-
142
- for source in range(1, n):
143
- target = seed.randrange(0, source)
144
- if seed.random() < p and target != 0:
145
- target = next(G.successors(target))
146
- G.add_edge(source, target)
147
- return G
148
-
149
-
150
- @py_random_state(2)
151
- @nx._dispatchable(graphs=None, returns_graph=True)
152
- def gnc_graph(n, create_using=None, seed=None):
153
- """Returns the growing network with copying (GNC) digraph with `n` nodes.
154
-
155
- The GNC graph is built by adding nodes one at a time with a link to one
156
- previously added node (chosen uniformly at random) and to all of that
157
- node's successors.
158
-
159
- Parameters
160
- ----------
161
- n : int
162
- The number of nodes for the generated graph.
163
- create_using : NetworkX graph constructor, optional (default DiGraph)
164
- Graph type to create. If graph instance, then cleared before populated.
165
- seed : integer, random_state, or None (default)
166
- Indicator of random number generation state.
167
- See :ref:`Randomness<randomness>`.
168
-
169
- References
170
- ----------
171
- .. [1] P. L. Krapivsky and S. Redner,
172
- Network Growth by Copying,
173
- Phys. Rev. E, 71, 036118, 2005k.},
174
- """
175
- G = empty_graph(1, create_using, default=nx.DiGraph)
176
- if not G.is_directed():
177
- raise nx.NetworkXError("create_using must indicate a Directed Graph")
178
-
179
- if n == 1:
180
- return G
181
-
182
- for source in range(1, n):
183
- target = seed.randrange(0, source)
184
- for succ in G.successors(target):
185
- G.add_edge(source, succ)
186
- G.add_edge(source, target)
187
- return G
188
-
189
-
190
- @py_random_state(6)
191
- @nx._dispatchable(graphs=None, returns_graph=True)
192
- def scale_free_graph(
193
- n,
194
- alpha=0.41,
195
- beta=0.54,
196
- gamma=0.05,
197
- delta_in=0.2,
198
- delta_out=0,
199
- seed=None,
200
- initial_graph=None,
201
- ):
202
- """Returns a scale-free directed graph.
203
-
204
- Parameters
205
- ----------
206
- n : integer
207
- Number of nodes in graph
208
- alpha : float
209
- Probability for adding a new node connected to an existing node
210
- chosen randomly according to the in-degree distribution.
211
- beta : float
212
- Probability for adding an edge between two existing nodes.
213
- One existing node is chosen randomly according the in-degree
214
- distribution and the other chosen randomly according to the out-degree
215
- distribution.
216
- gamma : float
217
- Probability for adding a new node connected to an existing node
218
- chosen randomly according to the out-degree distribution.
219
- delta_in : float
220
- Bias for choosing nodes from in-degree distribution.
221
- delta_out : float
222
- Bias for choosing nodes from out-degree distribution.
223
- seed : integer, random_state, or None (default)
224
- Indicator of random number generation state.
225
- See :ref:`Randomness<randomness>`.
226
- initial_graph : MultiDiGraph instance, optional
227
- Build the scale-free graph starting from this initial MultiDiGraph,
228
- if provided.
229
-
230
- Returns
231
- -------
232
- MultiDiGraph
233
-
234
- Examples
235
- --------
236
- Create a scale-free graph on one hundred nodes::
237
-
238
- >>> G = nx.scale_free_graph(100)
239
-
240
- Notes
241
- -----
242
- The sum of `alpha`, `beta`, and `gamma` must be 1.
243
-
244
- References
245
- ----------
246
- .. [1] B. Bollobás, C. Borgs, J. Chayes, and O. Riordan,
247
- Directed scale-free graphs,
248
- Proceedings of the fourteenth annual ACM-SIAM Symposium on
249
- Discrete Algorithms, 132--139, 2003.
250
- """
251
-
252
- def _choose_node(candidates, node_list, delta):
253
- if delta > 0:
254
- bias_sum = len(node_list) * delta
255
- p_delta = bias_sum / (bias_sum + len(candidates))
256
- if seed.random() < p_delta:
257
- return seed.choice(node_list)
258
- return seed.choice(candidates)
259
-
260
- if initial_graph is not None and hasattr(initial_graph, "_adj"):
261
- if not isinstance(initial_graph, nx.MultiDiGraph):
262
- raise nx.NetworkXError("initial_graph must be a MultiDiGraph.")
263
- G = initial_graph
264
- else:
265
- # Start with 3-cycle
266
- G = nx.MultiDiGraph([(0, 1), (1, 2), (2, 0)])
267
-
268
- if alpha <= 0:
269
- raise ValueError("alpha must be > 0.")
270
- if beta <= 0:
271
- raise ValueError("beta must be > 0.")
272
- if gamma <= 0:
273
- raise ValueError("gamma must be > 0.")
274
-
275
- if abs(alpha + beta + gamma - 1.0) >= 1e-9:
276
- raise ValueError("alpha+beta+gamma must equal 1.")
277
-
278
- if delta_in < 0:
279
- raise ValueError("delta_in must be >= 0.")
280
-
281
- if delta_out < 0:
282
- raise ValueError("delta_out must be >= 0.")
283
-
284
- # pre-populate degree states
285
- vs = sum((count * [idx] for idx, count in G.out_degree()), [])
286
- ws = sum((count * [idx] for idx, count in G.in_degree()), [])
287
-
288
- # pre-populate node state
289
- node_list = list(G.nodes())
290
-
291
- # see if there already are number-based nodes
292
- numeric_nodes = [n for n in node_list if isinstance(n, numbers.Number)]
293
- if len(numeric_nodes) > 0:
294
- # set cursor for new nodes appropriately
295
- cursor = max(int(n.real) for n in numeric_nodes) + 1
296
- else:
297
- # or start at zero
298
- cursor = 0
299
-
300
- while len(G) < n:
301
- r = seed.random()
302
-
303
- # random choice in alpha,beta,gamma ranges
304
- if r < alpha:
305
- # alpha
306
- # add new node v
307
- v = cursor
308
- cursor += 1
309
- # also add to node state
310
- node_list.append(v)
311
- # choose w according to in-degree and delta_in
312
- w = _choose_node(ws, node_list, delta_in)
313
-
314
- elif r < alpha + beta:
315
- # beta
316
- # choose v according to out-degree and delta_out
317
- v = _choose_node(vs, node_list, delta_out)
318
- # choose w according to in-degree and delta_in
319
- w = _choose_node(ws, node_list, delta_in)
320
-
321
- else:
322
- # gamma
323
- # choose v according to out-degree and delta_out
324
- v = _choose_node(vs, node_list, delta_out)
325
- # add new node w
326
- w = cursor
327
- cursor += 1
328
- # also add to node state
329
- node_list.append(w)
330
-
331
- # add edge to graph
332
- G.add_edge(v, w)
333
-
334
- # update degree states
335
- vs.append(v)
336
- ws.append(w)
337
-
338
- return G
339
-
340
-
341
- @py_random_state(4)
342
- @nx._dispatchable(graphs=None, returns_graph=True)
343
- def random_uniform_k_out_graph(n, k, self_loops=True, with_replacement=True, seed=None):
344
- """Returns a random `k`-out graph with uniform attachment.
345
-
346
- A random `k`-out graph with uniform attachment is a multidigraph
347
- generated by the following algorithm. For each node *u*, choose
348
- `k` nodes *v* uniformly at random (with replacement). Add a
349
- directed edge joining *u* to *v*.
350
-
351
- Parameters
352
- ----------
353
- n : int
354
- The number of nodes in the returned graph.
355
-
356
- k : int
357
- The out-degree of each node in the returned graph.
358
-
359
- self_loops : bool
360
- If True, self-loops are allowed when generating the graph.
361
-
362
- with_replacement : bool
363
- If True, neighbors are chosen with replacement and the
364
- returned graph will be a directed multigraph. Otherwise,
365
- neighbors are chosen without replacement and the returned graph
366
- will be a directed graph.
367
-
368
- seed : integer, random_state, or None (default)
369
- Indicator of random number generation state.
370
- See :ref:`Randomness<randomness>`.
371
-
372
- Returns
373
- -------
374
- NetworkX graph
375
- A `k`-out-regular directed graph generated according to the
376
- above algorithm. It will be a multigraph if and only if
377
- `with_replacement` is True.
378
-
379
- Raises
380
- ------
381
- ValueError
382
- If `with_replacement` is False and `k` is greater than
383
- `n`.
384
-
385
- See also
386
- --------
387
- random_k_out_graph
388
-
389
- Notes
390
- -----
391
- The return digraph or multidigraph may not be strongly connected, or
392
- even weakly connected.
393
-
394
- If `with_replacement` is True, this function is similar to
395
- :func:`random_k_out_graph`, if that function had parameter `alpha`
396
- set to positive infinity.
397
-
398
- """
399
- if with_replacement:
400
- create_using = nx.MultiDiGraph()
401
-
402
- def sample(v, nodes):
403
- if not self_loops:
404
- nodes = nodes - {v}
405
- return (seed.choice(list(nodes)) for i in range(k))
406
-
407
- else:
408
- create_using = nx.DiGraph()
409
-
410
- def sample(v, nodes):
411
- if not self_loops:
412
- nodes = nodes - {v}
413
- return seed.sample(list(nodes), k)
414
-
415
- G = nx.empty_graph(n, create_using)
416
- nodes = set(G)
417
- for u in G:
418
- G.add_edges_from((u, v) for v in sample(u, nodes))
419
- return G
420
-
421
-
422
- @nx._dispatchable(graphs=None, returns_graph=True)
423
- def random_k_out_graph(n, k, alpha, self_loops=True, seed=None):
424
- """Returns a random `k`-out graph with preferential attachment.
425
-
426
- .. versionchanged:: 3.5
427
- Different implementations will be used based on whether NumPy is
428
- available. See Notes for details.
429
-
430
- A random `k`-out graph with preferential attachment is a
431
- multidigraph generated by the following algorithm.
432
-
433
- 1. Begin with an empty digraph, and initially set each node to have
434
- weight `alpha`.
435
- 2. Choose a node `u` with out-degree less than `k` uniformly at
436
- random.
437
- 3. Choose a node `v` from with probability proportional to its
438
- weight.
439
- 4. Add a directed edge from `u` to `v`, and increase the weight
440
- of `v` by one.
441
- 5. If each node has out-degree `k`, halt, otherwise repeat from
442
- step 2.
443
-
444
- For more information on this model of random graph, see [1]_.
445
-
446
- Parameters
447
- ----------
448
- n : int
449
- The number of nodes in the returned graph.
450
-
451
- k : int
452
- The out-degree of each node in the returned graph.
453
-
454
- alpha : float
455
- A positive :class:`float` representing the initial weight of
456
- each vertex. A higher number means that in step 3 above, nodes
457
- will be chosen more like a true uniformly random sample, and a
458
- lower number means that nodes are more likely to be chosen as
459
- their in-degree increases. If this parameter is not positive, a
460
- :exc:`ValueError` is raised.
461
-
462
- self_loops : bool
463
- If True, self-loops are allowed when generating the graph.
464
-
465
- seed : integer, random_state, or None (default)
466
- Indicator of random number generation state.
467
- See :ref:`Randomness<randomness>`.
468
-
469
- Returns
470
- -------
471
- :class:`~networkx.classes.MultiDiGraph`
472
- A `k`-out-regular multidigraph generated according to the above
473
- algorithm.
474
-
475
- Raises
476
- ------
477
- ValueError
478
- If `alpha` is not positive.
479
-
480
- Notes
481
- -----
482
- The returned multidigraph may not be strongly connected, or even
483
- weakly connected.
484
-
485
- `random_k_out_graph` has two implementations: an array-based formulation that
486
- uses `numpy` (``_random_k_out_graph_numpy``), and a pure-Python
487
- implementation (``_random_k_out_graph_python``).
488
- The NumPy implementation is more performant, especially for large `n`, and is
489
- therefore used by default. If NumPy is not installed in the environment,
490
- then the pure Python implementation is executed.
491
- However, you can explicitly control which implementation is executed by directly
492
- calling the corresponding function::
493
-
494
- # Use numpy if available, else Python
495
- nx.random_k_out_graph(1000, 5, alpha=1)
496
-
497
- # Use the numpy-based implementation (raises ImportError if numpy not installed)
498
- nx.generators.directed._random_k_out_graph_numpy(1000, 5, alpha=1)
499
-
500
- # Use the Python-based implementation
501
- nx.generators.directed._random_k_out_graph_python(1000, 5, alpha=1)
502
-
503
- References
504
- ----------
505
- .. [1] Peterson, Nicholas R., and Boris Pittel.
506
- "Distance between two random `k`-out digraphs, with and without preferential attachment."
507
- arXiv preprint arXiv:1311.5961 (2013) <https://arxiv.org/abs/1311.5961>.
508
-
509
- """
510
- if alpha < 0:
511
- raise ValueError("alpha must be positive")
512
- try: # Use numpy if available, otherwise fall back to pure Python implementation
513
- return _random_k_out_graph_numpy(n, k, alpha, self_loops, seed)
514
- except ImportError:
515
- return _random_k_out_graph_python(n, k, alpha, self_loops, seed)
516
-
517
-
518
- @np_random_state(4)
519
- def _random_k_out_graph_numpy(n, k, alpha, self_loops=True, seed=None):
520
- import numpy as np
521
-
522
- G = nx.empty_graph(n, create_using=nx.MultiDiGraph)
523
- nodes = np.arange(n)
524
- remaining_mask = np.full(n, True)
525
- weights = np.full(n, alpha)
526
- total_weight = n * alpha
527
- out_strengths = np.zeros(n)
528
-
529
- for i in range(k * n):
530
- u = seed.choice(nodes[remaining_mask])
531
-
532
- if self_loops:
533
- v = seed.choice(nodes, p=weights / total_weight)
534
- else: # Ignore weight of u when selecting v
535
- u_weight = weights[u]
536
- weights[u] = 0
537
- v = seed.choice(nodes, p=weights / (total_weight - u_weight))
538
- weights[u] = u_weight
539
-
540
- G.add_edge(u.item(), v.item())
541
- weights[v] += 1
542
- total_weight += 1
543
- out_strengths[u] += 1
544
- if out_strengths[u] == k:
545
- remaining_mask[u] = False
546
- return G
547
-
548
-
549
- @py_random_state(4)
550
- def _random_k_out_graph_python(n, k, alpha, self_loops=True, seed=None):
551
- G = nx.empty_graph(n, create_using=nx.MultiDiGraph)
552
- weights = Counter({v: alpha for v in G})
553
- out_strengths = Counter({v: 0 for v in G})
554
-
555
- for i in range(k * n):
556
- u = seed.choice(list(out_strengths.keys()))
557
- # If self-loops are not allowed, make the source node `u` have
558
- # weight zero.
559
- if not self_loops:
560
- uweight = weights.pop(u)
561
-
562
- v = weighted_choice(weights, seed=seed)
563
-
564
- if not self_loops:
565
- weights[u] = uweight
566
-
567
- G.add_edge(u, v)
568
- weights[v] += 1
569
- out_strengths[u] += 1
570
- if out_strengths[u] == k:
571
- out_strengths.pop(u)
572
- return G