okstra 0.130.3 → 0.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/README.md +0 -1
  2. package/docs/architecture.md +2 -2
  3. package/docs/cli.md +1 -1
  4. package/docs/for-ai/README.md +0 -2
  5. package/docs/for-ai/skills/okstra-run.md +13 -2
  6. package/docs/for-ai/skills/okstra-setup.md +4 -1
  7. package/docs/project-structure-overview.md +5 -4
  8. package/docs/task-process/implementation-planning.md +13 -0
  9. package/docs/task-process/implementation.md +17 -2
  10. package/package.json +1 -1
  11. package/runtime/BUILD.json +2 -2
  12. package/runtime/agents/workers/report-writer-worker.md +7 -0
  13. package/runtime/bin/lib/okstra/usage.sh +4 -4
  14. package/runtime/prompts/lead/okstra-lead-contract.md +2 -2
  15. package/runtime/prompts/lead/plan-body-verification.md +26 -5
  16. package/runtime/prompts/lead/report-writer.md +6 -2
  17. package/runtime/prompts/profiles/_common-contract.md +2 -1
  18. package/runtime/prompts/profiles/_implementation-deliverable.md +6 -1
  19. package/runtime/prompts/profiles/_implementation-executor.md +2 -2
  20. package/runtime/prompts/profiles/_implementation-verifier.md +33 -10
  21. package/runtime/prompts/profiles/final-verification.md +21 -6
  22. package/runtime/prompts/profiles/implementation-planning.md +21 -4
  23. package/runtime/python/okstra_ctl/codex_dispatch.py +31 -0
  24. package/runtime/python/okstra_ctl/conformance.py +49 -11
  25. package/runtime/python/okstra_ctl/report_finalize.py +52 -1
  26. package/runtime/python/okstra_ctl/report_views.py +32 -5
  27. package/runtime/python/okstra_ctl/run.py +15 -3
  28. package/runtime/python/okstra_ctl/worker_prompt_contract.py +14 -6
  29. package/runtime/python/okstra_ctl/worker_prompt_policy.py +19 -1
  30. package/runtime/python/okstra_vendor/__init__.py +0 -44
  31. package/runtime/schemas/final-report-v1.0.schema.json +101 -6
  32. package/runtime/skills/okstra-run/SKILL.md +11 -4
  33. package/runtime/skills/okstra-setup/SKILL.md +3 -2
  34. package/runtime/skills/okstra-setup/references/project-config.md +16 -7
  35. package/runtime/templates/reports/final-report.template.md +18 -12
  36. package/runtime/templates/reports/i18n/en.json +1 -0
  37. package/runtime/templates/reports/i18n/ko.json +1 -0
  38. package/runtime/templates/reports/report.css +18 -0
  39. package/runtime/validators/lib/fixtures.sh +6 -0
  40. package/runtime/validators/validate-run.py +1722 -98
  41. package/src/cli-registry.mjs +0 -7
  42. package/src/commands/lifecycle/doctor.mjs +0 -9
  43. package/src/lib/skill-catalog.mjs +0 -1
  44. package/docs/for-ai/skills/okstra-graphify.md +0 -64
  45. package/runtime/python/okstra_ctl/graphify_cmd.py +0 -225
  46. package/runtime/python/okstra_vendor/graphify/.vendored-version +0 -1
  47. package/runtime/python/okstra_vendor/graphify/__init__.py +0 -28
  48. package/runtime/python/okstra_vendor/graphify/__main__.py +0 -1371
  49. package/runtime/python/okstra_vendor/graphify/analyze.py +0 -540
  50. package/runtime/python/okstra_vendor/graphify/benchmark.py +0 -129
  51. package/runtime/python/okstra_vendor/graphify/build.py +0 -107
  52. package/runtime/python/okstra_vendor/graphify/cache.py +0 -169
  53. package/runtime/python/okstra_vendor/graphify/cluster.py +0 -137
  54. package/runtime/python/okstra_vendor/graphify/detect.py +0 -510
  55. package/runtime/python/okstra_vendor/graphify/export.py +0 -1014
  56. package/runtime/python/okstra_vendor/graphify/extract.py +0 -3277
  57. package/runtime/python/okstra_vendor/graphify/hooks.py +0 -220
  58. package/runtime/python/okstra_vendor/graphify/ingest.py +0 -297
  59. package/runtime/python/okstra_vendor/graphify/manifest.py +0 -4
  60. package/runtime/python/okstra_vendor/graphify/report.py +0 -175
  61. package/runtime/python/okstra_vendor/graphify/security.py +0 -203
  62. package/runtime/python/okstra_vendor/graphify/serve.py +0 -373
  63. package/runtime/python/okstra_vendor/graphify/skill-aider.md +0 -1184
  64. package/runtime/python/okstra_vendor/graphify/skill-claw.md +0 -1184
  65. package/runtime/python/okstra_vendor/graphify/skill-codex.md +0 -1242
  66. package/runtime/python/okstra_vendor/graphify/skill-copilot.md +0 -1268
  67. package/runtime/python/okstra_vendor/graphify/skill-droid.md +0 -1239
  68. package/runtime/python/okstra_vendor/graphify/skill-kiro.md +0 -1183
  69. package/runtime/python/okstra_vendor/graphify/skill-opencode.md +0 -1238
  70. package/runtime/python/okstra_vendor/graphify/skill-trae.md +0 -1208
  71. package/runtime/python/okstra_vendor/graphify/skill-vscode.md +0 -253
  72. package/runtime/python/okstra_vendor/graphify/skill-windows.md +0 -1245
  73. package/runtime/python/okstra_vendor/graphify/skill.md +0 -1319
  74. package/runtime/python/okstra_vendor/graphify/transcribe.py +0 -182
  75. package/runtime/python/okstra_vendor/graphify/validate.py +0 -72
  76. package/runtime/python/okstra_vendor/graphify/watch.py +0 -188
  77. package/runtime/python/okstra_vendor/graphify/wiki.py +0 -214
  78. package/runtime/python/okstra_vendor/networkx/__init__.py +0 -62
  79. package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +0 -134
  80. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +0 -26
  81. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +0 -259
  82. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +0 -71
  83. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +0 -412
  84. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +0 -396
  85. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +0 -150
  86. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +0 -149
  87. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +0 -369
  88. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +0 -44
  89. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +0 -143
  90. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +0 -53
  91. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +0 -265
  92. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +0 -1508
  93. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +0 -255
  94. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +0 -83
  95. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +0 -5
  96. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +0 -122
  97. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +0 -302
  98. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +0 -255
  99. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +0 -160
  100. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +0 -127
  101. package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +0 -164
  102. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +0 -88
  103. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +0 -322
  104. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +0 -290
  105. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +0 -289
  106. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +0 -57
  107. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +0 -360
  108. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +0 -105
  109. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +0 -603
  110. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +0 -316
  111. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +0 -590
  112. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +0 -232
  113. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +0 -526
  114. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +0 -112
  115. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +0 -69
  116. package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +0 -168
  117. package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +0 -205
  118. package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +0 -164
  119. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +0 -20
  120. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +0 -591
  121. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +0 -236
  122. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +0 -282
  123. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +0 -364
  124. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +0 -227
  125. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +0 -96
  126. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +0 -150
  127. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +0 -107
  128. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +0 -357
  129. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +0 -130
  130. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +0 -787
  131. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +0 -88
  132. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +0 -331
  133. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +0 -150
  134. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +0 -200
  135. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +0 -128
  136. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +0 -209
  137. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +0 -141
  138. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +0 -361
  139. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +0 -181
  140. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +0 -95
  141. package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +0 -172
  142. package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +0 -443
  143. package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +0 -818
  144. package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +0 -732
  145. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +0 -4
  146. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +0 -505
  147. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +0 -565
  148. package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +0 -163
  149. package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +0 -28
  150. package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +0 -153
  151. package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +0 -354
  152. package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +0 -171
  153. package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +0 -30
  154. package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +0 -216
  155. package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +0 -79
  156. package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +0 -338
  157. package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +0 -162
  158. package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +0 -220
  159. package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +0 -384
  160. package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +0 -227
  161. package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +0 -452
  162. package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +0 -347
  163. package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +0 -6
  164. package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +0 -115
  165. package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +0 -394
  166. package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +0 -282
  167. package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +0 -71
  168. package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +0 -359
  169. package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +0 -196
  170. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +0 -11
  171. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +0 -811
  172. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +0 -616
  173. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +0 -408
  174. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +0 -1270
  175. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +0 -592
  176. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +0 -220
  177. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +0 -235
  178. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +0 -152
  179. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +0 -88
  180. package/runtime/python/okstra_vendor/networkx/algorithms/core.py +0 -588
  181. package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +0 -142
  182. package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +0 -416
  183. package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +0 -1234
  184. package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +0 -677
  185. package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +0 -1392
  186. package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +0 -1095
  187. package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +0 -272
  188. package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +0 -142
  189. package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +0 -268
  190. package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +0 -167
  191. package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +0 -470
  192. package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +0 -11
  193. package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +0 -370
  194. package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +0 -407
  195. package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +0 -238
  196. package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +0 -241
  197. package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +0 -178
  198. package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +0 -611
  199. package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +0 -356
  200. package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +0 -662
  201. package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +0 -425
  202. package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +0 -300
  203. package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +0 -194
  204. package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +0 -435
  205. package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +0 -483
  206. package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +0 -57
  207. package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +0 -196
  208. package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +0 -107
  209. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +0 -7
  210. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +0 -1306
  211. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +0 -336
  212. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +0 -1262
  213. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +0 -352
  214. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +0 -308
  215. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +0 -264
  216. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +0 -1102
  217. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +0 -192
  218. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +0 -2
  219. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +0 -337
  220. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +0 -498
  221. package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +0 -687
  222. package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +0 -280
  223. package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +0 -1148
  224. package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +0 -27
  225. package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +0 -738
  226. package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +0 -78
  227. package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +0 -59
  228. package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +0 -219
  229. package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +0 -155
  230. package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +0 -4
  231. package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +0 -324
  232. package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +0 -468
  233. package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +0 -633
  234. package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +0 -77
  235. package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +0 -73
  236. package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +0 -464
  237. package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +0 -1463
  238. package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +0 -306
  239. package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +0 -98
  240. package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +0 -167
  241. package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +0 -138
  242. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +0 -5
  243. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +0 -239
  244. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +0 -264
  245. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +0 -716
  246. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +0 -625
  247. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +0 -2542
  248. package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +0 -2107
  249. package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +0 -966
  250. package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +0 -404
  251. package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +0 -30
  252. package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +0 -296
  253. package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +0 -374
  254. package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +0 -564
  255. package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +0 -406
  256. package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +0 -981
  257. package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +0 -142
  258. package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +0 -406
  259. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +0 -5
  260. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +0 -90
  261. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +0 -576
  262. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +0 -529
  263. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +0 -185
  264. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +0 -182
  265. package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +0 -7
  266. package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +0 -1042
  267. package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +0 -413
  268. package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +0 -88
  269. package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +0 -219
  270. package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +0 -1281
  271. package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +0 -106
  272. package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +0 -273
  273. package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +0 -500
  274. package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +0 -76
  275. package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +0 -86
  276. package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +0 -77
  277. package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +0 -278
  278. package/runtime/python/okstra_vendor/networkx/classes/__init__.py +0 -13
  279. package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +0 -435
  280. package/runtime/python/okstra_vendor/networkx/classes/digraph.py +0 -1363
  281. package/runtime/python/okstra_vendor/networkx/classes/filters.py +0 -95
  282. package/runtime/python/okstra_vendor/networkx/classes/function.py +0 -1549
  283. package/runtime/python/okstra_vendor/networkx/classes/graph.py +0 -2082
  284. package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +0 -269
  285. package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +0 -977
  286. package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +0 -1294
  287. package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +0 -1447
  288. package/runtime/python/okstra_vendor/networkx/convert.py +0 -502
  289. package/runtime/python/okstra_vendor/networkx/convert_matrix.py +0 -1314
  290. package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +0 -7
  291. package/runtime/python/okstra_vendor/networkx/drawing/layout.py +0 -2036
  292. package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +0 -470
  293. package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +0 -570
  294. package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +0 -361
  295. package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +0 -2978
  296. package/runtime/python/okstra_vendor/networkx/exception.py +0 -131
  297. package/runtime/python/okstra_vendor/networkx/generators/__init__.py +0 -34
  298. package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
  299. package/runtime/python/okstra_vendor/networkx/generators/atlas.py +0 -227
  300. package/runtime/python/okstra_vendor/networkx/generators/classic.py +0 -1091
  301. package/runtime/python/okstra_vendor/networkx/generators/cographs.py +0 -68
  302. package/runtime/python/okstra_vendor/networkx/generators/community.py +0 -1070
  303. package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +0 -886
  304. package/runtime/python/okstra_vendor/networkx/generators/directed.py +0 -572
  305. package/runtime/python/okstra_vendor/networkx/generators/duplication.py +0 -174
  306. package/runtime/python/okstra_vendor/networkx/generators/ego.py +0 -66
  307. package/runtime/python/okstra_vendor/networkx/generators/expanders.py +0 -499
  308. package/runtime/python/okstra_vendor/networkx/generators/geometric.py +0 -1037
  309. package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +0 -163
  310. package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +0 -443
  311. package/runtime/python/okstra_vendor/networkx/generators/intersection.py +0 -125
  312. package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +0 -70
  313. package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +0 -664
  314. package/runtime/python/okstra_vendor/networkx/generators/lattice.py +0 -405
  315. package/runtime/python/okstra_vendor/networkx/generators/line.py +0 -501
  316. package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +0 -110
  317. package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +0 -259
  318. package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +0 -117
  319. package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +0 -1416
  320. package/runtime/python/okstra_vendor/networkx/generators/small.py +0 -1070
  321. package/runtime/python/okstra_vendor/networkx/generators/social.py +0 -554
  322. package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +0 -120
  323. package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +0 -54
  324. package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +0 -131
  325. package/runtime/python/okstra_vendor/networkx/generators/time_series.py +0 -74
  326. package/runtime/python/okstra_vendor/networkx/generators/trees.py +0 -1070
  327. package/runtime/python/okstra_vendor/networkx/generators/triads.py +0 -94
  328. package/runtime/python/okstra_vendor/networkx/lazy_imports.py +0 -188
  329. package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +0 -13
  330. package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +0 -650
  331. package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +0 -466
  332. package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +0 -77
  333. package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +0 -168
  334. package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +0 -512
  335. package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +0 -166
  336. package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +0 -186
  337. package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +0 -17
  338. package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +0 -330
  339. package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +0 -489
  340. package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +0 -1084
  341. package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +0 -879
  342. package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +0 -427
  343. package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +0 -1053
  344. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +0 -19
  345. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +0 -156
  346. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +0 -190
  347. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +0 -261
  348. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +0 -137
  349. package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +0 -108
  350. package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +0 -393
  351. package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +0 -113
  352. package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +0 -286
  353. package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +0 -379
  354. package/runtime/python/okstra_vendor/networkx/readwrite/text.py +0 -851
  355. package/runtime/python/okstra_vendor/networkx/relabel.py +0 -285
  356. package/runtime/python/okstra_vendor/networkx/utils/__init__.py +0 -8
  357. package/runtime/python/okstra_vendor/networkx/utils/backends.py +0 -2171
  358. package/runtime/python/okstra_vendor/networkx/utils/configs.py +0 -396
  359. package/runtime/python/okstra_vendor/networkx/utils/decorators.py +0 -1233
  360. package/runtime/python/okstra_vendor/networkx/utils/heaps.py +0 -338
  361. package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +0 -297
  362. package/runtime/python/okstra_vendor/networkx/utils/misc.py +0 -703
  363. package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +0 -198
  364. package/runtime/python/okstra_vendor/networkx/utils/rcm.py +0 -159
  365. package/runtime/python/okstra_vendor/networkx/utils/union_find.py +0 -106
  366. package/runtime/skills/okstra-graphify/SKILL.md +0 -169
  367. package/src/commands/graphify.mjs +0 -32
