okstra 0.130.4 → 0.131.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/README.md +0 -1
  2. package/docs/architecture.md +2 -2
  3. package/docs/cli.md +1 -1
  4. package/docs/for-ai/README.md +0 -2
  5. package/docs/for-ai/skills/okstra-run.md +13 -2
  6. package/docs/for-ai/skills/okstra-setup.md +4 -1
  7. package/docs/project-structure-overview.md +5 -4
  8. package/docs/task-process/implementation-planning.md +13 -0
  9. package/docs/task-process/implementation.md +17 -2
  10. package/package.json +1 -1
  11. package/runtime/BUILD.json +2 -2
  12. package/runtime/agents/workers/report-writer-worker.md +7 -0
  13. package/runtime/bin/lib/okstra/usage.sh +4 -4
  14. package/runtime/prompts/lead/okstra-lead-contract.md +2 -2
  15. package/runtime/prompts/lead/plan-body-verification.md +26 -5
  16. package/runtime/prompts/lead/report-writer.md +6 -2
  17. package/runtime/prompts/profiles/_common-contract.md +2 -1
  18. package/runtime/prompts/profiles/_implementation-deliverable.md +6 -1
  19. package/runtime/prompts/profiles/_implementation-executor.md +2 -2
  20. package/runtime/prompts/profiles/_implementation-verifier.md +33 -10
  21. package/runtime/prompts/profiles/final-verification.md +21 -6
  22. package/runtime/prompts/profiles/implementation-planning.md +16 -4
  23. package/runtime/python/okstra_ctl/codex_dispatch.py +31 -0
  24. package/runtime/python/okstra_ctl/conformance.py +49 -11
  25. package/runtime/python/okstra_ctl/report_finalize.py +52 -1
  26. package/runtime/python/okstra_ctl/run.py +15 -3
  27. package/runtime/python/okstra_ctl/worker_prompt_contract.py +14 -6
  28. package/runtime/python/okstra_ctl/worker_prompt_policy.py +19 -1
  29. package/runtime/python/okstra_vendor/__init__.py +0 -44
  30. package/runtime/schemas/final-report-v1.0.schema.json +99 -5
  31. package/runtime/skills/okstra-run/SKILL.md +11 -4
  32. package/runtime/skills/okstra-setup/SKILL.md +3 -2
  33. package/runtime/skills/okstra-setup/references/project-config.md +16 -7
  34. package/runtime/templates/reports/final-report.template.md +15 -9
  35. package/runtime/templates/reports/i18n/en.json +1 -0
  36. package/runtime/templates/reports/i18n/ko.json +1 -0
  37. package/runtime/validators/lib/fixtures.sh +6 -0
  38. package/runtime/validators/validate-run.py +2019 -96
  39. package/src/cli-registry.mjs +0 -7
  40. package/src/commands/lifecycle/doctor.mjs +0 -9
  41. package/src/lib/skill-catalog.mjs +0 -1
  42. package/docs/for-ai/skills/okstra-graphify.md +0 -64
  43. package/runtime/python/okstra_ctl/graphify_cmd.py +0 -225
  44. package/runtime/python/okstra_vendor/graphify/.vendored-version +0 -1
  45. package/runtime/python/okstra_vendor/graphify/__init__.py +0 -28
  46. package/runtime/python/okstra_vendor/graphify/__main__.py +0 -1371
  47. package/runtime/python/okstra_vendor/graphify/analyze.py +0 -540
  48. package/runtime/python/okstra_vendor/graphify/benchmark.py +0 -129
  49. package/runtime/python/okstra_vendor/graphify/build.py +0 -107
  50. package/runtime/python/okstra_vendor/graphify/cache.py +0 -169
  51. package/runtime/python/okstra_vendor/graphify/cluster.py +0 -137
  52. package/runtime/python/okstra_vendor/graphify/detect.py +0 -510
  53. package/runtime/python/okstra_vendor/graphify/export.py +0 -1014
  54. package/runtime/python/okstra_vendor/graphify/extract.py +0 -3277
  55. package/runtime/python/okstra_vendor/graphify/hooks.py +0 -220
  56. package/runtime/python/okstra_vendor/graphify/ingest.py +0 -297
  57. package/runtime/python/okstra_vendor/graphify/manifest.py +0 -4
  58. package/runtime/python/okstra_vendor/graphify/report.py +0 -175
  59. package/runtime/python/okstra_vendor/graphify/security.py +0 -203
  60. package/runtime/python/okstra_vendor/graphify/serve.py +0 -373
  61. package/runtime/python/okstra_vendor/graphify/skill-aider.md +0 -1184
  62. package/runtime/python/okstra_vendor/graphify/skill-claw.md +0 -1184
  63. package/runtime/python/okstra_vendor/graphify/skill-codex.md +0 -1242
  64. package/runtime/python/okstra_vendor/graphify/skill-copilot.md +0 -1268
  65. package/runtime/python/okstra_vendor/graphify/skill-droid.md +0 -1239
  66. package/runtime/python/okstra_vendor/graphify/skill-kiro.md +0 -1183
  67. package/runtime/python/okstra_vendor/graphify/skill-opencode.md +0 -1238
  68. package/runtime/python/okstra_vendor/graphify/skill-trae.md +0 -1208
  69. package/runtime/python/okstra_vendor/graphify/skill-vscode.md +0 -253
  70. package/runtime/python/okstra_vendor/graphify/skill-windows.md +0 -1245
  71. package/runtime/python/okstra_vendor/graphify/skill.md +0 -1319
  72. package/runtime/python/okstra_vendor/graphify/transcribe.py +0 -182
  73. package/runtime/python/okstra_vendor/graphify/validate.py +0 -72
  74. package/runtime/python/okstra_vendor/graphify/watch.py +0 -188
  75. package/runtime/python/okstra_vendor/graphify/wiki.py +0 -214
  76. package/runtime/python/okstra_vendor/networkx/__init__.py +0 -62
  77. package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +0 -134
  78. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +0 -26
  79. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +0 -259
  80. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +0 -71
  81. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +0 -412
  82. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +0 -396
  83. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +0 -150
  84. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +0 -149
  85. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +0 -369
  86. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +0 -44
  87. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +0 -143
  88. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +0 -53
  89. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +0 -265
  90. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +0 -1508
  91. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +0 -255
  92. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +0 -83
  93. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +0 -5
  94. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +0 -122
  95. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +0 -302
  96. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +0 -255
  97. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +0 -160
  98. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +0 -127
  99. package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +0 -164
  100. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +0 -88
  101. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +0 -322
  102. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +0 -290
  103. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +0 -289
  104. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +0 -57
  105. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +0 -360
  106. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +0 -105
  107. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +0 -603
  108. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +0 -316
  109. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +0 -590
  110. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +0 -232
  111. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +0 -526
  112. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +0 -112
  113. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +0 -69
  114. package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +0 -168
  115. package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +0 -205
  116. package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +0 -164
  117. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +0 -20
  118. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +0 -591
  119. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +0 -236
  120. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +0 -282
  121. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +0 -364
  122. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +0 -227
  123. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +0 -96
  124. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +0 -150
  125. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +0 -107
  126. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +0 -357
  127. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +0 -130
  128. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +0 -787
  129. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +0 -88
  130. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +0 -331
  131. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +0 -150
  132. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +0 -200
  133. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +0 -128
  134. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +0 -209
  135. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +0 -141
  136. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +0 -361
  137. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +0 -181
  138. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +0 -95
  139. package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +0 -172
  140. package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +0 -443
  141. package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +0 -818
  142. package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +0 -732
  143. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +0 -4
  144. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +0 -505
  145. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +0 -565
  146. package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +0 -163
  147. package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +0 -28
  148. package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +0 -153
  149. package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +0 -354
  150. package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +0 -171
  151. package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +0 -30
  152. package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +0 -216
  153. package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +0 -79
  154. package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +0 -338
  155. package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +0 -162
  156. package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +0 -220
  157. package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +0 -384
  158. package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +0 -227
  159. package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +0 -452
  160. package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +0 -347
  161. package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +0 -6
  162. package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +0 -115
  163. package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +0 -394
  164. package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +0 -282
  165. package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +0 -71
  166. package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +0 -359
  167. package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +0 -196
  168. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +0 -11
  169. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +0 -811
  170. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +0 -616
  171. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +0 -408
  172. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +0 -1270
  173. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +0 -592
  174. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +0 -220
  175. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +0 -235
  176. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +0 -152
  177. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +0 -88
  178. package/runtime/python/okstra_vendor/networkx/algorithms/core.py +0 -588
  179. package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +0 -142
  180. package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +0 -416
  181. package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +0 -1234
  182. package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +0 -677
  183. package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +0 -1392
  184. package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +0 -1095
  185. package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +0 -272
  186. package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +0 -142
  187. package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +0 -268
  188. package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +0 -167
  189. package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +0 -470
  190. package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +0 -11
  191. package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +0 -370
  192. package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +0 -407
  193. package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +0 -238
  194. package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +0 -241
  195. package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +0 -178
  196. package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +0 -611
  197. package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +0 -356
  198. package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +0 -662
  199. package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +0 -425
  200. package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +0 -300
  201. package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +0 -194
  202. package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +0 -435
  203. package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +0 -483
  204. package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +0 -57
  205. package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +0 -196
  206. package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +0 -107
  207. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +0 -7
  208. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +0 -1306
  209. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +0 -336
  210. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +0 -1262
  211. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +0 -352
  212. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +0 -308
  213. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +0 -264
  214. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +0 -1102
  215. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +0 -192
  216. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +0 -2
  217. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +0 -337
  218. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +0 -498
  219. package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +0 -687
  220. package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +0 -280
  221. package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +0 -1148
  222. package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +0 -27
  223. package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +0 -738
  224. package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +0 -78
  225. package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +0 -59
  226. package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +0 -219
  227. package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +0 -155
  228. package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +0 -4
  229. package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +0 -324
  230. package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +0 -468
  231. package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +0 -633
  232. package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +0 -77
  233. package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +0 -73
  234. package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +0 -464
  235. package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +0 -1463
  236. package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +0 -306
  237. package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +0 -98
  238. package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +0 -167
  239. package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +0 -138
  240. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +0 -5
  241. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +0 -239
  242. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +0 -264
  243. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +0 -716
  244. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +0 -625
  245. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +0 -2542
  246. package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +0 -2107
  247. package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +0 -966
  248. package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +0 -404
  249. package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +0 -30
  250. package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +0 -296
  251. package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +0 -374
  252. package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +0 -564
  253. package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +0 -406
  254. package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +0 -981
  255. package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +0 -142
  256. package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +0 -406
  257. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +0 -5
  258. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +0 -90
  259. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +0 -576
  260. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +0 -529
  261. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +0 -185
  262. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +0 -182
  263. package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +0 -7
  264. package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +0 -1042
  265. package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +0 -413
  266. package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +0 -88
  267. package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +0 -219
  268. package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +0 -1281
  269. package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +0 -106
  270. package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +0 -273
  271. package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +0 -500
  272. package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +0 -76
  273. package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +0 -86
  274. package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +0 -77
  275. package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +0 -278
  276. package/runtime/python/okstra_vendor/networkx/classes/__init__.py +0 -13
  277. package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +0 -435
  278. package/runtime/python/okstra_vendor/networkx/classes/digraph.py +0 -1363
  279. package/runtime/python/okstra_vendor/networkx/classes/filters.py +0 -95
  280. package/runtime/python/okstra_vendor/networkx/classes/function.py +0 -1549
  281. package/runtime/python/okstra_vendor/networkx/classes/graph.py +0 -2082
  282. package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +0 -269
  283. package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +0 -977
  284. package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +0 -1294
  285. package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +0 -1447
  286. package/runtime/python/okstra_vendor/networkx/convert.py +0 -502
  287. package/runtime/python/okstra_vendor/networkx/convert_matrix.py +0 -1314
  288. package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +0 -7
  289. package/runtime/python/okstra_vendor/networkx/drawing/layout.py +0 -2036
  290. package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +0 -470
  291. package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +0 -570
  292. package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +0 -361
  293. package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +0 -2978
  294. package/runtime/python/okstra_vendor/networkx/exception.py +0 -131
  295. package/runtime/python/okstra_vendor/networkx/generators/__init__.py +0 -34
  296. package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
  297. package/runtime/python/okstra_vendor/networkx/generators/atlas.py +0 -227
  298. package/runtime/python/okstra_vendor/networkx/generators/classic.py +0 -1091
  299. package/runtime/python/okstra_vendor/networkx/generators/cographs.py +0 -68
  300. package/runtime/python/okstra_vendor/networkx/generators/community.py +0 -1070
  301. package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +0 -886
  302. package/runtime/python/okstra_vendor/networkx/generators/directed.py +0 -572
  303. package/runtime/python/okstra_vendor/networkx/generators/duplication.py +0 -174
  304. package/runtime/python/okstra_vendor/networkx/generators/ego.py +0 -66
  305. package/runtime/python/okstra_vendor/networkx/generators/expanders.py +0 -499
  306. package/runtime/python/okstra_vendor/networkx/generators/geometric.py +0 -1037
  307. package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +0 -163
  308. package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +0 -443
  309. package/runtime/python/okstra_vendor/networkx/generators/intersection.py +0 -125
  310. package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +0 -70
  311. package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +0 -664
  312. package/runtime/python/okstra_vendor/networkx/generators/lattice.py +0 -405
  313. package/runtime/python/okstra_vendor/networkx/generators/line.py +0 -501
  314. package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +0 -110
  315. package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +0 -259
  316. package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +0 -117
  317. package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +0 -1416
  318. package/runtime/python/okstra_vendor/networkx/generators/small.py +0 -1070
  319. package/runtime/python/okstra_vendor/networkx/generators/social.py +0 -554
  320. package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +0 -120
  321. package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +0 -54
  322. package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +0 -131
  323. package/runtime/python/okstra_vendor/networkx/generators/time_series.py +0 -74
  324. package/runtime/python/okstra_vendor/networkx/generators/trees.py +0 -1070
  325. package/runtime/python/okstra_vendor/networkx/generators/triads.py +0 -94
  326. package/runtime/python/okstra_vendor/networkx/lazy_imports.py +0 -188
  327. package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +0 -13
  328. package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +0 -650
  329. package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +0 -466
  330. package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +0 -77
  331. package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +0 -168
  332. package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +0 -512
  333. package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +0 -166
  334. package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +0 -186
  335. package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +0 -17
  336. package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +0 -330
  337. package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +0 -489
  338. package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +0 -1084
  339. package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +0 -879
  340. package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +0 -427
  341. package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +0 -1053
  342. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +0 -19
  343. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +0 -156
  344. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +0 -190
  345. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +0 -261
  346. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +0 -137
  347. package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +0 -108
  348. package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +0 -393
  349. package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +0 -113
  350. package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +0 -286
  351. package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +0 -379
  352. package/runtime/python/okstra_vendor/networkx/readwrite/text.py +0 -851
  353. package/runtime/python/okstra_vendor/networkx/relabel.py +0 -285
  354. package/runtime/python/okstra_vendor/networkx/utils/__init__.py +0 -8
  355. package/runtime/python/okstra_vendor/networkx/utils/backends.py +0 -2171
  356. package/runtime/python/okstra_vendor/networkx/utils/configs.py +0 -396
  357. package/runtime/python/okstra_vendor/networkx/utils/decorators.py +0 -1233
  358. package/runtime/python/okstra_vendor/networkx/utils/heaps.py +0 -338
  359. package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +0 -297
  360. package/runtime/python/okstra_vendor/networkx/utils/misc.py +0 -703
  361. package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +0 -198
  362. package/runtime/python/okstra_vendor/networkx/utils/rcm.py +0 -159
  363. package/runtime/python/okstra_vendor/networkx/utils/union_find.py +0 -106
  364. package/runtime/skills/okstra-graphify/SKILL.md +0 -169
  365. package/src/commands/graphify.mjs +0 -32
