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,529 +0,0 @@
1
- """Basic algorithms for depth-first searching the nodes of a graph."""
2
-
3
- from collections import defaultdict
4
-
5
- import networkx as nx
6
-
7
- __all__ = [
8
- "dfs_edges",
9
- "dfs_tree",
10
- "dfs_predecessors",
11
- "dfs_successors",
12
- "dfs_preorder_nodes",
13
- "dfs_postorder_nodes",
14
- "dfs_labeled_edges",
15
- ]
16
-
17
-
18
- @nx._dispatchable
19
- def dfs_edges(G, source=None, depth_limit=None, *, sort_neighbors=None):
20
- """Iterate over edges in a depth-first-search (DFS).
21
-
22
- Perform a depth-first-search over the nodes of `G` and yield
23
- the edges in order. This may not generate all edges in `G`
24
- (see `~networkx.algorithms.traversal.edgedfs.edge_dfs`).
25
-
26
- Parameters
27
- ----------
28
- G : NetworkX graph
29
-
30
- source : node, optional
31
- Specify starting node for depth-first search and yield edges in
32
- the component reachable from source.
33
-
34
- depth_limit : int, optional (default=len(G))
35
- Specify the maximum search depth.
36
-
37
- sort_neighbors : function (default=None)
38
- A function that takes an iterator over nodes as the input, and
39
- returns an iterable of the same nodes with a custom ordering.
40
- For example, `sorted` will sort the nodes in increasing order.
41
-
42
- Yields
43
- ------
44
- edge: 2-tuple of nodes
45
- Yields edges resulting from the depth-first-search.
46
-
47
- Examples
48
- --------
49
- >>> G = nx.path_graph(5)
50
- >>> list(nx.dfs_edges(G, source=0))
51
- [(0, 1), (1, 2), (2, 3), (3, 4)]
52
- >>> list(nx.dfs_edges(G, source=0, depth_limit=2))
53
- [(0, 1), (1, 2)]
54
-
55
- Notes
56
- -----
57
- If a source is not specified then a source is chosen arbitrarily and
58
- repeatedly until all components in the graph are searched.
59
-
60
- The implementation of this function is adapted from David Eppstein's
61
- depth-first search function in PADS [1]_, with modifications
62
- to allow depth limits based on the Wikipedia article
63
- "Depth-limited search" [2]_.
64
-
65
- See Also
66
- --------
67
- dfs_preorder_nodes
68
- dfs_postorder_nodes
69
- dfs_labeled_edges
70
- :func:`~networkx.algorithms.traversal.edgedfs.edge_dfs`
71
- :func:`~networkx.algorithms.traversal.breadth_first_search.bfs_edges`
72
-
73
- References
74
- ----------
75
- .. [1] http://www.ics.uci.edu/~eppstein/PADS
76
- .. [2] https://en.wikipedia.org/wiki/Depth-limited_search
77
- """
78
- if source is None:
79
- # edges for all components
80
- nodes = G
81
- else:
82
- # edges for components with source
83
- nodes = [source]
84
- if depth_limit is None:
85
- depth_limit = len(G)
86
-
87
- get_children = (
88
- G.neighbors
89
- if sort_neighbors is None
90
- else lambda n: iter(sort_neighbors(G.neighbors(n)))
91
- )
92
-
93
- visited = set()
94
- for start in nodes:
95
- if start in visited:
96
- continue
97
- visited.add(start)
98
- stack = [(start, get_children(start))]
99
- depth_now = 1
100
- while stack:
101
- parent, children = stack[-1]
102
- for child in children:
103
- if child not in visited:
104
- yield parent, child
105
- visited.add(child)
106
- if depth_now < depth_limit:
107
- stack.append((child, get_children(child)))
108
- depth_now += 1
109
- break
110
- else:
111
- stack.pop()
112
- depth_now -= 1
113
-
114
-
115
- @nx._dispatchable(returns_graph=True)
116
- def dfs_tree(G, source=None, depth_limit=None, *, sort_neighbors=None):
117
- """Returns oriented tree constructed from a depth-first-search from source.
118
-
119
- Parameters
120
- ----------
121
- G : NetworkX graph
122
-
123
- source : node, optional
124
- Specify starting node for depth-first search.
125
-
126
- depth_limit : int, optional (default=len(G))
127
- Specify the maximum search depth.
128
-
129
- sort_neighbors : function (default=None)
130
- A function that takes an iterator over nodes as the input, and
131
- returns an iterable of the same nodes with a custom ordering.
132
- For example, `sorted` will sort the nodes in increasing order.
133
-
134
- Returns
135
- -------
136
- T : NetworkX DiGraph
137
- An oriented tree
138
-
139
- Examples
140
- --------
141
- >>> G = nx.path_graph(5)
142
- >>> T = nx.dfs_tree(G, source=0, depth_limit=2)
143
- >>> list(T.edges())
144
- [(0, 1), (1, 2)]
145
- >>> T = nx.dfs_tree(G, source=0)
146
- >>> list(T.edges())
147
- [(0, 1), (1, 2), (2, 3), (3, 4)]
148
-
149
- See Also
150
- --------
151
- dfs_preorder_nodes
152
- dfs_postorder_nodes
153
- dfs_labeled_edges
154
- :func:`~networkx.algorithms.traversal.edgedfs.edge_dfs`
155
- :func:`~networkx.algorithms.traversal.breadth_first_search.bfs_tree`
156
- """
157
- T = nx.DiGraph()
158
- if source is None:
159
- T.add_nodes_from(G)
160
- else:
161
- T.add_node(source)
162
- T.add_edges_from(dfs_edges(G, source, depth_limit, sort_neighbors=sort_neighbors))
163
- return T
164
-
165
-
166
- @nx._dispatchable
167
- def dfs_predecessors(G, source=None, depth_limit=None, *, sort_neighbors=None):
168
- """Returns dictionary of predecessors in depth-first-search from source.
169
-
170
- Parameters
171
- ----------
172
- G : NetworkX graph
173
-
174
- source : node, optional
175
- Specify starting node for depth-first search.
176
- Note that you will get predecessors for all nodes in the
177
- component containing `source`. This input only specifies
178
- where the DFS starts.
179
-
180
- depth_limit : int, optional (default=len(G))
181
- Specify the maximum search depth.
182
-
183
- sort_neighbors : function (default=None)
184
- A function that takes an iterator over nodes as the input, and
185
- returns an iterable of the same nodes with a custom ordering.
186
- For example, `sorted` will sort the nodes in increasing order.
187
-
188
- Returns
189
- -------
190
- pred: dict
191
- A dictionary with nodes as keys and predecessor nodes as values.
192
-
193
- Examples
194
- --------
195
- >>> G = nx.path_graph(4)
196
- >>> nx.dfs_predecessors(G, source=0)
197
- {1: 0, 2: 1, 3: 2}
198
- >>> nx.dfs_predecessors(G, source=0, depth_limit=2)
199
- {1: 0, 2: 1}
200
-
201
- Notes
202
- -----
203
- If a source is not specified then a source is chosen arbitrarily and
204
- repeatedly until all components in the graph are searched.
205
-
206
- The implementation of this function is adapted from David Eppstein's
207
- depth-first search function in `PADS`_, with modifications
208
- to allow depth limits based on the Wikipedia article
209
- "`Depth-limited search`_".
210
-
211
- .. _PADS: http://www.ics.uci.edu/~eppstein/PADS
212
- .. _Depth-limited search: https://en.wikipedia.org/wiki/Depth-limited_search
213
-
214
- See Also
215
- --------
216
- dfs_preorder_nodes
217
- dfs_postorder_nodes
218
- dfs_labeled_edges
219
- :func:`~networkx.algorithms.traversal.edgedfs.edge_dfs`
220
- :func:`~networkx.algorithms.traversal.breadth_first_search.bfs_tree`
221
- """
222
- return {
223
- t: s
224
- for s, t in dfs_edges(G, source, depth_limit, sort_neighbors=sort_neighbors)
225
- }
226
-
227
-
228
- @nx._dispatchable
229
- def dfs_successors(G, source=None, depth_limit=None, *, sort_neighbors=None):
230
- """Returns dictionary of successors in depth-first-search from source.
231
-
232
- Parameters
233
- ----------
234
- G : NetworkX graph
235
-
236
- source : node, optional
237
- Specify starting node for depth-first search.
238
- Note that you will get successors for all nodes in the
239
- component containing `source`. This input only specifies
240
- where the DFS starts.
241
-
242
- depth_limit : int, optional (default=len(G))
243
- Specify the maximum search depth.
244
-
245
- sort_neighbors : function (default=None)
246
- A function that takes an iterator over nodes as the input, and
247
- returns an iterable of the same nodes with a custom ordering.
248
- For example, `sorted` will sort the nodes in increasing order.
249
-
250
- Returns
251
- -------
252
- succ: dict
253
- A dictionary with nodes as keys and list of successor nodes as values.
254
-
255
- Examples
256
- --------
257
- >>> G = nx.path_graph(5)
258
- >>> nx.dfs_successors(G, source=0)
259
- {0: [1], 1: [2], 2: [3], 3: [4]}
260
- >>> nx.dfs_successors(G, source=0, depth_limit=2)
261
- {0: [1], 1: [2]}
262
-
263
- Notes
264
- -----
265
- If a source is not specified then a source is chosen arbitrarily and
266
- repeatedly until all components in the graph are searched.
267
-
268
- The implementation of this function is adapted from David Eppstein's
269
- depth-first search function in `PADS`_, with modifications
270
- to allow depth limits based on the Wikipedia article
271
- "`Depth-limited search`_".
272
-
273
- .. _PADS: http://www.ics.uci.edu/~eppstein/PADS
274
- .. _Depth-limited search: https://en.wikipedia.org/wiki/Depth-limited_search
275
-
276
- See Also
277
- --------
278
- dfs_preorder_nodes
279
- dfs_postorder_nodes
280
- dfs_labeled_edges
281
- :func:`~networkx.algorithms.traversal.edgedfs.edge_dfs`
282
- :func:`~networkx.algorithms.traversal.breadth_first_search.bfs_tree`
283
- """
284
- d = defaultdict(list)
285
- for s, t in dfs_edges(
286
- G,
287
- source=source,
288
- depth_limit=depth_limit,
289
- sort_neighbors=sort_neighbors,
290
- ):
291
- d[s].append(t)
292
- return dict(d)
293
-
294
-
295
- @nx._dispatchable
296
- def dfs_postorder_nodes(G, source=None, depth_limit=None, *, sort_neighbors=None):
297
- """Generate nodes in a depth-first-search post-ordering starting at source.
298
-
299
- Parameters
300
- ----------
301
- G : NetworkX graph
302
-
303
- source : node, optional
304
- Specify starting node for depth-first search.
305
-
306
- depth_limit : int, optional (default=len(G))
307
- Specify the maximum search depth.
308
-
309
- sort_neighbors : function (default=None)
310
- A function that takes an iterator over nodes as the input, and
311
- returns an iterable of the same nodes with a custom ordering.
312
- For example, `sorted` will sort the nodes in increasing order.
313
-
314
- Returns
315
- -------
316
- nodes: generator
317
- A generator of nodes in a depth-first-search post-ordering.
318
-
319
- Examples
320
- --------
321
- >>> G = nx.path_graph(5)
322
- >>> list(nx.dfs_postorder_nodes(G, source=0))
323
- [4, 3, 2, 1, 0]
324
- >>> list(nx.dfs_postorder_nodes(G, source=0, depth_limit=2))
325
- [1, 0]
326
-
327
- Notes
328
- -----
329
- If a source is not specified then a source is chosen arbitrarily and
330
- repeatedly until all components in the graph are searched.
331
-
332
- The implementation of this function is adapted from David Eppstein's
333
- depth-first search function in `PADS`_, with modifications
334
- to allow depth limits based on the Wikipedia article
335
- "`Depth-limited search`_".
336
-
337
- .. _PADS: http://www.ics.uci.edu/~eppstein/PADS
338
- .. _Depth-limited search: https://en.wikipedia.org/wiki/Depth-limited_search
339
-
340
- See Also
341
- --------
342
- dfs_edges
343
- dfs_preorder_nodes
344
- dfs_labeled_edges
345
- :func:`~networkx.algorithms.traversal.edgedfs.edge_dfs`
346
- :func:`~networkx.algorithms.traversal.breadth_first_search.bfs_tree`
347
- """
348
- edges = nx.dfs_labeled_edges(
349
- G, source=source, depth_limit=depth_limit, sort_neighbors=sort_neighbors
350
- )
351
- return (v for u, v, d in edges if d == "reverse")
352
-
353
-
354
- @nx._dispatchable
355
- def dfs_preorder_nodes(G, source=None, depth_limit=None, *, sort_neighbors=None):
356
- """Generate nodes in a depth-first-search pre-ordering starting at source.
357
-
358
- Parameters
359
- ----------
360
- G : NetworkX graph
361
-
362
- source : node, optional
363
- Specify starting node for depth-first search and return nodes in
364
- the component reachable from source.
365
-
366
- depth_limit : int, optional (default=len(G))
367
- Specify the maximum search depth.
368
-
369
- sort_neighbors : function (default=None)
370
- A function that takes an iterator over nodes as the input, and
371
- returns an iterable of the same nodes with a custom ordering.
372
- For example, `sorted` will sort the nodes in increasing order.
373
-
374
- Returns
375
- -------
376
- nodes: generator
377
- A generator of nodes in a depth-first-search pre-ordering.
378
-
379
- Examples
380
- --------
381
- >>> G = nx.path_graph(5)
382
- >>> list(nx.dfs_preorder_nodes(G, source=0))
383
- [0, 1, 2, 3, 4]
384
- >>> list(nx.dfs_preorder_nodes(G, source=0, depth_limit=2))
385
- [0, 1, 2]
386
-
387
- Notes
388
- -----
389
- If a source is not specified then a source is chosen arbitrarily and
390
- repeatedly until all components in the graph are searched.
391
-
392
- The implementation of this function is adapted from David Eppstein's
393
- depth-first search function in `PADS`_, with modifications
394
- to allow depth limits based on the Wikipedia article
395
- "`Depth-limited search`_".
396
-
397
- .. _PADS: http://www.ics.uci.edu/~eppstein/PADS
398
- .. _Depth-limited search: https://en.wikipedia.org/wiki/Depth-limited_search
399
-
400
- See Also
401
- --------
402
- dfs_edges
403
- dfs_postorder_nodes
404
- dfs_labeled_edges
405
- :func:`~networkx.algorithms.traversal.breadth_first_search.bfs_edges`
406
- """
407
- edges = nx.dfs_labeled_edges(
408
- G, source=source, depth_limit=depth_limit, sort_neighbors=sort_neighbors
409
- )
410
- return (v for u, v, d in edges if d == "forward")
411
-
412
-
413
- @nx._dispatchable
414
- def dfs_labeled_edges(G, source=None, depth_limit=None, *, sort_neighbors=None):
415
- """Iterate over edges in a depth-first-search (DFS) labeled by type.
416
-
417
- Parameters
418
- ----------
419
- G : NetworkX graph
420
-
421
- source : node, optional
422
- Specify starting node for depth-first search and return edges in
423
- the component reachable from source.
424
-
425
- depth_limit : int, optional (default=len(G))
426
- Specify the maximum search depth.
427
-
428
- sort_neighbors : function (default=None)
429
- A function that takes an iterator over nodes as the input, and
430
- returns an iterable of the same nodes with a custom ordering.
431
- For example, `sorted` will sort the nodes in increasing order.
432
-
433
- Returns
434
- -------
435
- edges: generator
436
- A generator of triples of the form (*u*, *v*, *d*), where (*u*,
437
- *v*) is the edge being explored in the depth-first search and *d*
438
- is one of the strings 'forward', 'nontree', 'reverse', or 'reverse-depth_limit'.
439
- A 'forward' edge is one in which *u* has been visited but *v* has
440
- not. A 'nontree' edge is one in which both *u* and *v* have been
441
- visited but the edge is not in the DFS tree. A 'reverse' edge is
442
- one in which both *u* and *v* have been visited and the edge is in
443
- the DFS tree. When the `depth_limit` is reached via a 'forward' edge,
444
- a 'reverse' edge is immediately generated rather than the subtree
445
- being explored. To indicate this flavor of 'reverse' edge, the string
446
- yielded is 'reverse-depth_limit'.
447
-
448
- Examples
449
- --------
450
-
451
- The labels reveal the complete transcript of the depth-first search
452
- algorithm in more detail than, for example, :func:`dfs_edges`::
453
-
454
- >>> from pprint import pprint
455
- >>>
456
- >>> G = nx.DiGraph([(0, 1), (1, 2), (2, 1)])
457
- >>> pprint(list(nx.dfs_labeled_edges(G, source=0)))
458
- [(0, 0, 'forward'),
459
- (0, 1, 'forward'),
460
- (1, 2, 'forward'),
461
- (2, 1, 'nontree'),
462
- (1, 2, 'reverse'),
463
- (0, 1, 'reverse'),
464
- (0, 0, 'reverse')]
465
-
466
- Notes
467
- -----
468
- If a source is not specified then a source is chosen arbitrarily and
469
- repeatedly until all components in the graph are searched.
470
-
471
- The implementation of this function is adapted from David Eppstein's
472
- depth-first search function in `PADS`_, with modifications
473
- to allow depth limits based on the Wikipedia article
474
- "`Depth-limited search`_".
475
-
476
- .. _PADS: http://www.ics.uci.edu/~eppstein/PADS
477
- .. _Depth-limited search: https://en.wikipedia.org/wiki/Depth-limited_search
478
-
479
- See Also
480
- --------
481
- dfs_edges
482
- dfs_preorder_nodes
483
- dfs_postorder_nodes
484
- """
485
- # Based on http://www.ics.uci.edu/~eppstein/PADS/DFS.py
486
- # by D. Eppstein, July 2004.
487
- if source is None:
488
- # edges for all components
489
- nodes = G
490
- else:
491
- # edges for components with source
492
- nodes = [source]
493
- if depth_limit is None:
494
- depth_limit = len(G)
495
-
496
- get_children = (
497
- G.neighbors
498
- if sort_neighbors is None
499
- else lambda n: iter(sort_neighbors(G.neighbors(n)))
500
- )
501
-
502
- visited = set()
503
- for start in nodes:
504
- if start in visited:
505
- continue
506
- yield start, start, "forward"
507
- visited.add(start)
508
- stack = [(start, get_children(start))]
509
- depth_now = 1
510
- while stack:
511
- parent, children = stack[-1]
512
- for child in children:
513
- if child in visited:
514
- yield parent, child, "nontree"
515
- else:
516
- yield parent, child, "forward"
517
- visited.add(child)
518
- if depth_now < depth_limit:
519
- stack.append((child, iter(get_children(child))))
520
- depth_now += 1
521
- break
522
- else:
523
- yield parent, child, "reverse-depth_limit"
524
- else:
525
- stack.pop()
526
- depth_now -= 1
527
- if stack:
528
- yield stack[-1][0], parent, "reverse"
529
- yield start, start, "reverse"
@@ -1,185 +0,0 @@
1
- """
2
- =============================
3
- Breadth First Search on Edges
4
- =============================
5
-
6
- Algorithms for a breadth-first traversal of edges in a graph.
7
-
8
- """
9
-
10
- from collections import deque
11
-
12
- import networkx as nx
13
-
14
- FORWARD = "forward"
15
- REVERSE = "reverse"
16
-
17
- __all__ = ["edge_bfs"]
18
-
19
-
20
- @nx._dispatchable
21
- def edge_bfs(G, source=None, orientation=None):
22
- """A directed, breadth-first-search of edges in `G`, beginning at `source`.
23
-
24
- Yield the edges of G in a breadth-first-search order continuing until
25
- all edges are generated.
26
-
27
- Parameters
28
- ----------
29
- G : graph
30
- A directed/undirected graph/multigraph.
31
-
32
- source : node, list of nodes
33
- The node from which the traversal begins. If None, then a source
34
- is chosen arbitrarily and repeatedly until all edges from each node in
35
- the graph are searched.
36
-
37
- orientation : None | 'original' | 'reverse' | 'ignore' (default: None)
38
- For directed graphs and directed multigraphs, edge traversals need not
39
- respect the original orientation of the edges.
40
- When set to 'reverse' every edge is traversed in the reverse direction.
41
- When set to 'ignore', every edge is treated as undirected.
42
- When set to 'original', every edge is treated as directed.
43
- In all three cases, the yielded edge tuples add a last entry to
44
- indicate the direction in which that edge was traversed.
45
- If orientation is None, the yielded edge has no direction indicated.
46
- The direction is respected, but not reported.
47
-
48
- Yields
49
- ------
50
- edge : directed edge
51
- A directed edge indicating the path taken by the breadth-first-search.
52
- For graphs, `edge` is of the form `(u, v)` where `u` and `v`
53
- are the tail and head of the edge as determined by the traversal.
54
- For multigraphs, `edge` is of the form `(u, v, key)`, where `key` is
55
- the key of the edge. When the graph is directed, then `u` and `v`
56
- are always in the order of the actual directed edge.
57
- If orientation is not None then the edge tuple is extended to include
58
- the direction of traversal ('forward' or 'reverse') on that edge.
59
-
60
- Examples
61
- --------
62
- >>> from pprint import pprint
63
- >>> nodes = [0, 1, 2, 3]
64
- >>> edges = [(0, 1), (1, 0), (1, 0), (2, 0), (2, 1), (3, 1)]
65
-
66
- >>> list(nx.edge_bfs(nx.Graph(edges), nodes))
67
- [(0, 1), (0, 2), (1, 2), (1, 3)]
68
-
69
- >>> list(nx.edge_bfs(nx.DiGraph(edges), nodes))
70
- [(0, 1), (1, 0), (2, 0), (2, 1), (3, 1)]
71
-
72
- >>> list(nx.edge_bfs(nx.MultiGraph(edges), nodes))
73
- [(0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 2, 0), (1, 2, 0), (1, 3, 0)]
74
-
75
- >>> list(nx.edge_bfs(nx.MultiDiGraph(edges), nodes))
76
- [(0, 1, 0), (1, 0, 0), (1, 0, 1), (2, 0, 0), (2, 1, 0), (3, 1, 0)]
77
-
78
- >>> list(nx.edge_bfs(nx.DiGraph(edges), nodes, orientation="ignore"))
79
- [(0, 1, 'forward'), (1, 0, 'reverse'), (2, 0, 'reverse'), (2, 1, 'reverse'), (3, 1, 'reverse')]
80
-
81
- >>> elist = list(nx.edge_bfs(nx.MultiDiGraph(edges), nodes, orientation="ignore"))
82
- >>> pprint(elist)
83
- [(0, 1, 0, 'forward'),
84
- (1, 0, 0, 'reverse'),
85
- (1, 0, 1, 'reverse'),
86
- (2, 0, 0, 'reverse'),
87
- (2, 1, 0, 'reverse'),
88
- (3, 1, 0, 'reverse')]
89
-
90
- Notes
91
- -----
92
- The goal of this function is to visit edges. It differs from the more
93
- familiar breadth-first-search of nodes, as provided by
94
- :func:`networkx.algorithms.traversal.breadth_first_search.bfs_edges`, in
95
- that it does not stop once every node has been visited. In a directed graph
96
- with edges [(0, 1), (1, 2), (2, 1)], the edge (2, 1) would not be visited
97
- if not for the functionality provided by this function.
98
-
99
- The naming of this function is very similar to bfs_edges. The difference
100
- is that 'edge_bfs' yields edges even if they extend back to an already
101
- explored node while 'bfs_edges' yields the edges of the tree that results
102
- from a breadth-first-search (BFS) so no edges are reported if they extend
103
- to already explored nodes. That means 'edge_bfs' reports all edges while
104
- 'bfs_edges' only report those traversed by a node-based BFS. Yet another
105
- description is that 'bfs_edges' reports the edges traversed during BFS
106
- while 'edge_bfs' reports all edges in the order they are explored.
107
-
108
- See Also
109
- --------
110
- bfs_edges
111
- bfs_tree
112
- edge_dfs
113
-
114
- """
115
- nodes = list(G.nbunch_iter(source))
116
- if not nodes:
117
- return
118
-
119
- directed = G.is_directed()
120
- kwds = {"data": False}
121
- if G.is_multigraph() is True:
122
- kwds["keys"] = True
123
-
124
- # set up edge lookup
125
- if orientation is None:
126
-
127
- def edges_from(node):
128
- return iter(G.edges(node, **kwds))
129
-
130
- elif not directed or orientation == "original":
131
-
132
- def edges_from(node):
133
- for e in G.edges(node, **kwds):
134
- yield e + (FORWARD,)
135
-
136
- elif orientation == "reverse":
137
-
138
- def edges_from(node):
139
- for e in G.in_edges(node, **kwds):
140
- yield e + (REVERSE,)
141
-
142
- elif orientation == "ignore":
143
-
144
- def edges_from(node):
145
- for e in G.edges(node, **kwds):
146
- yield e + (FORWARD,)
147
- for e in G.in_edges(node, **kwds):
148
- yield e + (REVERSE,)
149
-
150
- else:
151
- raise nx.NetworkXError("invalid orientation argument.")
152
-
153
- if directed:
154
- neighbors = G.successors
155
-
156
- def edge_id(edge):
157
- # remove direction indicator
158
- return edge[:-1] if orientation is not None else edge
159
-
160
- else:
161
- neighbors = G.neighbors
162
-
163
- def edge_id(edge):
164
- return (frozenset(edge[:2]),) + edge[2:]
165
-
166
- check_reverse = directed and orientation in ("reverse", "ignore")
167
-
168
- # start BFS
169
- visited_nodes = set(nodes)
170
- visited_edges = set()
171
- queue = deque([(n, edges_from(n)) for n in nodes])
172
- while queue:
173
- parent, children_edges = queue.popleft()
174
- for edge in children_edges:
175
- if check_reverse and edge[-1] == REVERSE:
176
- child = edge[0]
177
- else:
178
- child = edge[1]
179
- if child not in visited_nodes:
180
- visited_nodes.add(child)
181
- queue.append((child, edges_from(child)))
182
- edgeid = edge_id(edge)
183
- if edgeid not in visited_edges:
184
- visited_edges.add(edgeid)
185
- yield edge