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,369 +0,0 @@
1
- """Fast approximation for k-component structure"""
2
-
3
- import itertools
4
- from collections import defaultdict
5
- from collections.abc import Mapping
6
- from functools import cached_property
7
-
8
- import networkx as nx
9
- from networkx.algorithms.approximation import local_node_connectivity
10
- from networkx.exception import NetworkXError
11
- from networkx.utils import not_implemented_for
12
-
13
- __all__ = ["k_components"]
14
-
15
-
16
- @not_implemented_for("directed")
17
- @nx._dispatchable(name="approximate_k_components")
18
- def k_components(G, min_density=0.95):
19
- r"""Returns the approximate k-component structure of a graph G.
20
-
21
- A `k`-component is a maximal subgraph of a graph G that has, at least,
22
- node connectivity `k`: we need to remove at least `k` nodes to break it
23
- into more components. `k`-components have an inherent hierarchical
24
- structure because they are nested in terms of connectivity: a connected
25
- graph can contain several 2-components, each of which can contain
26
- one or more 3-components, and so forth.
27
-
28
- This implementation is based on the fast heuristics to approximate
29
- the `k`-component structure of a graph [1]_. Which, in turn, it is based on
30
- a fast approximation algorithm for finding good lower bounds of the number
31
- of node independent paths between two nodes [2]_.
32
-
33
- Parameters
34
- ----------
35
- G : NetworkX graph
36
- Undirected graph
37
-
38
- min_density : Float
39
- Density relaxation threshold. Default value 0.95
40
-
41
- Returns
42
- -------
43
- k_components : dict
44
- Dictionary with connectivity level `k` as key and a list of
45
- sets of nodes that form a k-component of level `k` as values.
46
-
47
- Raises
48
- ------
49
- NetworkXNotImplemented
50
- If G is directed.
51
-
52
- Examples
53
- --------
54
- >>> # Petersen graph has 10 nodes and it is triconnected, thus all
55
- >>> # nodes are in a single component on all three connectivity levels
56
- >>> from networkx.algorithms import approximation as apxa
57
- >>> G = nx.petersen_graph()
58
- >>> k_components = apxa.k_components(G)
59
-
60
- Notes
61
- -----
62
- The logic of the approximation algorithm for computing the `k`-component
63
- structure [1]_ is based on repeatedly applying simple and fast algorithms
64
- for `k`-cores and biconnected components in order to narrow down the
65
- number of pairs of nodes over which we have to compute White and Newman's
66
- approximation algorithm for finding node independent paths [2]_. More
67
- formally, this algorithm is based on Whitney's theorem, which states
68
- an inclusion relation among node connectivity, edge connectivity, and
69
- minimum degree for any graph G. This theorem implies that every
70
- `k`-component is nested inside a `k`-edge-component, which in turn,
71
- is contained in a `k`-core. Thus, this algorithm computes node independent
72
- paths among pairs of nodes in each biconnected part of each `k`-core,
73
- and repeats this procedure for each `k` from 3 to the maximal core number
74
- of a node in the input graph.
75
-
76
- Because, in practice, many nodes of the core of level `k` inside a
77
- bicomponent actually are part of a component of level k, the auxiliary
78
- graph needed for the algorithm is likely to be very dense. Thus, we use
79
- a complement graph data structure (see `AntiGraph`) to save memory.
80
- AntiGraph only stores information of the edges that are *not* present
81
- in the actual auxiliary graph. When applying algorithms to this
82
- complement graph data structure, it behaves as if it were the dense
83
- version.
84
-
85
- See also
86
- --------
87
- k_components
88
-
89
- References
90
- ----------
91
- .. [1] Torrents, J. and F. Ferraro (2015) Structural Cohesion:
92
- Visualization and Heuristics for Fast Computation.
93
- https://arxiv.org/pdf/1503.04476v1
94
-
95
- .. [2] White, Douglas R., and Mark Newman (2001) A Fast Algorithm for
96
- Node-Independent Paths. Santa Fe Institute Working Paper #01-07-035
97
- https://www.santafe.edu/research/results/working-papers/fast-approximation-algorithms-for-finding-node-ind
98
-
99
- .. [3] Moody, J. and D. White (2003). Social cohesion and embeddedness:
100
- A hierarchical conception of social groups.
101
- American Sociological Review 68(1), 103--28.
102
- https://doi.org/10.2307/3088904
103
-
104
- """
105
- # Dictionary with connectivity level (k) as keys and a list of
106
- # sets of nodes that form a k-component as values
107
- k_components = defaultdict(list)
108
- # make a few functions local for speed
109
- node_connectivity = local_node_connectivity
110
- k_core = nx.k_core
111
- core_number = nx.core_number
112
- biconnected_components = nx.biconnected_components
113
- combinations = itertools.combinations
114
- # Exact solution for k = {1,2}
115
- # There is a linear time algorithm for triconnectivity, if we had an
116
- # implementation available we could start from k = 4.
117
- for component in nx.connected_components(G):
118
- # isolated nodes have connectivity 0
119
- comp = set(component)
120
- if len(comp) > 1:
121
- k_components[1].append(comp)
122
- for bicomponent in nx.biconnected_components(G):
123
- # avoid considering dyads as bicomponents
124
- bicomp = set(bicomponent)
125
- if len(bicomp) > 2:
126
- k_components[2].append(bicomp)
127
- # There is no k-component of k > maximum core number
128
- # \kappa(G) <= \lambda(G) <= \delta(G)
129
- g_cnumber = core_number(G)
130
- max_core = max(g_cnumber.values())
131
- for k in range(3, max_core + 1):
132
- C = k_core(G, k, core_number=g_cnumber)
133
- for nodes in biconnected_components(C):
134
- # Build a subgraph SG induced by the nodes that are part of
135
- # each biconnected component of the k-core subgraph C.
136
- if len(nodes) < k:
137
- continue
138
- SG = G.subgraph(nodes)
139
- # Build auxiliary graph
140
- H = _AntiGraph()
141
- H.add_nodes_from(SG.nodes())
142
- for u, v in combinations(SG, 2):
143
- K = node_connectivity(SG, u, v, cutoff=k)
144
- if k > K:
145
- H.add_edge(u, v)
146
- for h_nodes in biconnected_components(H):
147
- if len(h_nodes) <= k:
148
- continue
149
- SH = H.subgraph(h_nodes)
150
- for Gc in _cliques_heuristic(SG, SH, k, min_density):
151
- for k_nodes in biconnected_components(Gc):
152
- Gk = nx.k_core(SG.subgraph(k_nodes), k)
153
- if len(Gk) <= k:
154
- continue
155
- k_components[k].append(set(Gk))
156
- return k_components
157
-
158
-
159
- def _cliques_heuristic(G, H, k, min_density):
160
- h_cnumber = nx.core_number(H)
161
- for i, c_value in enumerate(sorted(set(h_cnumber.values()), reverse=True)):
162
- cands = {n for n, c in h_cnumber.items() if c == c_value}
163
- # Skip checking for overlap for the highest core value
164
- if i == 0:
165
- overlap = False
166
- else:
167
- overlap = set.intersection(
168
- *[{x for x in H[n] if x not in cands} for n in cands]
169
- )
170
- if overlap and len(overlap) < k:
171
- SH = H.subgraph(cands | overlap)
172
- else:
173
- SH = H.subgraph(cands)
174
- sh_cnumber = nx.core_number(SH)
175
- SG = nx.k_core(G.subgraph(SH), k)
176
- while not (_same(sh_cnumber) and nx.density(SH) >= min_density):
177
- # This subgraph must be writable => .copy()
178
- SH = H.subgraph(SG).copy()
179
- if len(SH) <= k:
180
- break
181
- sh_cnumber = nx.core_number(SH)
182
- sh_deg = dict(SH.degree())
183
- min_deg = min(sh_deg.values())
184
- SH.remove_nodes_from(n for n, d in sh_deg.items() if d == min_deg)
185
- SG = nx.k_core(G.subgraph(SH), k)
186
- else:
187
- yield SG
188
-
189
-
190
- def _same(measure, tol=0):
191
- vals = set(measure.values())
192
- if (max(vals) - min(vals)) <= tol:
193
- return True
194
- return False
195
-
196
-
197
- class _AntiGraph(nx.Graph):
198
- """
199
- Class for complement graphs.
200
-
201
- The main goal is to be able to work with big and dense graphs with
202
- a low memory footprint.
203
-
204
- In this class you add the edges that *do not exist* in the dense graph,
205
- the report methods of the class return the neighbors, the edges and
206
- the degree as if it was the dense graph. Thus it's possible to use
207
- an instance of this class with some of NetworkX functions. In this
208
- case we only use k-core, connected_components, and biconnected_components.
209
- """
210
-
211
- all_edge_dict = {"weight": 1}
212
-
213
- def single_edge_dict(self):
214
- return self.all_edge_dict
215
-
216
- edge_attr_dict_factory = single_edge_dict # type: ignore[assignment]
217
-
218
- def __getitem__(self, n):
219
- """Returns a dict of neighbors of node n in the dense graph.
220
-
221
- Parameters
222
- ----------
223
- n : node
224
- A node in the graph.
225
-
226
- Returns
227
- -------
228
- adj_dict : dictionary
229
- The adjacency dictionary for nodes connected to n.
230
-
231
- """
232
- all_edge_dict = self.all_edge_dict
233
- return {
234
- node: all_edge_dict for node in set(self._adj) - set(self._adj[n]) - {n}
235
- }
236
-
237
- def neighbors(self, n):
238
- """Returns an iterator over all neighbors of node n in the
239
- dense graph.
240
- """
241
- try:
242
- return iter(set(self._adj) - set(self._adj[n]) - {n})
243
- except KeyError as err:
244
- raise NetworkXError(f"The node {n} is not in the graph.") from err
245
-
246
- class AntiAtlasView(Mapping):
247
- """An adjacency inner dict for AntiGraph"""
248
-
249
- def __init__(self, graph, node):
250
- self._graph = graph
251
- self._atlas = graph._adj[node]
252
- self._node = node
253
-
254
- def __len__(self):
255
- return len(self._graph) - len(self._atlas) - 1
256
-
257
- def __iter__(self):
258
- return (n for n in self._graph if n not in self._atlas and n != self._node)
259
-
260
- def __getitem__(self, nbr):
261
- nbrs = set(self._graph._adj) - set(self._atlas) - {self._node}
262
- if nbr in nbrs:
263
- return self._graph.all_edge_dict
264
- raise KeyError(nbr)
265
-
266
- class AntiAdjacencyView(AntiAtlasView):
267
- """An adjacency outer dict for AntiGraph"""
268
-
269
- def __init__(self, graph):
270
- self._graph = graph
271
- self._atlas = graph._adj
272
-
273
- def __len__(self):
274
- return len(self._atlas)
275
-
276
- def __iter__(self):
277
- return iter(self._graph)
278
-
279
- def __getitem__(self, node):
280
- if node not in self._graph:
281
- raise KeyError(node)
282
- return self._graph.AntiAtlasView(self._graph, node)
283
-
284
- @cached_property
285
- def adj(self):
286
- return self.AntiAdjacencyView(self)
287
-
288
- def subgraph(self, nodes):
289
- """This subgraph method returns a full AntiGraph. Not a View"""
290
- nodes = set(nodes)
291
- G = _AntiGraph()
292
- G.add_nodes_from(nodes)
293
- for n in G:
294
- Gnbrs = G.adjlist_inner_dict_factory()
295
- G._adj[n] = Gnbrs
296
- for nbr, d in self._adj[n].items():
297
- if nbr in G._adj:
298
- Gnbrs[nbr] = d
299
- G._adj[nbr][n] = d
300
- G.graph = self.graph
301
- return G
302
-
303
- class AntiDegreeView(nx.reportviews.DegreeView):
304
- def __iter__(self):
305
- all_nodes = set(self._succ)
306
- for n in self._nodes:
307
- nbrs = all_nodes - set(self._succ[n]) - {n}
308
- yield (n, len(nbrs))
309
-
310
- def __getitem__(self, n):
311
- nbrs = set(self._succ) - set(self._succ[n]) - {n}
312
- # AntiGraph is a ThinGraph so all edges have weight 1
313
- return len(nbrs) + (n in nbrs)
314
-
315
- @cached_property
316
- def degree(self):
317
- """Returns an iterator for (node, degree) and degree for single node.
318
-
319
- The node degree is the number of edges adjacent to the node.
320
-
321
- Parameters
322
- ----------
323
- nbunch : iterable container, optional (default=all nodes)
324
- A container of nodes. The container will be iterated
325
- through once.
326
-
327
- weight : string or None, optional (default=None)
328
- The edge attribute that holds the numerical value used
329
- as a weight. If None, then each edge has weight 1.
330
- The degree is the sum of the edge weights adjacent to the node.
331
-
332
- Returns
333
- -------
334
- deg:
335
- Degree of the node, if a single node is passed as argument.
336
- nd_iter : an iterator
337
- The iterator returns two-tuples of (node, degree).
338
-
339
- See Also
340
- --------
341
- degree
342
-
343
- Examples
344
- --------
345
- >>> G = nx.path_graph(4)
346
- >>> G.degree(0) # node 0 with degree 1
347
- 1
348
- >>> list(G.degree([0, 1]))
349
- [(0, 1), (1, 2)]
350
-
351
- """
352
- return self.AntiDegreeView(self)
353
-
354
- def adjacency(self):
355
- """Returns an iterator of (node, adjacency set) tuples for all nodes
356
- in the dense graph.
357
-
358
- This is the fastest way to look at every edge.
359
- For directed graphs, only outgoing adjacencies are included.
360
-
361
- Returns
362
- -------
363
- adj_iter : iterator
364
- An iterator of (node, adjacency set) for all nodes in
365
- the graph.
366
-
367
- """
368
- for n in self._adj:
369
- yield (n, set(self._adj) - set(self._adj[n]) - {n})
@@ -1,44 +0,0 @@
1
- """
2
- **************
3
- Graph Matching
4
- **************
5
-
6
- Given a graph G = (V,E), a matching M in G is a set of pairwise non-adjacent
7
- edges; that is, no two edges share a common vertex.
8
-
9
- `Wikipedia: Matching <https://en.wikipedia.org/wiki/Matching_(graph_theory)>`_
10
- """
11
-
12
- import networkx as nx
13
-
14
- __all__ = ["min_maximal_matching"]
15
-
16
-
17
- @nx._dispatchable
18
- def min_maximal_matching(G):
19
- r"""Returns the minimum maximal matching of G. That is, out of all maximal
20
- matchings of the graph G, the smallest is returned.
21
-
22
- Parameters
23
- ----------
24
- G : NetworkX graph
25
- Undirected graph
26
-
27
- Returns
28
- -------
29
- min_maximal_matching : set
30
- Returns a set of edges such that no two edges share a common endpoint
31
- and every edge not in the set shares some common endpoint in the set.
32
- Cardinality will be 2*OPT in the worst case.
33
-
34
- Notes
35
- -----
36
- The algorithm computes an approximate solution for the minimum maximal
37
- cardinality matching problem. The solution is no more than 2 * OPT in size.
38
- Runtime is $O(|E|)$.
39
-
40
- References
41
- ----------
42
- .. [1] Vazirani, Vijay Approximation Algorithms (2001)
43
- """
44
- return nx.maximal_matching(G)
@@ -1,143 +0,0 @@
1
- import networkx as nx
2
- from networkx.utils.decorators import not_implemented_for, py_random_state
3
-
4
- __all__ = ["randomized_partitioning", "one_exchange"]
5
-
6
-
7
- @not_implemented_for("directed")
8
- @not_implemented_for("multigraph")
9
- @py_random_state(1)
10
- @nx._dispatchable(edge_attrs="weight")
11
- def randomized_partitioning(G, seed=None, p=0.5, weight=None):
12
- """Compute a random partitioning of the graph nodes and its cut value.
13
-
14
- A partitioning is calculated by observing each node
15
- and deciding to add it to the partition with probability `p`,
16
- returning a random cut and its corresponding value (the
17
- sum of weights of edges connecting different partitions).
18
-
19
- Parameters
20
- ----------
21
- G : NetworkX graph
22
-
23
- seed : integer, random_state, or None (default)
24
- Indicator of random number generation state.
25
- See :ref:`Randomness<randomness>`.
26
-
27
- p : scalar
28
- Probability for each node to be part of the first partition.
29
- Should be in [0,1]
30
-
31
- weight : object
32
- Edge attribute key to use as weight. If not specified, edges
33
- have weight one.
34
-
35
- Returns
36
- -------
37
- cut_size : scalar
38
- Value of the minimum cut.
39
-
40
- partition : pair of node sets
41
- A partitioning of the nodes that defines a minimum cut.
42
-
43
- Examples
44
- --------
45
- >>> G = nx.complete_graph(5)
46
- >>> cut_size, partition = nx.approximation.randomized_partitioning(G, seed=1)
47
- >>> cut_size
48
- 6
49
- >>> partition
50
- ({0, 3, 4}, {1, 2})
51
-
52
- Raises
53
- ------
54
- NetworkXNotImplemented
55
- If the graph is directed or is a multigraph.
56
- """
57
- cut = {node for node in G.nodes() if seed.random() < p}
58
- cut_size = nx.algorithms.cut_size(G, cut, weight=weight)
59
- partition = (cut, G.nodes - cut)
60
- return cut_size, partition
61
-
62
-
63
- def _swap_node_partition(cut, node):
64
- return cut - {node} if node in cut else cut.union({node})
65
-
66
-
67
- @not_implemented_for("directed")
68
- @not_implemented_for("multigraph")
69
- @py_random_state(2)
70
- @nx._dispatchable(edge_attrs="weight")
71
- def one_exchange(G, initial_cut=None, seed=None, weight=None):
72
- """Compute a partitioning of the graphs nodes and the corresponding cut value.
73
-
74
- Use a greedy one exchange strategy to find a locally maximal cut
75
- and its value, it works by finding the best node (one that gives
76
- the highest gain to the cut value) to add to the current cut
77
- and repeats this process until no improvement can be made.
78
-
79
- Parameters
80
- ----------
81
- G : networkx Graph
82
- Graph to find a maximum cut for.
83
-
84
- initial_cut : set
85
- Cut to use as a starting point. If not supplied the algorithm
86
- starts with an empty cut.
87
-
88
- seed : integer, random_state, or None (default)
89
- Indicator of random number generation state.
90
- See :ref:`Randomness<randomness>`.
91
-
92
- weight : object
93
- Edge attribute key to use as weight. If not specified, edges
94
- have weight one.
95
-
96
- Returns
97
- -------
98
- cut_value : scalar
99
- Value of the maximum cut.
100
-
101
- partition : pair of node sets
102
- A partitioning of the nodes that defines a maximum cut.
103
-
104
- Examples
105
- --------
106
- >>> G = nx.complete_graph(5)
107
- >>> curr_cut_size, partition = nx.approximation.one_exchange(G, seed=1)
108
- >>> curr_cut_size
109
- 6
110
- >>> partition
111
- ({0, 2}, {1, 3, 4})
112
-
113
- Raises
114
- ------
115
- NetworkXNotImplemented
116
- If the graph is directed or is a multigraph.
117
- """
118
- if initial_cut is None:
119
- initial_cut = set()
120
- cut = set(initial_cut)
121
- current_cut_size = nx.algorithms.cut_size(G, cut, weight=weight)
122
- while True:
123
- nodes = list(G.nodes())
124
- # Shuffling the nodes ensures random tie-breaks in the following call to max
125
- seed.shuffle(nodes)
126
- best_node_to_swap = max(
127
- nodes,
128
- key=lambda v: nx.algorithms.cut_size(
129
- G, _swap_node_partition(cut, v), weight=weight
130
- ),
131
- default=None,
132
- )
133
- potential_cut = _swap_node_partition(cut, best_node_to_swap)
134
- potential_cut_size = nx.algorithms.cut_size(G, potential_cut, weight=weight)
135
-
136
- if potential_cut_size > current_cut_size:
137
- cut = potential_cut
138
- current_cut_size = potential_cut_size
139
- else:
140
- break
141
-
142
- partition = (cut, G.nodes - cut)
143
- return current_cut_size, partition
@@ -1,53 +0,0 @@
1
- """
2
- Ramsey numbers.
3
- """
4
-
5
- import networkx as nx
6
- from networkx.utils import not_implemented_for
7
-
8
- from ...utils import arbitrary_element
9
-
10
- __all__ = ["ramsey_R2"]
11
-
12
-
13
- @not_implemented_for("directed")
14
- @not_implemented_for("multigraph")
15
- @nx._dispatchable
16
- def ramsey_R2(G):
17
- r"""Compute the largest clique and largest independent set in `G`.
18
-
19
- This can be used to estimate bounds for the 2-color
20
- Ramsey number `R(2;s,t)` for `G`.
21
-
22
- This is a recursive implementation which could run into trouble
23
- for large recursions. Note that self-loop edges are ignored.
24
-
25
- Parameters
26
- ----------
27
- G : NetworkX graph
28
- Undirected graph
29
-
30
- Returns
31
- -------
32
- max_pair : (set, set) tuple
33
- Maximum clique, Maximum independent set.
34
-
35
- Raises
36
- ------
37
- NetworkXNotImplemented
38
- If the graph is directed or is a multigraph.
39
- """
40
- if not G:
41
- return set(), set()
42
-
43
- node = arbitrary_element(G)
44
- nbrs = (nbr for nbr in nx.all_neighbors(G, node) if nbr != node)
45
- nnbrs = nx.non_neighbors(G, node)
46
- c_1, i_1 = ramsey_R2(G.subgraph(nbrs).copy())
47
- c_2, i_2 = ramsey_R2(G.subgraph(nnbrs).copy())
48
-
49
- c_1.add(node)
50
- i_2.add(node)
51
- # Choose the larger of the two cliques and the larger of the two
52
- # independent sets, according to cardinality.
53
- return max(c_1, c_2, key=len), max(i_1, i_2, key=len)