@@ -1,220 +0,0 @@
1
- """
2
- Moody and White algorithm for k-components
3
- """
4
-
5
- from collections import defaultdict
6
- from itertools import combinations
7
- from operator import itemgetter
8
-
9
- import networkx as nx
10
-
11
- # Define the default maximum flow function.
12
- from networkx.algorithms.flow import edmonds_karp
13
- from networkx.utils import not_implemented_for
14
-
15
- default_flow_func = edmonds_karp
16
-
17
- __all__ = ["k_components"]
18
-
19
-
20
- @not_implemented_for("directed")
21
- @nx._dispatchable
22
- def k_components(G, flow_func=None):
23
- r"""Returns the k-component structure of a graph G.
24
-
25
- A `k`-component is a maximal subgraph of a graph G that has, at least,
26
- node connectivity `k`: we need to remove at least `k` nodes to break it
27
- into more components. `k`-components have an inherent hierarchical
28
- structure because they are nested in terms of connectivity: a connected
29
- graph can contain several 2-components, each of which can contain
30
- one or more 3-components, and so forth.
31
-
32
- Parameters
33
- ----------
34
- G : NetworkX graph
35
-
36
- flow_func : function
37
- Function to perform the underlying flow computations. Default value
38
- :meth:`edmonds_karp`. This function performs better in sparse graphs with
39
- right tailed degree distributions. :meth:`shortest_augmenting_path` will
40
- perform better in denser graphs.
41
-
42
- Returns
43
- -------
44
- k_components : dict
45
- Dictionary with all connectivity levels `k` in the input Graph as keys
46
- and a list of sets of nodes that form a k-component of level `k` as
47
- values.
48
-
49
- Raises
50
- ------
51
- NetworkXNotImplemented
52
- If the input graph is directed.
53
-
54
- Examples
55
- --------
56
- >>> # Petersen graph has 10 nodes and it is triconnected, thus all
57
- >>> # nodes are in a single component on all three connectivity levels
58
- >>> G = nx.petersen_graph()
59
- >>> k_components = nx.k_components(G)
60
-
61
- Notes
62
- -----
63
- Moody and White [1]_ (appendix A) provide an algorithm for identifying
64
- k-components in a graph, which is based on Kanevsky's algorithm [2]_
65
- for finding all minimum-size node cut-sets of a graph (implemented in
66
- :meth:`all_node_cuts` function):
67
-
68
- 1. Compute node connectivity, k, of the input graph G.
69
-
70
- 2. Identify all k-cutsets at the current level of connectivity using
71
- Kanevsky's algorithm.
72
-
73
- 3. Generate new graph components based on the removal of
74
- these cutsets. Nodes in a cutset belong to both sides
75
- of the induced cut.
76
-
77
- 4. If the graph is neither complete nor trivial, return to 1;
78
- else end.
79
-
80
- This implementation also uses some heuristics (see [3]_ for details)
81
- to speed up the computation.
82
-
83
- See also
84
- --------
85
- node_connectivity
86
- all_node_cuts
87
- biconnected_components : special case of this function when k=2
88
- k_edge_components : similar to this function, but uses edge-connectivity
89
- instead of node-connectivity
90
-
91
- References
92
- ----------
93
- .. [1] Moody, J. and D. White (2003). Social cohesion and embeddedness:
94
- A hierarchical conception of social groups.
95
- American Sociological Review 68(1), 103--28.
96
- http://www2.asanet.org/journals/ASRFeb03MoodyWhite.pdf
97
-
98
- .. [2] Kanevsky, A. (1993). Finding all minimum-size separating vertex
99
- sets in a graph. Networks 23(6), 533--541.
100
- http://onlinelibrary.wiley.com/doi/10.1002/net.3230230604/abstract
101
-
102
- .. [3] Torrents, J. and F. Ferraro (2015). Structural Cohesion:
103
- Visualization and Heuristics for Fast Computation.
104
- https://arxiv.org/pdf/1503.04476v1
105
-
106
- """
107
- # Dictionary with connectivity level (k) as keys and a list of
108
- # sets of nodes that form a k-component as values. Note that
109
- # k-components can overlap (but only k - 1 nodes).
110
- k_components = defaultdict(list)
111
- # Define default flow function
112
- if flow_func is None:
113
- flow_func = default_flow_func
114
- # Bicomponents as a base to check for higher order k-components
115
- for component in nx.connected_components(G):
116
- # isolated nodes have connectivity 0
117
- comp = set(component)
118
- if len(comp) > 1:
119
- k_components[1].append(comp)
120
- bicomponents = [G.subgraph(c) for c in nx.biconnected_components(G)]
121
- for bicomponent in bicomponents:
122
- bicomp = set(bicomponent)
123
- # avoid considering dyads as bicomponents
124
- if len(bicomp) > 2:
125
- k_components[2].append(bicomp)
126
- for B in bicomponents:
127
- if len(B) <= 2:
128
- continue
129
- k = nx.node_connectivity(B, flow_func=flow_func)
130
- if k > 2:
131
- k_components[k].append(set(B))
132
- # Perform cuts in a DFS like order.
133
- cuts = list(nx.all_node_cuts(B, k=k, flow_func=flow_func))
134
- stack = [(k, _generate_partition(B, cuts, k))]
135
- while stack:
136
- (parent_k, partition) = stack[-1]
137
- try:
138
- nodes = next(partition)
139
- C = B.subgraph(nodes)
140
- this_k = nx.node_connectivity(C, flow_func=flow_func)
141
- if this_k > parent_k and this_k > 2:
142
- k_components[this_k].append(set(C))
143
- cuts = list(nx.all_node_cuts(C, k=this_k, flow_func=flow_func))
144
- if cuts:
145
- stack.append((this_k, _generate_partition(C, cuts, this_k)))
146
- except StopIteration:
147
- stack.pop()
148
-
149
- # This is necessary because k-components may only be reported at their
150
- # maximum k level. But we want to return a dictionary in which keys are
151
- # connectivity levels and values list of sets of components, without
152
- # skipping any connectivity level. Also, it's possible that subsets of
153
- # an already detected k-component appear at a level k. Checking for this
154
- # in the while loop above penalizes the common case. Thus we also have to
155
- # _consolidate all connectivity levels in _reconstruct_k_components.
156
- return _reconstruct_k_components(k_components)
157
-
158
-
159
- def _consolidate(sets, k):
160
- """Merge sets that share k or more elements.
161
-
162
- See: http://rosettacode.org/wiki/Set_consolidation
163
-
164
- The iterative python implementation posted there is
165
- faster than this because of the overhead of building a
166
- Graph and calling nx.connected_components, but it's not
167
- clear for us if we can use it in NetworkX because there
168
- is no licence for the code.
169
-
170
- """
171
- G = nx.Graph()
172
- nodes = dict(enumerate(sets))
173
- G.add_nodes_from(nodes)
174
- G.add_edges_from(
175
- (u, v) for u, v in combinations(nodes, 2) if len(nodes[u] & nodes[v]) >= k
176
- )
177
- for component in nx.connected_components(G):
178
- yield set.union(*[nodes[n] for n in component])
179
-
180
-
181
- def _generate_partition(G, cuts, k):
182
- def has_nbrs_in_partition(G, node, partition):
183
- return any(n in partition for n in G[node])
184
-
185
- components = []
186
- n_in_cuts = {n for cut in cuts for n in cut}
187
- nodes = {n for n, d in G.degree() if d > k} - n_in_cuts
188
- H = G.subgraph(nodes)
189
- for cc in map(set, nx.connected_components(H)):
190
- component = cc | {n for n in n_in_cuts if has_nbrs_in_partition(G, n, cc)}
191
- if len(component) < G.order():
192
- components.append(component)
193
- yield from _consolidate(components, k + 1)
194
-
195
-
196
- def _reconstruct_k_components(k_comps):
197
- result = {}
198
- max_k = max(k_comps) if k_comps else 0
199
- for k in range(max_k, 0, -1):
200
- if k == max_k:
201
- result[k] = list(_consolidate(k_comps[k], k))
202
- elif k not in k_comps:
203
- result[k] = list(_consolidate(result[k + 1], k))
204
- else:
205
- nodes_at_k = set.union(*k_comps[k])
206
- to_add = [c for c in result[k + 1] if any(n not in nodes_at_k for n in c)]
207
- if to_add:
208
- result[k] = list(_consolidate(k_comps[k] + to_add, k))
209
- else:
210
- result[k] = list(_consolidate(k_comps[k], k))
211
- return result
212
-
213
-
214
- def build_k_number_dict(kcomps):
215
- return {
216
- node: k
217
- for k, comps in sorted(kcomps.items(), key=itemgetter(0))
218
- for comp in comps
219
- for node in comp
220
- }
@@ -1,235 +0,0 @@
1
- """
2
- Kanevsky all minimum node k cutsets algorithm.
3
- """
4
-
5
- import copy
6
- from collections import defaultdict
7
- from itertools import combinations
8
- from operator import itemgetter
9
-
10
- import networkx as nx
11
- from networkx.algorithms.flow import (
12
- build_residual_network,
13
- edmonds_karp,
14
- shortest_augmenting_path,
15
- )
16
-
17
- from .utils import build_auxiliary_node_connectivity
18
-
19
- default_flow_func = edmonds_karp
20
-
21
-
22
- __all__ = ["all_node_cuts"]
23
-
24
-
25
- @nx._dispatchable
26
- def all_node_cuts(G, k=None, flow_func=None):
27
- r"""Returns all minimum k cutsets of an undirected graph G.
28
-
29
- This implementation is based on Kanevsky's algorithm [1]_ for finding all
30
- minimum-size node cut-sets of an undirected graph G; ie the set (or sets)
31
- of nodes of cardinality equal to the node connectivity of G. Thus if
32
- removed, would break G into two or more connected components.
33
-
34
- Parameters
35
- ----------
36
- G : NetworkX graph
37
- Undirected graph
38
-
39
- k : Integer
40
- Node connectivity of the input graph. If k is None, then it is
41
- computed. Default value: None.
42
-
43
- flow_func : function
44
- Function to perform the underlying flow computations. Default value is
45
- :func:`~networkx.algorithms.flow.edmonds_karp`. This function performs
46
- better in sparse graphs with right tailed degree distributions.
47
- :func:`~networkx.algorithms.flow.shortest_augmenting_path` will
48
- perform better in denser graphs.
49
-
50
-
51
- Returns
52
- -------
53
- cuts : a generator of node cutsets
54
- Each node cutset has cardinality equal to the node connectivity of
55
- the input graph.
56
-
57
- Examples
58
- --------
59
- >>> # A two-dimensional grid graph has 4 cutsets of cardinality 2
60
- >>> G = nx.grid_2d_graph(5, 5)
61
- >>> cutsets = list(nx.all_node_cuts(G))
62
- >>> len(cutsets)
63
- 4
64
- >>> all(2 == len(cutset) for cutset in cutsets)
65
- True
66
- >>> nx.node_connectivity(G)
67
- 2
68
-
69
- Notes
70
- -----
71
- This implementation is based on the sequential algorithm for finding all
72
- minimum-size separating vertex sets in a graph [1]_. The main idea is to
73
- compute minimum cuts using local maximum flow computations among a set
74
- of nodes of highest degree and all other non-adjacent nodes in the Graph.
75
- Once we find a minimum cut, we add an edge between the high degree
76
- node and the target node of the local maximum flow computation to make
77
- sure that we will not find that minimum cut again.
78
-
79
- See also
80
- --------
81
- node_connectivity
82
- edmonds_karp
83
- shortest_augmenting_path
84
-
85
- References
86
- ----------
87
- .. [1] Kanevsky, A. (1993). Finding all minimum-size separating vertex
88
- sets in a graph. Networks 23(6), 533--541.
89
- http://onlinelibrary.wiley.com/doi/10.1002/net.3230230604/abstract
90
-
91
- """
92
- if not nx.is_connected(G):
93
- raise nx.NetworkXError("Input graph is disconnected.")
94
-
95
- # Address some corner cases first.
96
- # For complete Graphs
97
-
98
- if nx.density(G) == 1:
99
- yield from ()
100
- return
101
-
102
- # Initialize data structures.
103
- # Keep track of the cuts already computed so we do not repeat them.
104
- seen = []
105
- # Even-Tarjan reduction is what we call auxiliary digraph
106
- # for node connectivity.
107
- H = build_auxiliary_node_connectivity(G)
108
- H_nodes = H.nodes # for speed
109
- mapping = H.graph["mapping"]
110
- # Keep a copy of original predecessors, H will be modified later.
111
- # Shallow copy is enough.
112
- original_H_pred = copy.copy(H._pred)
113
- R = build_residual_network(H, "capacity")
114
- kwargs = {"capacity": "capacity", "residual": R}
115
- # Define default flow function
116
- if flow_func is None:
117
- flow_func = default_flow_func
118
- if flow_func is shortest_augmenting_path:
119
- kwargs["two_phase"] = True
120
- # Begin the actual algorithm
121
- # step 1: Find node connectivity k of G
122
- if k is None:
123
- k = nx.node_connectivity(G, flow_func=flow_func)
124
- # step 2:
125
- # Find k nodes with top degree, call it X:
126
- X = {n for n, d in sorted(G.degree(), key=itemgetter(1), reverse=True)[:k]}
127
- # Check if X is a k-node-cutset
128
- if _is_separating_set(G, X):
129
- seen.append(X)
130
- yield X
131
-
132
- for x in X:
133
- # step 3: Compute local connectivity flow of x with all other
134
- # non adjacent nodes in G
135
- non_adjacent = set(G) - {x} - set(G[x])
136
- for v in non_adjacent:
137
- # step 4: compute maximum flow in an Even-Tarjan reduction H of G
138
- # and step 5: build the associated residual network R
139
- R = flow_func(H, f"{mapping[x]}B", f"{mapping[v]}A", **kwargs)
140
- flow_value = R.graph["flow_value"]
141
-
142
- if flow_value == k:
143
- # Find the nodes incident to the flow.
144
- E1 = flowed_edges = [
145
- (u, w) for (u, w, d) in R.edges(data=True) if d["flow"] != 0
146
- ]
147
- VE1 = incident_nodes = {n for edge in E1 for n in edge}
148
- # Remove saturated edges form the residual network.
149
- # Note that reversed edges are introduced with capacity 0
150
- # in the residual graph and they need to be removed too.
151
- saturated_edges = [
152
- (u, w, d)
153
- for (u, w, d) in R.edges(data=True)
154
- if d["capacity"] == d["flow"] or d["capacity"] == 0
155
- ]
156
- R.remove_edges_from(saturated_edges)
157
- R_closure = nx.transitive_closure(R)
158
- # step 6: shrink the strongly connected components of
159
- # residual flow network R and call it L.
160
- L = nx.condensation(R)
161
- cmap = L.graph["mapping"]
162
- inv_cmap = defaultdict(list)
163
- for n, scc in cmap.items():
164
- inv_cmap[scc].append(n)
165
- # Find the incident nodes in the condensed graph.
166
- VE1 = {cmap[n] for n in VE1}
167
- # step 7: Compute all antichains of L;
168
- # they map to closed sets in H.
169
- # Any edge in H that links a closed set is part of a cutset.
170
- for antichain in nx.antichains(L):
171
- # Only antichains that are subsets of incident nodes counts.
172
- # Lemma 8 in reference.
173
- if not set(antichain).issubset(VE1):
174
- continue
175
- # Nodes in an antichain of the condensation graph of
176
- # the residual network map to a closed set of nodes that
177
- # define a node partition of the auxiliary digraph H
178
- # through taking all of antichain's predecessors in the
179
- # transitive closure.
180
- S = set()
181
- for scc in antichain:
182
- S.update(inv_cmap[scc])
183
- S_ancestors = set()
184
- for n in S:
185
- S_ancestors.update(R_closure._pred[n])
186
- S.update(S_ancestors)
187
- if f"{mapping[x]}B" not in S or f"{mapping[v]}A" in S:
188
- continue
189
- # Find the cutset that links the node partition (S,~S) in H
190
- cutset = set()
191
- for u in S:
192
- cutset.update((u, w) for w in original_H_pred[u] if w not in S)
193
- # The edges in H that form the cutset are internal edges
194
- # (ie edges that represent a node of the original graph G)
195
- if any(H_nodes[u]["id"] != H_nodes[w]["id"] for u, w in cutset):
196
- continue
197
- node_cut = {H_nodes[u]["id"] for u, _ in cutset}
198
-
199
- if len(node_cut) == k:
200
- # The cut is invalid if it includes internal edges of
201
- # end nodes. The other half of Lemma 8 in ref.
202
- if x in node_cut or v in node_cut:
203
- continue
204
- if node_cut not in seen:
205
- yield node_cut
206
- seen.append(node_cut)
207
-
208
- # Add an edge (x, v) to make sure that we do not
209
- # find this cutset again. This is equivalent
210
- # of adding the edge in the input graph
211
- # G.add_edge(x, v) and then regenerate H and R:
212
- # Add edges to the auxiliary digraph.
213
- # See build_residual_network for convention we used
214
- # in residual graphs.
215
- H.add_edge(f"{mapping[x]}B", f"{mapping[v]}A", capacity=1)
216
- H.add_edge(f"{mapping[v]}B", f"{mapping[x]}A", capacity=1)
217
- # Add edges to the residual network.
218
- R.add_edge(f"{mapping[x]}B", f"{mapping[v]}A", capacity=1)
219
- R.add_edge(f"{mapping[v]}A", f"{mapping[x]}B", capacity=0)
220
- R.add_edge(f"{mapping[v]}B", f"{mapping[x]}A", capacity=1)
221
- R.add_edge(f"{mapping[x]}A", f"{mapping[v]}B", capacity=0)
222
-
223
- # Add again the saturated edges to reuse the residual network
224
- R.add_edges_from(saturated_edges)
225
-
226
-
227
- def _is_separating_set(G, cut):
228
- """Assumes that the input graph is connected"""
229
- if len(cut) == len(G) - 1:
230
- return True
231
-
232
- H = nx.restricted_view(G, cut, [])
233
- if nx.is_connected(H):
234
- return False
235
- return True
@@ -1,152 +0,0 @@
1
- """
2
- Stoer-Wagner minimum cut algorithm.
3
- """
4
-
5
- from itertools import islice
6
-
7
- import networkx as nx
8
-
9
- from ...utils import BinaryHeap, arbitrary_element, not_implemented_for
10
-
11
- __all__ = ["stoer_wagner"]
12
-
13
-
14
- @not_implemented_for("directed")
15
- @not_implemented_for("multigraph")
16
- @nx._dispatchable(edge_attrs="weight")
17
- def stoer_wagner(G, weight="weight", heap=BinaryHeap):
18
- r"""Returns the weighted minimum edge cut using the Stoer-Wagner algorithm.
19
-
20
- Determine the minimum edge cut of a connected graph using the
21
- Stoer-Wagner algorithm. In weighted cases, all weights must be
22
- nonnegative.
23
-
24
- The running time of the algorithm depends on the type of heaps used:
25
-
26
- ============== =============================================
27
- Type of heap Running time
28
- ============== =============================================
29
- Binary heap $O(n (m + n) \log n)$
30
- Fibonacci heap $O(nm + n^2 \log n)$
31
- Pairing heap $O(2^{2 \sqrt{\log \log n}} nm + n^2 \log n)$
32
- ============== =============================================
33
-
34
- Parameters
35
- ----------
36
- G : NetworkX graph
37
- Edges of the graph are expected to have an attribute named by the
38
- weight parameter below. If this attribute is not present, the edge is
39
- considered to have unit weight.
40
-
41
- weight : string
42
- Name of the weight attribute of the edges. If the attribute is not
43
- present, unit weight is assumed. Default value: 'weight'.
44
-
45
- heap : class
46
- Type of heap to be used in the algorithm. It should be a subclass of
47
- :class:`MinHeap` or implement a compatible interface.
48
-
49
- If a stock heap implementation is to be used, :class:`BinaryHeap` is
50
- recommended over :class:`PairingHeap` for Python implementations without
51
- optimized attribute accesses (e.g., CPython) despite a slower
52
- asymptotic running time. For Python implementations with optimized
53
- attribute accesses (e.g., PyPy), :class:`PairingHeap` provides better
54
- performance. Default value: :class:`BinaryHeap`.
55
-
56
- Returns
57
- -------
58
- cut_value : integer or float
59
- The sum of weights of edges in a minimum cut.
60
-
61
- partition : pair of node lists
62
- A partitioning of the nodes that defines a minimum cut.
63
-
64
- Raises
65
- ------
66
- NetworkXNotImplemented
67
- If the graph is directed or a multigraph.
68
-
69
- NetworkXError
70
- If the graph has less than two nodes, is not connected or has a
71
- negative-weighted edge.
72
-
73
- Examples
74
- --------
75
- >>> G = nx.Graph()
76
- >>> G.add_edge("x", "a", weight=3)
77
- >>> G.add_edge("x", "b", weight=1)
78
- >>> G.add_edge("a", "c", weight=3)
79
- >>> G.add_edge("b", "c", weight=5)
80
- >>> G.add_edge("b", "d", weight=4)
81
- >>> G.add_edge("d", "e", weight=2)
82
- >>> G.add_edge("c", "y", weight=2)
83
- >>> G.add_edge("e", "y", weight=3)
84
- >>> cut_value, partition = nx.stoer_wagner(G)
85
- >>> cut_value
86
- 4
87
- """
88
- n = len(G)
89
- if n < 2:
90
- raise nx.NetworkXError("graph has less than two nodes.")
91
- if not nx.is_connected(G):
92
- raise nx.NetworkXError("graph is not connected.")
93
-
94
- # Make a copy of the graph for internal use.
95
- G = nx.Graph(
96
- (u, v, {"weight": e.get(weight, 1)}) for u, v, e in G.edges(data=True) if u != v
97
- )
98
- G.__networkx_cache__ = None # Disable caching
99
-
100
- for u, v, e in G.edges(data=True):
101
- if e["weight"] < 0:
102
- raise nx.NetworkXError("graph has a negative-weighted edge.")
103
-
104
- cut_value = float("inf")
105
- nodes = set(G)
106
- contractions = [] # contracted node pairs
107
-
108
- # Repeatedly pick a pair of nodes to contract until only one node is left.
109
- for i in range(n - 1):
110
- # Pick an arbitrary node u and create a set A = {u}.
111
- u = arbitrary_element(G)
112
- A = {u}
113
- # Repeatedly pick the node "most tightly connected" to A and add it to
114
- # A. The tightness of connectivity of a node not in A is defined by the
115
- # of edges connecting it to nodes in A.
116
- h = heap() # min-heap emulating a max-heap
117
- for v, e in G[u].items():
118
- h.insert(v, -e["weight"])
119
- # Repeat until all but one node has been added to A.
120
- for j in range(n - i - 2):
121
- u = h.pop()[0]
122
- A.add(u)
123
- for v, e in G[u].items():
124
- if v not in A:
125
- h.insert(v, h.get(v, 0) - e["weight"])
126
- # A and the remaining node v define a "cut of the phase". There is a
127
- # minimum cut of the original graph that is also a cut of the phase.
128
- # Due to contractions in earlier phases, v may in fact represent
129
- # multiple nodes in the original graph.
130
- v, w = h.min()
131
- w = -w
132
- if w < cut_value:
133
- cut_value = w
134
- best_phase = i
135
- # Contract v and the last node added to A.
136
- contractions.append((u, v))
137
- for w, e in G[v].items():
138
- if w != u:
139
- if w not in G[u]:
140
- G.add_edge(u, w, weight=e["weight"])
141
- else:
142
- G[u][w]["weight"] += e["weight"]
143
- G.remove_node(v)
144
-
145
- # Recover the optimal partitioning from the contractions.
146
- G = nx.Graph(islice(contractions, best_phase))
147
- v = contractions[best_phase][1]
148
- G.add_node(v)
149
- reachable = set(nx.single_source_shortest_path_length(G, v))
150
- partition = (list(reachable), list(nodes - reachable))
151
-
152
- return cut_value, partition
@@ -1,88 +0,0 @@
1
- """
2
- Utilities for connectivity package
3
- """
4
-
5
- import networkx as nx
6
-
7
- __all__ = ["build_auxiliary_node_connectivity", "build_auxiliary_edge_connectivity"]
8
-
9
-
10
- @nx._dispatchable(returns_graph=True)
11
- def build_auxiliary_node_connectivity(G):
12
- r"""Creates a directed graph D from an undirected graph G to compute flow
13
- based node connectivity.
14
-
15
- For an undirected graph G having `n` nodes and `m` edges we derive a
16
- directed graph D with `2n` nodes and `2m+n` arcs by replacing each
17
- original node `v` with two nodes `vA`, `vB` linked by an (internal)
18
- arc in D. Then for each edge (`u`, `v`) in G we add two arcs (`uB`, `vA`)
19
- and (`vB`, `uA`) in D. Finally we set the attribute capacity = 1 for each
20
- arc in D [1]_.
21
-
22
- For a directed graph having `n` nodes and `m` arcs we derive a
23
- directed graph D with `2n` nodes and `m+n` arcs by replacing each
24
- original node `v` with two nodes `vA`, `vB` linked by an (internal)
25
- arc (`vA`, `vB`) in D. Then for each arc (`u`, `v`) in G we add one
26
- arc (`uB`, `vA`) in D. Finally we set the attribute capacity = 1 for
27
- each arc in D.
28
-
29
- A dictionary with a mapping between nodes in the original graph and the
30
- auxiliary digraph is stored as a graph attribute: D.graph['mapping'].
31
-
32
- References
33
- ----------
34
- .. [1] Kammer, Frank and Hanjo Taubig. Graph Connectivity. in Brandes and
35
- Erlebach, 'Network Analysis: Methodological Foundations', Lecture
36
- Notes in Computer Science, Volume 3418, Springer-Verlag, 2005.
37
- https://doi.org/10.1007/978-3-540-31955-9_7
38
-
39
- """
40
- directed = G.is_directed()
41
-
42
- mapping = {}
43
- H = nx.DiGraph()
44
-
45
- for i, node in enumerate(G):
46
- mapping[node] = i
47
- H.add_node(f"{i}A", id=node)
48
- H.add_node(f"{i}B", id=node)
49
- H.add_edge(f"{i}A", f"{i}B", capacity=1)
50
-
51
- edges = []
52
- for source, target in G.edges():
53
- edges.append((f"{mapping[source]}B", f"{mapping[target]}A"))
54
- if not directed:
55
- edges.append((f"{mapping[target]}B", f"{mapping[source]}A"))
56
- H.add_edges_from(edges, capacity=1)
57
-
58
- # Store mapping as graph attribute
59
- H.graph["mapping"] = mapping
60
- return H
61
-
62
-
63
- @nx._dispatchable(returns_graph=True)
64
- def build_auxiliary_edge_connectivity(G):
65
- """Auxiliary digraph for computing flow based edge connectivity
66
-
67
- If the input graph is undirected, we replace each edge (`u`,`v`) with
68
- two reciprocal arcs (`u`, `v`) and (`v`, `u`) and then we set the attribute
69
- 'capacity' for each arc to 1. If the input graph is directed we simply
70
- add the 'capacity' attribute. Part of algorithm 1 in [1]_ .
71
-
72
- References
73
- ----------
74
- .. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms. (this is a
75
- chapter, look for the reference of the book).
76
- http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf
77
- """
78
- if G.is_directed():
79
- H = nx.DiGraph()
80
- H.add_nodes_from(G.nodes())
81
- H.add_edges_from(G.edges(), capacity=1)
82
- return H
83
- else:
84
- H = nx.DiGraph()
85
- H.add_nodes_from(G.nodes())
86
- for source, target in G.edges():
87
- H.add_edges_from([(source, target), (target, source)], capacity=1)
88
- return H