okstra 0.130.4 → 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 (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 +1722 -98
  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,616 +0,0 @@
1
- """
2
- Flow based cut algorithms
3
- """
4
-
5
- import itertools
6
-
7
- import networkx as nx
8
-
9
- # Define the default maximum flow function to use in all flow based
10
- # cut algorithms.
11
- from networkx.algorithms.flow import build_residual_network, edmonds_karp
12
-
13
- from .utils import build_auxiliary_edge_connectivity, build_auxiliary_node_connectivity
14
-
15
- default_flow_func = edmonds_karp
16
-
17
- __all__ = [
18
- "minimum_st_node_cut",
19
- "minimum_node_cut",
20
- "minimum_st_edge_cut",
21
- "minimum_edge_cut",
22
- ]
23
-
24
-
25
- @nx._dispatchable(
26
- graphs={"G": 0, "auxiliary?": 4},
27
- preserve_edge_attrs={"auxiliary": {"capacity": float("inf")}},
28
- preserve_graph_attrs={"auxiliary"},
29
- )
30
- def minimum_st_edge_cut(G, s, t, flow_func=None, auxiliary=None, residual=None):
31
- """Returns the edges of the cut-set of a minimum (s, t)-cut.
32
-
33
- This function returns the set of edges of minimum cardinality that,
34
- if removed, would destroy all paths among source and target in G.
35
- Edge weights are not considered. See :meth:`minimum_cut` for
36
- computing minimum cuts considering edge weights.
37
-
38
- Parameters
39
- ----------
40
- G : NetworkX graph
41
-
42
- s : node
43
- Source node for the flow.
44
-
45
- t : node
46
- Sink node for the flow.
47
-
48
- auxiliary : NetworkX DiGraph
49
- Auxiliary digraph to compute flow based node connectivity. It has
50
- to have a graph attribute called mapping with a dictionary mapping
51
- node names in G and in the auxiliary digraph. If provided
52
- it will be reused instead of recreated. Default value: None.
53
-
54
- flow_func : function
55
- A function for computing the maximum flow among a pair of nodes.
56
- The function has to accept at least three parameters: a Digraph,
57
- a source node, and a target node. And return a residual network
58
- that follows NetworkX conventions (see :meth:`maximum_flow` for
59
- details). If flow_func is None, the default maximum flow function
60
- (:meth:`edmonds_karp`) is used. See :meth:`node_connectivity` for
61
- details. The choice of the default function may change from version
62
- to version and should not be relied on. Default value: None.
63
-
64
- residual : NetworkX DiGraph
65
- Residual network to compute maximum flow. If provided it will be
66
- reused instead of recreated. Default value: None.
67
-
68
- Returns
69
- -------
70
- cutset : set
71
- Set of edges that, if removed from the graph, will disconnect it.
72
-
73
- See also
74
- --------
75
- :meth:`minimum_cut`
76
- :meth:`minimum_node_cut`
77
- :meth:`minimum_edge_cut`
78
- :meth:`stoer_wagner`
79
- :meth:`node_connectivity`
80
- :meth:`edge_connectivity`
81
- :meth:`maximum_flow`
82
- :meth:`edmonds_karp`
83
- :meth:`preflow_push`
84
- :meth:`shortest_augmenting_path`
85
-
86
- Examples
87
- --------
88
- This function is not imported in the base NetworkX namespace, so you
89
- have to explicitly import it from the connectivity package:
90
-
91
- >>> from networkx.algorithms.connectivity import minimum_st_edge_cut
92
-
93
- We use in this example the platonic icosahedral graph, which has edge
94
- connectivity 5.
95
-
96
- >>> G = nx.icosahedral_graph()
97
- >>> len(minimum_st_edge_cut(G, 0, 6))
98
- 5
99
-
100
- If you need to compute local edge cuts on several pairs of
101
- nodes in the same graph, it is recommended that you reuse the
102
- data structures that NetworkX uses in the computation: the
103
- auxiliary digraph for edge connectivity, and the residual
104
- network for the underlying maximum flow computation.
105
-
106
- Example of how to compute local edge cuts among all pairs of
107
- nodes of the platonic icosahedral graph reusing the data
108
- structures.
109
-
110
- >>> import itertools
111
- >>> # You also have to explicitly import the function for
112
- >>> # building the auxiliary digraph from the connectivity package
113
- >>> from networkx.algorithms.connectivity import build_auxiliary_edge_connectivity
114
- >>> H = build_auxiliary_edge_connectivity(G)
115
- >>> # And the function for building the residual network from the
116
- >>> # flow package
117
- >>> from networkx.algorithms.flow import build_residual_network
118
- >>> # Note that the auxiliary digraph has an edge attribute named capacity
119
- >>> R = build_residual_network(H, "capacity")
120
- >>> result = dict.fromkeys(G, dict())
121
- >>> # Reuse the auxiliary digraph and the residual network by passing them
122
- >>> # as parameters
123
- >>> for u, v in itertools.combinations(G, 2):
124
- ... k = len(minimum_st_edge_cut(G, u, v, auxiliary=H, residual=R))
125
- ... result[u][v] = k
126
- >>> all(result[u][v] == 5 for u, v in itertools.combinations(G, 2))
127
- True
128
-
129
- You can also use alternative flow algorithms for computing edge
130
- cuts. For instance, in dense networks the algorithm
131
- :meth:`shortest_augmenting_path` will usually perform better than
132
- the default :meth:`edmonds_karp` which is faster for sparse
133
- networks with highly skewed degree distributions. Alternative flow
134
- functions have to be explicitly imported from the flow package.
135
-
136
- >>> from networkx.algorithms.flow import shortest_augmenting_path
137
- >>> len(minimum_st_edge_cut(G, 0, 6, flow_func=shortest_augmenting_path))
138
- 5
139
-
140
- """
141
- if flow_func is None:
142
- flow_func = default_flow_func
143
-
144
- if auxiliary is None:
145
- H = build_auxiliary_edge_connectivity(G)
146
- else:
147
- H = auxiliary
148
-
149
- kwargs = {"capacity": "capacity", "flow_func": flow_func, "residual": residual}
150
-
151
- cut_value, partition = nx.minimum_cut(H, s, t, **kwargs)
152
- reachable, non_reachable = partition
153
- # Any edge in the original graph linking the two sets in the
154
- # partition is part of the edge cutset
155
- cutset = set()
156
- for u, nbrs in ((n, G[n]) for n in reachable):
157
- cutset.update((u, v) for v in nbrs if v in non_reachable)
158
-
159
- return cutset
160
-
161
-
162
- @nx._dispatchable(
163
- graphs={"G": 0, "auxiliary?": 4},
164
- preserve_node_attrs={"auxiliary": {"id": None}},
165
- preserve_graph_attrs={"auxiliary"},
166
- )
167
- def minimum_st_node_cut(G, s, t, flow_func=None, auxiliary=None, residual=None):
168
- r"""Returns a set of nodes of minimum cardinality that disconnect source
169
- from target in G.
170
-
171
- This function returns the set of nodes of minimum cardinality that,
172
- if removed, would destroy all paths among source and target in G.
173
-
174
- Parameters
175
- ----------
176
- G : NetworkX graph
177
-
178
- s : node
179
- Source node.
180
-
181
- t : node
182
- Target node.
183
-
184
- flow_func : function
185
- A function for computing the maximum flow among a pair of nodes.
186
- The function has to accept at least three parameters: a Digraph,
187
- a source node, and a target node. And return a residual network
188
- that follows NetworkX conventions (see :meth:`maximum_flow` for
189
- details). If flow_func is None, the default maximum flow function
190
- (:meth:`edmonds_karp`) is used. See below for details. The choice
191
- of the default function may change from version to version and
192
- should not be relied on. Default value: None.
193
-
194
- auxiliary : NetworkX DiGraph
195
- Auxiliary digraph to compute flow based node connectivity. It has
196
- to have a graph attribute called mapping with a dictionary mapping
197
- node names in G and in the auxiliary digraph. If provided
198
- it will be reused instead of recreated. Default value: None.
199
-
200
- residual : NetworkX DiGraph
201
- Residual network to compute maximum flow. If provided it will be
202
- reused instead of recreated. Default value: None.
203
-
204
- Returns
205
- -------
206
- cutset : set
207
- Set of nodes that, if removed, would destroy all paths between
208
- source and target in G.
209
-
210
- Returns an empty set if source and target are either in different
211
- components or are directly connected by an edge, as no node removal
212
- can destroy the path.
213
-
214
- Examples
215
- --------
216
- This function is not imported in the base NetworkX namespace, so you
217
- have to explicitly import it from the connectivity package:
218
-
219
- >>> from networkx.algorithms.connectivity import minimum_st_node_cut
220
-
221
- We use in this example the platonic icosahedral graph, which has node
222
- connectivity 5.
223
-
224
- >>> G = nx.icosahedral_graph()
225
- >>> len(minimum_st_node_cut(G, 0, 6))
226
- 5
227
-
228
- If you need to compute local st cuts between several pairs of
229
- nodes in the same graph, it is recommended that you reuse the
230
- data structures that NetworkX uses in the computation: the
231
- auxiliary digraph for node connectivity and node cuts, and the
232
- residual network for the underlying maximum flow computation.
233
-
234
- Example of how to compute local st node cuts reusing the data
235
- structures:
236
-
237
- >>> # You also have to explicitly import the function for
238
- >>> # building the auxiliary digraph from the connectivity package
239
- >>> from networkx.algorithms.connectivity import build_auxiliary_node_connectivity
240
- >>> H = build_auxiliary_node_connectivity(G)
241
- >>> # And the function for building the residual network from the
242
- >>> # flow package
243
- >>> from networkx.algorithms.flow import build_residual_network
244
- >>> # Note that the auxiliary digraph has an edge attribute named capacity
245
- >>> R = build_residual_network(H, "capacity")
246
- >>> # Reuse the auxiliary digraph and the residual network by passing them
247
- >>> # as parameters
248
- >>> len(minimum_st_node_cut(G, 0, 6, auxiliary=H, residual=R))
249
- 5
250
-
251
- You can also use alternative flow algorithms for computing minimum st
252
- node cuts. For instance, in dense networks the algorithm
253
- :meth:`shortest_augmenting_path` will usually perform better than
254
- the default :meth:`edmonds_karp` which is faster for sparse
255
- networks with highly skewed degree distributions. Alternative flow
256
- functions have to be explicitly imported from the flow package.
257
-
258
- >>> from networkx.algorithms.flow import shortest_augmenting_path
259
- >>> len(minimum_st_node_cut(G, 0, 6, flow_func=shortest_augmenting_path))
260
- 5
261
-
262
- Notes
263
- -----
264
- This is a flow based implementation of minimum node cut. The algorithm
265
- is based in solving a number of maximum flow computations to determine
266
- the capacity of the minimum cut on an auxiliary directed network that
267
- corresponds to the minimum node cut of G. It handles both directed
268
- and undirected graphs. This implementation is based on algorithm 11
269
- in [1]_.
270
-
271
- See also
272
- --------
273
- :meth:`minimum_node_cut`
274
- :meth:`minimum_edge_cut`
275
- :meth:`stoer_wagner`
276
- :meth:`node_connectivity`
277
- :meth:`edge_connectivity`
278
- :meth:`maximum_flow`
279
- :meth:`edmonds_karp`
280
- :meth:`preflow_push`
281
- :meth:`shortest_augmenting_path`
282
-
283
- References
284
- ----------
285
- .. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
286
- http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf
287
-
288
- """
289
- if auxiliary is None:
290
- H = build_auxiliary_node_connectivity(G)
291
- else:
292
- H = auxiliary
293
-
294
- mapping = H.graph.get("mapping", None)
295
- if mapping is None:
296
- raise nx.NetworkXError("Invalid auxiliary digraph.")
297
- if G.has_edge(s, t) or G.has_edge(t, s):
298
- return set()
299
- kwargs = {"flow_func": flow_func, "residual": residual, "auxiliary": H}
300
-
301
- # The edge cut in the auxiliary digraph corresponds to the node cut in the
302
- # original graph.
303
- edge_cut = minimum_st_edge_cut(H, f"{mapping[s]}B", f"{mapping[t]}A", **kwargs)
304
- # Each node in the original graph maps to two nodes of the auxiliary graph
305
- node_cut = {H.nodes[node]["id"] for edge in edge_cut for node in edge}
306
- return node_cut - {s, t}
307
-
308
-
309
- @nx._dispatchable
310
- def minimum_node_cut(G, s=None, t=None, flow_func=None):
311
- r"""Returns a set of nodes of minimum cardinality that disconnects G.
312
-
313
- If source and target nodes are provided, this function returns the
314
- set of nodes of minimum cardinality that, if removed, would destroy
315
- all paths among source and target in G. If not, it returns a set
316
- of nodes of minimum cardinality that disconnects G.
317
-
318
- Parameters
319
- ----------
320
- G : NetworkX graph
321
-
322
- s : node
323
- Source node. Optional. Default value: None.
324
-
325
- t : node
326
- Target node. Optional. Default value: None.
327
-
328
- flow_func : function
329
- A function for computing the maximum flow among a pair of nodes.
330
- The function has to accept at least three parameters: a Digraph,
331
- a source node, and a target node. And return a residual network
332
- that follows NetworkX conventions (see :meth:`maximum_flow` for
333
- details). If flow_func is None, the default maximum flow function
334
- (:meth:`edmonds_karp`) is used. See below for details. The
335
- choice of the default function may change from version
336
- to version and should not be relied on. Default value: None.
337
-
338
- Returns
339
- -------
340
- cutset : set
341
- Set of nodes that, if removed, would disconnect G. If source
342
- and target nodes are provided, the set contains the nodes that
343
- if removed, would destroy all paths between source and target.
344
-
345
- Examples
346
- --------
347
- >>> # Platonic icosahedral graph has node connectivity 5
348
- >>> G = nx.icosahedral_graph()
349
- >>> node_cut = nx.minimum_node_cut(G)
350
- >>> len(node_cut)
351
- 5
352
-
353
- You can use alternative flow algorithms for the underlying maximum
354
- flow computation. In dense networks the algorithm
355
- :meth:`shortest_augmenting_path` will usually perform better
356
- than the default :meth:`edmonds_karp`, which is faster for
357
- sparse networks with highly skewed degree distributions. Alternative
358
- flow functions have to be explicitly imported from the flow package.
359
-
360
- >>> from networkx.algorithms.flow import shortest_augmenting_path
361
- >>> node_cut == nx.minimum_node_cut(G, flow_func=shortest_augmenting_path)
362
- True
363
-
364
- If you specify a pair of nodes (source and target) as parameters,
365
- this function returns a local st node cut.
366
-
367
- >>> len(nx.minimum_node_cut(G, 3, 7))
368
- 5
369
-
370
- If you need to perform several local st cuts among different
371
- pairs of nodes on the same graph, it is recommended that you reuse
372
- the data structures used in the maximum flow computations. See
373
- :meth:`minimum_st_node_cut` for details.
374
-
375
- Notes
376
- -----
377
- This is a flow based implementation of minimum node cut. The algorithm
378
- is based in solving a number of maximum flow computations to determine
379
- the capacity of the minimum cut on an auxiliary directed network that
380
- corresponds to the minimum node cut of G. It handles both directed
381
- and undirected graphs. This implementation is based on algorithm 11
382
- in [1]_.
383
-
384
- See also
385
- --------
386
- :meth:`minimum_st_node_cut`
387
- :meth:`minimum_cut`
388
- :meth:`minimum_edge_cut`
389
- :meth:`stoer_wagner`
390
- :meth:`node_connectivity`
391
- :meth:`edge_connectivity`
392
- :meth:`maximum_flow`
393
- :meth:`edmonds_karp`
394
- :meth:`preflow_push`
395
- :meth:`shortest_augmenting_path`
396
-
397
- References
398
- ----------
399
- .. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
400
- http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf
401
-
402
- """
403
- if (s is not None and t is None) or (s is None and t is not None):
404
- raise nx.NetworkXError("Both source and target must be specified.")
405
-
406
- # Local minimum node cut.
407
- if s is not None and t is not None:
408
- if s not in G:
409
- raise nx.NetworkXError(f"node {s} not in graph")
410
- if t not in G:
411
- raise nx.NetworkXError(f"node {t} not in graph")
412
- return minimum_st_node_cut(G, s, t, flow_func=flow_func)
413
-
414
- # Global minimum node cut.
415
- # Analog to the algorithm 11 for global node connectivity in [1].
416
- if G.is_directed():
417
- if not nx.is_weakly_connected(G):
418
- raise nx.NetworkXError("Input graph is not connected")
419
- iter_func = itertools.permutations
420
-
421
- def neighbors(v):
422
- return itertools.chain.from_iterable([G.predecessors(v), G.successors(v)])
423
-
424
- else:
425
- if not nx.is_connected(G):
426
- raise nx.NetworkXError("Input graph is not connected")
427
- iter_func = itertools.combinations
428
- neighbors = G.neighbors
429
-
430
- # Reuse the auxiliary digraph and the residual network.
431
- H = build_auxiliary_node_connectivity(G)
432
- R = build_residual_network(H, "capacity")
433
- kwargs = {"flow_func": flow_func, "auxiliary": H, "residual": R}
434
-
435
- # Choose a node with minimum degree.
436
- v = min(G, key=G.degree)
437
- # Initial node cutset is all neighbors of the node with minimum degree.
438
- min_cut = set(G[v])
439
- # Compute st node cuts between v and all its non-neighbors nodes in G.
440
- for w in set(G) - set(neighbors(v)) - {v}:
441
- this_cut = minimum_st_node_cut(G, v, w, **kwargs)
442
- if len(min_cut) >= len(this_cut):
443
- min_cut = this_cut
444
- # Also for non adjacent pairs of neighbors of v.
445
- for x, y in iter_func(neighbors(v), 2):
446
- if y in G[x]:
447
- continue
448
- this_cut = minimum_st_node_cut(G, x, y, **kwargs)
449
- if len(min_cut) >= len(this_cut):
450
- min_cut = this_cut
451
-
452
- return min_cut
453
-
454
-
455
- @nx._dispatchable
456
- def minimum_edge_cut(G, s=None, t=None, flow_func=None):
457
- r"""Returns a set of edges of minimum cardinality that disconnects G.
458
-
459
- If source and target nodes are provided, this function returns the
460
- set of edges of minimum cardinality that, if removed, would break
461
- all paths among source and target in G. If not, it returns a set of
462
- edges of minimum cardinality that disconnects G.
463
-
464
- Parameters
465
- ----------
466
- G : NetworkX graph
467
-
468
- s : node
469
- Source node. Optional. Default value: None.
470
-
471
- t : node
472
- Target node. Optional. Default value: None.
473
-
474
- flow_func : function
475
- A function for computing the maximum flow among a pair of nodes.
476
- The function has to accept at least three parameters: a Digraph,
477
- a source node, and a target node. And return a residual network
478
- that follows NetworkX conventions (see :meth:`maximum_flow` for
479
- details). If flow_func is None, the default maximum flow function
480
- (:meth:`edmonds_karp`) is used. See below for details. The
481
- choice of the default function may change from version
482
- to version and should not be relied on. Default value: None.
483
-
484
- Returns
485
- -------
486
- cutset : set
487
- Set of edges that, if removed, would disconnect G. If source
488
- and target nodes are provided, the set contains the edges that
489
- if removed, would destroy all paths between source and target.
490
-
491
- Examples
492
- --------
493
- >>> # Platonic icosahedral graph has edge connectivity 5
494
- >>> G = nx.icosahedral_graph()
495
- >>> len(nx.minimum_edge_cut(G))
496
- 5
497
-
498
- You can use alternative flow algorithms for the underlying
499
- maximum flow computation. In dense networks the algorithm
500
- :meth:`shortest_augmenting_path` will usually perform better
501
- than the default :meth:`edmonds_karp`, which is faster for
502
- sparse networks with highly skewed degree distributions.
503
- Alternative flow functions have to be explicitly imported
504
- from the flow package.
505
-
506
- >>> from networkx.algorithms.flow import shortest_augmenting_path
507
- >>> len(nx.minimum_edge_cut(G, flow_func=shortest_augmenting_path))
508
- 5
509
-
510
- If you specify a pair of nodes (source and target) as parameters,
511
- this function returns the value of local edge connectivity.
512
-
513
- >>> nx.edge_connectivity(G, 3, 7)
514
- 5
515
-
516
- If you need to perform several local computations among different
517
- pairs of nodes on the same graph, it is recommended that you reuse
518
- the data structures used in the maximum flow computations. See
519
- :meth:`local_edge_connectivity` for details.
520
-
521
- Notes
522
- -----
523
- This is a flow based implementation of minimum edge cut. For
524
- undirected graphs the algorithm works by finding a 'small' dominating
525
- set of nodes of G (see algorithm 7 in [1]_) and computing the maximum
526
- flow between an arbitrary node in the dominating set and the rest of
527
- nodes in it. This is an implementation of algorithm 6 in [1]_. For
528
- directed graphs, the algorithm does n calls to the max flow function.
529
- The function raises an error if the directed graph is not weakly
530
- connected and returns an empty set if it is weakly connected.
531
- It is an implementation of algorithm 8 in [1]_.
532
-
533
- See also
534
- --------
535
- :meth:`minimum_st_edge_cut`
536
- :meth:`minimum_node_cut`
537
- :meth:`stoer_wagner`
538
- :meth:`node_connectivity`
539
- :meth:`edge_connectivity`
540
- :meth:`maximum_flow`
541
- :meth:`edmonds_karp`
542
- :meth:`preflow_push`
543
- :meth:`shortest_augmenting_path`
544
-
545
- References
546
- ----------
547
- .. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
548
- http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf
549
-
550
- """
551
- if (s is not None and t is None) or (s is None and t is not None):
552
- raise nx.NetworkXError("Both source and target must be specified.")
553
-
554
- # reuse auxiliary digraph and residual network
555
- H = build_auxiliary_edge_connectivity(G)
556
- R = build_residual_network(H, "capacity")
557
- kwargs = {"flow_func": flow_func, "residual": R, "auxiliary": H}
558
-
559
- # Local minimum edge cut if s and t are not None
560
- if s is not None and t is not None:
561
- if s not in G:
562
- raise nx.NetworkXError(f"node {s} not in graph")
563
- if t not in G:
564
- raise nx.NetworkXError(f"node {t} not in graph")
565
- return minimum_st_edge_cut(H, s, t, **kwargs)
566
-
567
- # Global minimum edge cut
568
- # Analog to the algorithm for global edge connectivity
569
- if G.is_directed():
570
- # Based on algorithm 8 in [1]
571
- if not nx.is_weakly_connected(G):
572
- raise nx.NetworkXError("Input graph is not connected")
573
-
574
- # Initial cutset is all edges of a node with minimum degree
575
- node = min(G, key=G.degree)
576
- min_cut = set(G.edges(node))
577
- nodes = list(G)
578
- n = len(nodes)
579
- for i in range(n):
580
- try:
581
- this_cut = minimum_st_edge_cut(H, nodes[i], nodes[i + 1], **kwargs)
582
- if len(this_cut) <= len(min_cut):
583
- min_cut = this_cut
584
- except IndexError: # Last node!
585
- this_cut = minimum_st_edge_cut(H, nodes[i], nodes[0], **kwargs)
586
- if len(this_cut) <= len(min_cut):
587
- min_cut = this_cut
588
-
589
- return min_cut
590
-
591
- else: # undirected
592
- # Based on algorithm 6 in [1]
593
- if not nx.is_connected(G):
594
- raise nx.NetworkXError("Input graph is not connected")
595
-
596
- # Initial cutset is all edges of a node with minimum degree
597
- node = min(G, key=G.degree)
598
- min_cut = set(G.edges(node))
599
- # A dominating set is \lambda-covering
600
- # We need a dominating set with at least two nodes
601
- for node in G:
602
- D = nx.dominating_set(G, start_with=node)
603
- v = D.pop()
604
- if D:
605
- break
606
- else:
607
- # in complete graphs the dominating set will always be of one node
608
- # thus we return min_cut, which now contains the edges of a node
609
- # with minimum degree
610
- return min_cut
611
- for w in D:
612
- this_cut = minimum_st_edge_cut(H, v, w, **kwargs)
613
- if len(this_cut) <= len(min_cut):
614
- min_cut = this_cut
615
-
616
- return min_cut