@@ -1,716 +0,0 @@
1
- """
2
- Compute the shortest paths and path lengths between nodes in the graph.
3
-
4
- These algorithms work with undirected and directed graphs.
5
-
6
- """
7
-
8
- import networkx as nx
9
-
10
- __all__ = [
11
- "shortest_path",
12
- "all_shortest_paths",
13
- "single_source_all_shortest_paths",
14
- "all_pairs_all_shortest_paths",
15
- "shortest_path_length",
16
- "average_shortest_path_length",
17
- "has_path",
18
- ]
19
-
20
-
21
- @nx._dispatchable
22
- def has_path(G, source, target):
23
- """Returns *True* if *G* has a path from *source* to *target*.
24
-
25
- Parameters
26
- ----------
27
- G : NetworkX graph
28
-
29
- source : node
30
- Starting node for path
31
-
32
- target : node
33
- Ending node for path
34
- """
35
- try:
36
- nx.shortest_path(G, source, target)
37
- except nx.NetworkXNoPath:
38
- return False
39
- return True
40
-
41
-
42
- @nx._dispatchable(edge_attrs="weight")
43
- def shortest_path(G, source=None, target=None, weight=None, method="dijkstra"):
44
- """Compute shortest paths in the graph.
45
-
46
- Parameters
47
- ----------
48
- G : NetworkX graph
49
-
50
- source : node, optional
51
- Starting node for path. If not specified, compute shortest
52
- paths for each possible starting node.
53
-
54
- target : node, optional
55
- Ending node for path. If not specified, compute shortest
56
- paths to all possible nodes.
57
-
58
- weight : None, string or function, optional (default = None)
59
- If None, every edge has weight/distance/cost 1.
60
- If a string, use this edge attribute as the edge weight.
61
- Any edge attribute not present defaults to 1.
62
- If this is a function, the weight of an edge is the value
63
- returned by the function. The function must accept exactly
64
- three positional arguments: the two endpoints of an edge and
65
- the dictionary of edge attributes for that edge.
66
- The function must return a number.
67
-
68
- method : string, optional (default = 'dijkstra')
69
- The algorithm to use to compute the path.
70
- Supported options: 'dijkstra', 'bellman-ford'.
71
- Other inputs produce a ValueError.
72
- If `weight` is None, unweighted graph methods are used, and this
73
- suggestion is ignored.
74
-
75
- Returns
76
- -------
77
- path: list or dictionary or iterator
78
- All returned paths include both the source and target in the path.
79
-
80
- If the source and target are both specified, return a single list
81
- of nodes in a shortest path from the source to the target.
82
-
83
- If only the source is specified, return a dictionary keyed by
84
- targets with a list of nodes in a shortest path from the source
85
- to one of the targets.
86
-
87
- If only the target is specified, return a dictionary keyed by
88
- sources with a list of nodes in a shortest path from one of the
89
- sources to the target.
90
-
91
- If neither the source nor target are specified, return an iterator
92
- over (source, dictionary) where dictionary is keyed by target to
93
- list of nodes in a shortest path from the source to the target.
94
-
95
- Raises
96
- ------
97
- NodeNotFound
98
- If `source` is not in `G`.
99
-
100
- ValueError
101
- If `method` is not among the supported options.
102
-
103
- NetworkXNoPath
104
- If `source` and `target` are specified but no path exists between them.
105
-
106
- Examples
107
- --------
108
- >>> G = nx.path_graph(5)
109
- >>> print(nx.shortest_path(G, source=0, target=4))
110
- [0, 1, 2, 3, 4]
111
- >>> p = nx.shortest_path(G, source=0) # target not specified
112
- >>> p[3] # shortest path from source=0 to target=3
113
- [0, 1, 2, 3]
114
- >>> p = nx.shortest_path(G, target=4) # source not specified
115
- >>> p[1] # shortest path from source=1 to target=4
116
- [1, 2, 3, 4]
117
- >>> p = dict(nx.shortest_path(G)) # source, target not specified
118
- >>> p[2][4] # shortest path from source=2 to target=4
119
- [2, 3, 4]
120
-
121
- Notes
122
- -----
123
- There may be more than one shortest path between a source and target.
124
- This returns only one of them.
125
-
126
- See Also
127
- --------
128
- all_pairs_shortest_path
129
- all_pairs_dijkstra_path
130
- all_pairs_bellman_ford_path
131
- single_source_shortest_path
132
- single_source_dijkstra_path
133
- single_source_bellman_ford_path
134
- """
135
- if method not in ("dijkstra", "bellman-ford"):
136
- # so we don't need to check in each branch later
137
- raise ValueError(f"method not supported: {method}")
138
- method = "unweighted" if weight is None else method
139
- if source is None:
140
- if target is None:
141
- # Find paths between all pairs. Iterator of dicts.
142
- if method == "unweighted":
143
- paths = nx.all_pairs_shortest_path(G)
144
- elif method == "dijkstra":
145
- paths = nx.all_pairs_dijkstra_path(G, weight=weight)
146
- else: # method == 'bellman-ford':
147
- paths = nx.all_pairs_bellman_ford_path(G, weight=weight)
148
- else:
149
- # Find paths from all nodes co-accessible to the target.
150
- if G.is_directed():
151
- G = G.reverse(copy=False)
152
- if method == "unweighted":
153
- paths = nx.single_source_shortest_path(G, target)
154
- elif method == "dijkstra":
155
- paths = nx.single_source_dijkstra_path(G, target, weight=weight)
156
- else: # method == 'bellman-ford':
157
- paths = nx.single_source_bellman_ford_path(G, target, weight=weight)
158
- # Now flip the paths so they go from a source to the target.
159
- for target in paths:
160
- paths[target] = list(reversed(paths[target]))
161
- else:
162
- if target is None:
163
- # Find paths to all nodes accessible from the source.
164
- if method == "unweighted":
165
- paths = nx.single_source_shortest_path(G, source)
166
- elif method == "dijkstra":
167
- paths = nx.single_source_dijkstra_path(G, source, weight=weight)
168
- else: # method == 'bellman-ford':
169
- paths = nx.single_source_bellman_ford_path(G, source, weight=weight)
170
- else:
171
- # Find shortest source-target path.
172
- if method == "unweighted":
173
- paths = nx.bidirectional_shortest_path(G, source, target)
174
- elif method == "dijkstra":
175
- _, paths = nx.bidirectional_dijkstra(G, source, target, weight)
176
- else: # method == 'bellman-ford':
177
- paths = nx.bellman_ford_path(G, source, target, weight)
178
- return paths
179
-
180
-
181
- @nx._dispatchable(edge_attrs="weight")
182
- def shortest_path_length(G, source=None, target=None, weight=None, method="dijkstra"):
183
- """Compute shortest path lengths in the graph.
184
-
185
- Parameters
186
- ----------
187
- G : NetworkX graph
188
-
189
- source : node, optional
190
- Starting node for path.
191
- If not specified, compute shortest path lengths using all nodes as
192
- source nodes.
193
-
194
- target : node, optional
195
- Ending node for path.
196
- If not specified, compute shortest path lengths using all nodes as
197
- target nodes.
198
-
199
- weight : None, string or function, optional (default = None)
200
- If None, every edge has weight/distance/cost 1.
201
- If a string, use this edge attribute as the edge weight.
202
- Any edge attribute not present defaults to 1.
203
- If this is a function, the weight of an edge is the value
204
- returned by the function. The function must accept exactly
205
- three positional arguments: the two endpoints of an edge and
206
- the dictionary of edge attributes for that edge.
207
- The function must return a number.
208
-
209
- method : string, optional (default = 'dijkstra')
210
- The algorithm to use to compute the path length.
211
- Supported options: 'dijkstra', 'bellman-ford'.
212
- Other inputs produce a ValueError.
213
- If `weight` is None, unweighted graph methods are used, and this
214
- suggestion is ignored.
215
-
216
- Returns
217
- -------
218
- length: number or iterator
219
- If the source and target are both specified, return the length of
220
- the shortest path from the source to the target.
221
-
222
- If only the source is specified, return a dict keyed by target
223
- to the shortest path length from the source to that target.
224
-
225
- If only the target is specified, return a dict keyed by source
226
- to the shortest path length from that source to the target.
227
-
228
- If neither the source nor target are specified, return an iterator
229
- over (source, dictionary) where dictionary is keyed by target to
230
- shortest path length from source to that target.
231
-
232
- Raises
233
- ------
234
- NodeNotFound
235
- If `source` is not in `G`.
236
-
237
- NetworkXNoPath
238
- If no path exists between source and target.
239
-
240
- ValueError
241
- If `method` is not among the supported options.
242
-
243
- Examples
244
- --------
245
- >>> G = nx.path_graph(5)
246
- >>> nx.shortest_path_length(G, source=0, target=4)
247
- 4
248
- >>> p = nx.shortest_path_length(G, source=0) # target not specified
249
- >>> p[4]
250
- 4
251
- >>> p = nx.shortest_path_length(G, target=4) # source not specified
252
- >>> p[0]
253
- 4
254
- >>> p = dict(nx.shortest_path_length(G)) # source,target not specified
255
- >>> p[0][4]
256
- 4
257
-
258
- Notes
259
- -----
260
- The length of the path is always 1 less than the number of nodes involved
261
- in the path since the length measures the number of edges followed.
262
-
263
- For digraphs this returns the shortest directed path length. To find path
264
- lengths in the reverse direction use G.reverse(copy=False) first to flip
265
- the edge orientation.
266
-
267
- See Also
268
- --------
269
- all_pairs_shortest_path_length
270
- all_pairs_dijkstra_path_length
271
- all_pairs_bellman_ford_path_length
272
- single_source_shortest_path_length
273
- single_source_dijkstra_path_length
274
- single_source_bellman_ford_path_length
275
- """
276
- if method not in ("dijkstra", "bellman-ford"):
277
- # so we don't need to check in each branch later
278
- raise ValueError(f"method not supported: {method}")
279
- method = "unweighted" if weight is None else method
280
- if source is None:
281
- if target is None:
282
- # Find paths between all pairs.
283
- if method == "unweighted":
284
- paths = nx.all_pairs_shortest_path_length(G)
285
- elif method == "dijkstra":
286
- paths = nx.all_pairs_dijkstra_path_length(G, weight=weight)
287
- else: # method == 'bellman-ford':
288
- paths = nx.all_pairs_bellman_ford_path_length(G, weight=weight)
289
- else:
290
- # Find paths from all nodes co-accessible to the target.
291
- if G.is_directed():
292
- G = G.reverse(copy=False)
293
- if method == "unweighted":
294
- path_length = nx.single_source_shortest_path_length
295
- paths = path_length(G, target)
296
- elif method == "dijkstra":
297
- path_length = nx.single_source_dijkstra_path_length
298
- paths = path_length(G, target, weight=weight)
299
- else: # method == 'bellman-ford':
300
- path_length = nx.single_source_bellman_ford_path_length
301
- paths = path_length(G, target, weight=weight)
302
- else:
303
- if target is None:
304
- # Find paths to all nodes accessible from the source.
305
- if method == "unweighted":
306
- paths = nx.single_source_shortest_path_length(G, source)
307
- elif method == "dijkstra":
308
- path_length = nx.single_source_dijkstra_path_length
309
- paths = path_length(G, source, weight=weight)
310
- else: # method == 'bellman-ford':
311
- path_length = nx.single_source_bellman_ford_path_length
312
- paths = path_length(G, source, weight=weight)
313
- else:
314
- # Find shortest source-target path.
315
- if method == "unweighted":
316
- p = nx.bidirectional_shortest_path(G, source, target)
317
- paths = len(p) - 1
318
- elif method == "dijkstra":
319
- paths = nx.dijkstra_path_length(G, source, target, weight)
320
- else: # method == 'bellman-ford':
321
- paths = nx.bellman_ford_path_length(G, source, target, weight)
322
- return paths
323
-
324
-
325
- @nx._dispatchable(edge_attrs="weight")
326
- def average_shortest_path_length(G, weight=None, method=None):
327
- r"""Returns the average shortest path length.
328
-
329
- The average shortest path length is
330
-
331
- .. math::
332
-
333
- a =\sum_{\substack{s,t \in V \\ s\neq t}} \frac{d(s, t)}{n(n-1)}
334
-
335
- where `V` is the set of nodes in `G`,
336
- `d(s, t)` is the shortest path from `s` to `t`,
337
- and `n` is the number of nodes in `G`.
338
-
339
- .. versionchanged:: 3.0
340
- An exception is raised for directed graphs that are not strongly
341
- connected.
342
-
343
- Parameters
344
- ----------
345
- G : NetworkX graph
346
-
347
- weight : None, string or function, optional (default = None)
348
- If None, every edge has weight/distance/cost 1.
349
- If a string, use this edge attribute as the edge weight.
350
- Any edge attribute not present defaults to 1.
351
- If this is a function, the weight of an edge is the value
352
- returned by the function. The function must accept exactly
353
- three positional arguments: the two endpoints of an edge and
354
- the dictionary of edge attributes for that edge.
355
- The function must return a number.
356
-
357
- method : string, optional (default = 'unweighted' or 'dijkstra')
358
- The algorithm to use to compute the path lengths.
359
- Supported options are 'unweighted', 'dijkstra', 'bellman-ford',
360
- 'floyd-warshall' and 'floyd-warshall-numpy'.
361
- Other method values produce a ValueError.
362
- The default method is 'unweighted' if `weight` is None,
363
- otherwise the default method is 'dijkstra'.
364
-
365
- Raises
366
- ------
367
- NetworkXPointlessConcept
368
- If `G` is the null graph (that is, the graph on zero nodes).
369
-
370
- NetworkXError
371
- If `G` is not connected (or not strongly connected, in the case
372
- of a directed graph).
373
-
374
- ValueError
375
- If `method` is not among the supported options.
376
-
377
- Examples
378
- --------
379
- >>> G = nx.path_graph(5)
380
- >>> nx.average_shortest_path_length(G)
381
- 2.0
382
-
383
- For disconnected graphs, you can compute the average shortest path
384
- length for each component
385
-
386
- >>> G = nx.Graph([(1, 2), (3, 4)])
387
- >>> for C in (G.subgraph(c).copy() for c in nx.connected_components(G)):
388
- ... print(nx.average_shortest_path_length(C))
389
- 1.0
390
- 1.0
391
-
392
- """
393
- single_source_methods = ["unweighted", "dijkstra", "bellman-ford"]
394
- all_pairs_methods = ["floyd-warshall", "floyd-warshall-numpy"]
395
- supported_methods = single_source_methods + all_pairs_methods
396
-
397
- if method is None:
398
- method = "unweighted" if weight is None else "dijkstra"
399
- if method not in supported_methods:
400
- raise ValueError(f"method not supported: {method}")
401
-
402
- n = len(G)
403
- # For the special case of the null graph, raise an exception, since
404
- # there are no paths in the null graph.
405
- if n == 0:
406
- msg = (
407
- "the null graph has no paths, thus there is no average shortest path length"
408
- )
409
- raise nx.NetworkXPointlessConcept(msg)
410
- # For the special case of the trivial graph, return zero immediately.
411
- if n == 1:
412
- return 0
413
- # Shortest path length is undefined if the graph is not strongly connected.
414
- if G.is_directed() and not nx.is_strongly_connected(G):
415
- raise nx.NetworkXError("Graph is not strongly connected.")
416
- # Shortest path length is undefined if the graph is not connected.
417
- if not G.is_directed() and not nx.is_connected(G):
418
- raise nx.NetworkXError("Graph is not connected.")
419
-
420
- # Compute all-pairs shortest paths.
421
- def path_length(v):
422
- if method == "unweighted":
423
- return nx.single_source_shortest_path_length(G, v)
424
- elif method == "dijkstra":
425
- return nx.single_source_dijkstra_path_length(G, v, weight=weight)
426
- elif method == "bellman-ford":
427
- return nx.single_source_bellman_ford_path_length(G, v, weight=weight)
428
-
429
- if method in single_source_methods:
430
- # Sum the distances for each (ordered) pair of source and target node.
431
- s = sum(l for u in G for l in path_length(u).values())
432
- else:
433
- if method == "floyd-warshall":
434
- all_pairs = nx.floyd_warshall(G, weight=weight)
435
- s = sum(sum(t.values()) for t in all_pairs.values())
436
- elif method == "floyd-warshall-numpy":
437
- s = float(nx.floyd_warshall_numpy(G, weight=weight).sum())
438
- return s / (n * (n - 1))
439
-
440
-
441
- @nx._dispatchable(edge_attrs="weight")
442
- def all_shortest_paths(G, source, target, weight=None, method="dijkstra"):
443
- """Compute all shortest simple paths in the graph.
444
-
445
- Parameters
446
- ----------
447
- G : NetworkX graph
448
-
449
- source : node
450
- Starting node for path.
451
-
452
- target : node
453
- Ending node for path.
454
-
455
- weight : None, string or function, optional (default = None)
456
- If None, every edge has weight/distance/cost 1.
457
- If a string, use this edge attribute as the edge weight.
458
- Any edge attribute not present defaults to 1.
459
- If this is a function, the weight of an edge is the value
460
- returned by the function. The function must accept exactly
461
- three positional arguments: the two endpoints of an edge and
462
- the dictionary of edge attributes for that edge.
463
- The function must return a number.
464
-
465
- method : string, optional (default = 'dijkstra')
466
- The algorithm to use to compute the path lengths.
467
- Supported options: 'dijkstra', 'bellman-ford'.
468
- Other inputs produce a ValueError.
469
- If `weight` is None, unweighted graph methods are used, and this
470
- suggestion is ignored.
471
-
472
- Returns
473
- -------
474
- paths : generator of lists
475
- A generator of all paths between source and target.
476
-
477
- Raises
478
- ------
479
- ValueError
480
- If `method` is not among the supported options.
481
-
482
- NetworkXNoPath
483
- If `target` cannot be reached from `source`.
484
-
485
- Examples
486
- --------
487
- >>> G = nx.Graph()
488
- >>> nx.add_path(G, [0, 1, 2])
489
- >>> nx.add_path(G, [0, 10, 2])
490
- >>> print([p for p in nx.all_shortest_paths(G, source=0, target=2)])
491
- [[0, 1, 2], [0, 10, 2]]
492
-
493
- Notes
494
- -----
495
- There may be many shortest paths between the source and target. If G
496
- contains zero-weight cycles, this function will not produce all shortest
497
- paths because doing so would produce infinitely many paths of unbounded
498
- length -- instead, we only produce the shortest simple paths.
499
-
500
- See Also
501
- --------
502
- shortest_path
503
- single_source_shortest_path
504
- all_pairs_shortest_path
505
- """
506
- method = "unweighted" if weight is None else method
507
- if method == "unweighted":
508
- pred = nx.predecessor(G, source)
509
- elif method == "dijkstra":
510
- pred, dist = nx.dijkstra_predecessor_and_distance(G, source, weight=weight)
511
- elif method == "bellman-ford":
512
- pred, dist = nx.bellman_ford_predecessor_and_distance(G, source, weight=weight)
513
- else:
514
- raise ValueError(f"method not supported: {method}")
515
-
516
- return _build_paths_from_predecessors({source}, target, pred)
517
-
518
-
519
- @nx._dispatchable(edge_attrs="weight")
520
- def single_source_all_shortest_paths(G, source, weight=None, method="dijkstra"):
521
- """Compute all shortest simple paths from the given source in the graph.
522
-
523
- Parameters
524
- ----------
525
- G : NetworkX graph
526
-
527
- source : node
528
- Starting node for path.
529
-
530
- weight : None, string or function, optional (default = None)
531
- If None, every edge has weight/distance/cost 1.
532
- If a string, use this edge attribute as the edge weight.
533
- Any edge attribute not present defaults to 1.
534
- If this is a function, the weight of an edge is the value
535
- returned by the function. The function must accept exactly
536
- three positional arguments: the two endpoints of an edge and
537
- the dictionary of edge attributes for that edge.
538
- The function must return a number.
539
-
540
- method : string, optional (default = 'dijkstra')
541
- The algorithm to use to compute the path lengths.
542
- Supported options: 'dijkstra', 'bellman-ford'.
543
- Other inputs produce a ValueError.
544
- If `weight` is None, unweighted graph methods are used, and this
545
- suggestion is ignored.
546
-
547
- Returns
548
- -------
549
- paths : generator of dictionary
550
- A generator of all paths between source and all nodes in the graph.
551
-
552
- Raises
553
- ------
554
- ValueError
555
- If `method` is not among the supported options.
556
-
557
- Examples
558
- --------
559
- >>> G = nx.Graph()
560
- >>> nx.add_path(G, [0, 1, 2, 3, 0])
561
- >>> dict(nx.single_source_all_shortest_paths(G, source=0))
562
- {0: [[0]], 1: [[0, 1]], 3: [[0, 3]], 2: [[0, 1, 2], [0, 3, 2]]}
563
-
564
- Notes
565
- -----
566
- There may be many shortest paths between the source and target. If G
567
- contains zero-weight cycles, this function will not produce all shortest
568
- paths because doing so would produce infinitely many paths of unbounded
569
- length -- instead, we only produce the shortest simple paths.
570
-
571
- See Also
572
- --------
573
- shortest_path
574
- all_shortest_paths
575
- single_source_shortest_path
576
- all_pairs_shortest_path
577
- all_pairs_all_shortest_paths
578
- """
579
- method = "unweighted" if weight is None else method
580
- if method == "unweighted":
581
- pred = nx.predecessor(G, source)
582
- elif method == "dijkstra":
583
- pred, dist = nx.dijkstra_predecessor_and_distance(G, source, weight=weight)
584
- elif method == "bellman-ford":
585
- pred, dist = nx.bellman_ford_predecessor_and_distance(G, source, weight=weight)
586
- else:
587
- raise ValueError(f"method not supported: {method}")
588
- for n in pred:
589
- yield n, list(_build_paths_from_predecessors({source}, n, pred))
590
-
591
-
592
- @nx._dispatchable(edge_attrs="weight")
593
- def all_pairs_all_shortest_paths(G, weight=None, method="dijkstra"):
594
- """Compute all shortest paths between all nodes.
595
-
596
- Parameters
597
- ----------
598
- G : NetworkX graph
599
-
600
- weight : None, string or function, optional (default = None)
601
- If None, every edge has weight/distance/cost 1.
602
- If a string, use this edge attribute as the edge weight.
603
- Any edge attribute not present defaults to 1.
604
- If this is a function, the weight of an edge is the value
605
- returned by the function. The function must accept exactly
606
- three positional arguments: the two endpoints of an edge and
607
- the dictionary of edge attributes for that edge.
608
- The function must return a number.
609
-
610
- method : string, optional (default = 'dijkstra')
611
- The algorithm to use to compute the path lengths.
612
- Supported options: 'dijkstra', 'bellman-ford'.
613
- Other inputs produce a ValueError.
614
- If `weight` is None, unweighted graph methods are used, and this
615
- suggestion is ignored.
616
-
617
- Returns
618
- -------
619
- paths : generator of dictionary
620
- Dictionary of arrays, keyed by source and target, of all shortest paths.
621
-
622
- Raises
623
- ------
624
- ValueError
625
- If `method` is not among the supported options.
626
-
627
- Examples
628
- --------
629
- >>> G = nx.cycle_graph(4)
630
- >>> dict(nx.all_pairs_all_shortest_paths(G))[0][2]
631
- [[0, 1, 2], [0, 3, 2]]
632
- >>> dict(nx.all_pairs_all_shortest_paths(G))[0][3]
633
- [[0, 3]]
634
-
635
- Notes
636
- -----
637
- There may be multiple shortest paths with equal lengths. Unlike
638
- all_pairs_shortest_path, this method returns all shortest paths.
639
-
640
- See Also
641
- --------
642
- all_pairs_shortest_path
643
- single_source_all_shortest_paths
644
- """
645
- for n in G:
646
- yield (
647
- n,
648
- dict(single_source_all_shortest_paths(G, n, weight=weight, method=method)),
649
- )
650
-
651
-
652
- def _build_paths_from_predecessors(sources, target, pred):
653
- """Compute all simple paths to target, given the predecessors found in
654
- pred, terminating when any source in sources is found.
655
-
656
- Parameters
657
- ----------
658
- sources : set
659
- Starting nodes for path.
660
-
661
- target : node
662
- Ending node for path.
663
-
664
- pred : dict
665
- A dictionary of predecessor lists, keyed by node
666
-
667
- Returns
668
- -------
669
- paths : generator of lists
670
- A generator of all paths between source and target.
671
-
672
- Raises
673
- ------
674
- NetworkXNoPath
675
- If `target` cannot be reached from `source`.
676
-
677
- Notes
678
- -----
679
- There may be many paths between the sources and target. If there are
680
- cycles among the predecessors, this function will not produce all
681
- possible paths because doing so would produce infinitely many paths
682
- of unbounded length -- instead, we only produce simple paths.
683
-
684
- See Also
685
- --------
686
- shortest_path
687
- single_source_shortest_path
688
- all_pairs_shortest_path
689
- all_shortest_paths
690
- bellman_ford_path
691
- """
692
- if target not in pred:
693
- raise nx.NetworkXNoPath(f"Target {target} cannot be reached from given sources")
694
-
695
- seen = {target}
696
- stack = [[target, 0]]
697
- top = 0
698
- while top >= 0:
699
- node, i = stack[top]
700
- if node in sources:
701
- yield [p for p, n in reversed(stack[: top + 1])]
702
- if len(pred[node]) > i:
703
- stack[top][1] = i + 1
704
- next = pred[node][i]
705
- if next in seen:
706
- continue
707
- else:
708
- seen.add(next)
709
- top += 1
710
- if top == len(stack):
711
- stack.append([next, 0])
712
- else:
713
- stack[top][:] = [next, 0]
714
- else:
715
- seen.discard(node)
716
- top -= 1