okstra 0.108.0 → 0.109.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (642) hide show
  1. package/package.json +1 -1
  2. package/runtime/BUILD.json +2 -2
  3. package/runtime/prompts/profiles/_common-contract.md +1 -1
  4. package/runtime/python/okstra_ctl/graphify_cmd.py +225 -0
  5. package/runtime/python/okstra_ctl/resolve_task_key.py +15 -9
  6. package/runtime/python/okstra_project/__init__.py +2 -0
  7. package/runtime/python/okstra_project/state.py +36 -0
  8. package/runtime/python/okstra_vendor/__init__.py +41 -0
  9. package/runtime/python/okstra_vendor/graphify/.vendored-version +1 -0
  10. package/runtime/python/okstra_vendor/graphify/__init__.py +28 -0
  11. package/runtime/python/okstra_vendor/graphify/__main__.py +1371 -0
  12. package/runtime/python/okstra_vendor/graphify/analyze.py +540 -0
  13. package/runtime/python/okstra_vendor/graphify/benchmark.py +129 -0
  14. package/runtime/python/okstra_vendor/graphify/build.py +107 -0
  15. package/runtime/python/okstra_vendor/graphify/cache.py +169 -0
  16. package/runtime/python/okstra_vendor/graphify/cluster.py +137 -0
  17. package/runtime/python/okstra_vendor/graphify/detect.py +510 -0
  18. package/runtime/python/okstra_vendor/graphify/export.py +1014 -0
  19. package/runtime/python/okstra_vendor/graphify/extract.py +3277 -0
  20. package/runtime/python/okstra_vendor/graphify/hooks.py +220 -0
  21. package/runtime/python/okstra_vendor/graphify/ingest.py +297 -0
  22. package/runtime/python/okstra_vendor/graphify/manifest.py +4 -0
  23. package/runtime/python/okstra_vendor/graphify/report.py +175 -0
  24. package/runtime/python/okstra_vendor/graphify/security.py +203 -0
  25. package/runtime/python/okstra_vendor/graphify/serve.py +373 -0
  26. package/runtime/python/okstra_vendor/graphify/skill-aider.md +1184 -0
  27. package/runtime/python/okstra_vendor/graphify/skill-claw.md +1184 -0
  28. package/runtime/python/okstra_vendor/graphify/skill-codex.md +1242 -0
  29. package/runtime/python/okstra_vendor/graphify/skill-copilot.md +1268 -0
  30. package/runtime/python/okstra_vendor/graphify/skill-droid.md +1239 -0
  31. package/runtime/python/okstra_vendor/graphify/skill-kiro.md +1183 -0
  32. package/runtime/python/okstra_vendor/graphify/skill-opencode.md +1238 -0
  33. package/runtime/python/okstra_vendor/graphify/skill-trae.md +1208 -0
  34. package/runtime/python/okstra_vendor/graphify/skill-vscode.md +253 -0
  35. package/runtime/python/okstra_vendor/graphify/skill-windows.md +1245 -0
  36. package/runtime/python/okstra_vendor/graphify/skill.md +1319 -0
  37. package/runtime/python/okstra_vendor/graphify/transcribe.py +182 -0
  38. package/runtime/python/okstra_vendor/graphify/validate.py +72 -0
  39. package/runtime/python/okstra_vendor/graphify/watch.py +188 -0
  40. package/runtime/python/okstra_vendor/graphify/wiki.py +214 -0
  41. package/runtime/python/okstra_vendor/networkx/__init__.py +62 -0
  42. package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +134 -0
  43. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +26 -0
  44. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +259 -0
  45. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +71 -0
  46. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +412 -0
  47. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +396 -0
  48. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +150 -0
  49. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +149 -0
  50. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +369 -0
  51. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +44 -0
  52. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +143 -0
  53. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +53 -0
  54. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +265 -0
  55. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/__init__.py +0 -0
  56. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py +41 -0
  57. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_clique.py +112 -0
  58. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_connectivity.py +199 -0
  59. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_density.py +146 -0
  60. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_distance_measures.py +59 -0
  61. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_dominating_set.py +78 -0
  62. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_kcomponents.py +303 -0
  63. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_matching.py +8 -0
  64. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_maxcut.py +94 -0
  65. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_ramsey.py +31 -0
  66. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_steinertree.py +306 -0
  67. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_traveling_salesman.py +1014 -0
  68. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_treewidth.py +274 -0
  69. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_vertex_cover.py +68 -0
  70. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +1508 -0
  71. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +255 -0
  72. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +83 -0
  73. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +5 -0
  74. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +122 -0
  75. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +302 -0
  76. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +255 -0
  77. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +160 -0
  78. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +127 -0
  79. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/__init__.py +0 -0
  80. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/base_test.py +81 -0
  81. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_connectivity.py +143 -0
  82. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_correlation.py +122 -0
  83. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_mixing.py +174 -0
  84. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_neighbor_degree.py +107 -0
  85. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_pairs.py +87 -0
  86. package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +164 -0
  87. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +88 -0
  88. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +322 -0
  89. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +290 -0
  90. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +289 -0
  91. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +57 -0
  92. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +360 -0
  93. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +105 -0
  94. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +603 -0
  95. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +316 -0
  96. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +590 -0
  97. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +232 -0
  98. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +526 -0
  99. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +112 -0
  100. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +69 -0
  101. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/__init__.py +0 -0
  102. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_basic.py +125 -0
  103. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_centrality.py +192 -0
  104. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_cluster.py +84 -0
  105. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_covering.py +33 -0
  106. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_edgelist.py +240 -0
  107. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_extendability.py +334 -0
  108. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_generators.py +407 -0
  109. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_link_analysis.py +218 -0
  110. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matching.py +327 -0
  111. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matrix.py +138 -0
  112. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_project.py +409 -0
  113. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_redundancy.py +35 -0
  114. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py +80 -0
  115. package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +168 -0
  116. package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +205 -0
  117. package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +164 -0
  118. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +20 -0
  119. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +591 -0
  120. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +236 -0
  121. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +282 -0
  122. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +364 -0
  123. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +227 -0
  124. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +96 -0
  125. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +150 -0
  126. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +107 -0
  127. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +357 -0
  128. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +130 -0
  129. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +787 -0
  130. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +88 -0
  131. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +331 -0
  132. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +150 -0
  133. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +200 -0
  134. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +128 -0
  135. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +209 -0
  136. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +141 -0
  137. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +361 -0
  138. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/__init__.py +0 -0
  139. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality.py +923 -0
  140. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py +354 -0
  141. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_closeness_centrality.py +274 -0
  142. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality.py +259 -0
  143. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality_subset.py +147 -0
  144. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_closeness.py +43 -0
  145. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_degree_centrality.py +144 -0
  146. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_dispersion.py +73 -0
  147. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py +186 -0
  148. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_group.py +277 -0
  149. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_harmonic_centrality.py +122 -0
  150. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_katz_centrality.py +345 -0
  151. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_laplacian_centrality.py +220 -0
  152. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_load_centrality.py +344 -0
  153. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_percolation_centrality.py +87 -0
  154. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_reaching.py +140 -0
  155. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_second_order_centrality.py +82 -0
  156. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_subgraph.py +110 -0
  157. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_trophic.py +302 -0
  158. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_voterank.py +64 -0
  159. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +181 -0
  160. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +95 -0
  161. package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +172 -0
  162. package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +443 -0
  163. package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +818 -0
  164. package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +732 -0
  165. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +4 -0
  166. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +505 -0
  167. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +565 -0
  168. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/__init__.py +0 -0
  169. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/test_coloring.py +863 -0
  170. package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +163 -0
  171. package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +28 -0
  172. package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +153 -0
  173. package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +354 -0
  174. package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +171 -0
  175. package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +30 -0
  176. package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +216 -0
  177. package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +79 -0
  178. package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +338 -0
  179. package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +162 -0
  180. package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +220 -0
  181. package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +384 -0
  182. package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +227 -0
  183. package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +452 -0
  184. package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +347 -0
  185. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/__init__.py +0 -0
  186. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_asyn_fluid.py +147 -0
  187. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_bipartitions.py +157 -0
  188. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_centrality.py +85 -0
  189. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_divisive.py +106 -0
  190. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_kclique.py +91 -0
  191. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_label_propagation.py +241 -0
  192. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_leiden.py +138 -0
  193. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_local.py +76 -0
  194. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_louvain.py +264 -0
  195. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_lukes.py +152 -0
  196. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_modularity_max.py +340 -0
  197. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_quality.py +139 -0
  198. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_utils.py +26 -0
  199. package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +6 -0
  200. package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +115 -0
  201. package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +394 -0
  202. package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +282 -0
  203. package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +71 -0
  204. package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +359 -0
  205. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/__init__.py +0 -0
  206. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_attracting.py +70 -0
  207. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_biconnected.py +248 -0
  208. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_connected.py +138 -0
  209. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_semiconnected.py +55 -0
  210. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_strongly_connected.py +193 -0
  211. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_weakly_connected.py +96 -0
  212. package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +196 -0
  213. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +11 -0
  214. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +811 -0
  215. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +616 -0
  216. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +408 -0
  217. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +1270 -0
  218. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +592 -0
  219. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +220 -0
  220. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +235 -0
  221. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +152 -0
  222. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/__init__.py +0 -0
  223. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_connectivity.py +421 -0
  224. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_cuts.py +309 -0
  225. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_disjoint_paths.py +249 -0
  226. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_augmentation.py +502 -0
  227. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_kcomponents.py +488 -0
  228. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcomponents.py +323 -0
  229. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcutsets.py +280 -0
  230. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_stoer_wagner.py +102 -0
  231. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +88 -0
  232. package/runtime/python/okstra_vendor/networkx/algorithms/core.py +588 -0
  233. package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +142 -0
  234. package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +416 -0
  235. package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +1234 -0
  236. package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +677 -0
  237. package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +1392 -0
  238. package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +1095 -0
  239. package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +272 -0
  240. package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +142 -0
  241. package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +268 -0
  242. package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +167 -0
  243. package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +470 -0
  244. package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +11 -0
  245. package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +370 -0
  246. package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +407 -0
  247. package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +238 -0
  248. package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +241 -0
  249. package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +178 -0
  250. package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +611 -0
  251. package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +356 -0
  252. package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +662 -0
  253. package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +425 -0
  254. package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +300 -0
  255. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/__init__.py +0 -0
  256. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gl1.gpickle.bz2 +0 -0
  257. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gw1.gpickle.bz2 +0 -0
  258. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/netgen-2.gpickle.bz2 +0 -0
  259. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_gomory_hu.py +128 -0
  260. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow.py +573 -0
  261. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow_large_graph.py +155 -0
  262. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_mincost.py +475 -0
  263. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_networksimplex.py +481 -0
  264. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/wlm3.gpickle.bz2 +0 -0
  265. package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +194 -0
  266. package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +435 -0
  267. package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +483 -0
  268. package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +57 -0
  269. package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +196 -0
  270. package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +107 -0
  271. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +7 -0
  272. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +1306 -0
  273. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +336 -0
  274. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +1262 -0
  275. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +352 -0
  276. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +308 -0
  277. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/__init__.py +0 -0
  278. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.A99 +0 -0
  279. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.B99 +0 -0
  280. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.A99 +0 -0
  281. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.B99 +0 -0
  282. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_ismags.py +719 -0
  283. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphism.py +103 -0
  284. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py +490 -0
  285. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_match_helpers.py +64 -0
  286. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_temporalisomorphvf2.py +212 -0
  287. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_tree_isomorphism.py +202 -0
  288. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp.py +1655 -0
  289. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp_helpers.py +3118 -0
  290. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py +196 -0
  291. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +264 -0
  292. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +1102 -0
  293. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +192 -0
  294. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +2 -0
  295. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +337 -0
  296. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +498 -0
  297. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/__init__.py +0 -0
  298. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_hits.py +77 -0
  299. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_pagerank.py +213 -0
  300. package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +687 -0
  301. package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +280 -0
  302. package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +1148 -0
  303. package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +27 -0
  304. package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +738 -0
  305. package/runtime/python/okstra_vendor/networkx/algorithms/minors/tests/test_contraction.py +544 -0
  306. package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +78 -0
  307. package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +59 -0
  308. package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +219 -0
  309. package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +155 -0
  310. package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +4 -0
  311. package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +324 -0
  312. package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +468 -0
  313. package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +633 -0
  314. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/__init__.py +0 -0
  315. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_all.py +328 -0
  316. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_binary.py +451 -0
  317. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_product.py +491 -0
  318. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_unary.py +55 -0
  319. package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +77 -0
  320. package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +73 -0
  321. package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +464 -0
  322. package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +1463 -0
  323. package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +306 -0
  324. package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +98 -0
  325. package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +167 -0
  326. package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +138 -0
  327. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +5 -0
  328. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +239 -0
  329. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +264 -0
  330. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +716 -0
  331. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/__init__.py +0 -0
  332. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_astar.py +254 -0
  333. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense.py +212 -0
  334. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense_numpy.py +88 -0
  335. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_generic.py +511 -0
  336. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_unweighted.py +149 -0
  337. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_weighted.py +983 -0
  338. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +625 -0
  339. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +2542 -0
  340. package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +2107 -0
  341. package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +966 -0
  342. package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +404 -0
  343. package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +30 -0
  344. package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +296 -0
  345. package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +374 -0
  346. package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +564 -0
  347. package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +406 -0
  348. package/runtime/python/okstra_vendor/networkx/algorithms/tests/__init__.py +0 -0
  349. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_asteroidal.py +23 -0
  350. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_boundary.py +154 -0
  351. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_bridges.py +144 -0
  352. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_broadcasting.py +109 -0
  353. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chains.py +136 -0
  354. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chordal.py +129 -0
  355. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_clique.py +300 -0
  356. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cluster.py +678 -0
  357. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_communicability.py +80 -0
  358. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_core.py +266 -0
  359. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_covering.py +85 -0
  360. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cuts.py +171 -0
  361. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cycles.py +984 -0
  362. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_d_separation.py +340 -0
  363. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dag.py +835 -0
  364. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_measures.py +831 -0
  365. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_regular.py +85 -0
  366. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominance.py +299 -0
  367. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominating.py +115 -0
  368. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_efficiency.py +58 -0
  369. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_euler.py +314 -0
  370. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graph_hashing.py +872 -0
  371. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graphical.py +163 -0
  372. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hierarchy.py +46 -0
  373. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hybrid.py +24 -0
  374. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_isolate.py +26 -0
  375. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_link_prediction.py +615 -0
  376. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_lowest_common_ancestors.py +459 -0
  377. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_matching.py +556 -0
  378. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_max_weight_clique.py +179 -0
  379. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_mis.py +62 -0
  380. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_moral.py +15 -0
  381. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_node_classification.py +140 -0
  382. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_non_randomness.py +60 -0
  383. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_perfect_graph.py +27 -0
  384. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planar_drawing.py +274 -0
  385. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planarity.py +556 -0
  386. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_polynomials.py +57 -0
  387. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_reciprocity.py +37 -0
  388. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_regular.py +88 -0
  389. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_richclub.py +149 -0
  390. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_similarity.py +1158 -0
  391. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_simple_paths.py +803 -0
  392. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smallworld.py +76 -0
  393. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smetric.py +8 -0
  394. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_sparsifiers.py +138 -0
  395. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_structuralholes.py +191 -0
  396. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_summarization.py +642 -0
  397. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_swap.py +179 -0
  398. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_threshold.py +270 -0
  399. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_time_dependent.py +431 -0
  400. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_tournament.py +161 -0
  401. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_triads.py +248 -0
  402. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_vitality.py +41 -0
  403. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_voronoi.py +103 -0
  404. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_walks.py +54 -0
  405. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_wiener.py +157 -0
  406. package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +981 -0
  407. package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +142 -0
  408. package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +406 -0
  409. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +5 -0
  410. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +90 -0
  411. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +576 -0
  412. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +529 -0
  413. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +185 -0
  414. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +182 -0
  415. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/__init__.py +0 -0
  416. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_beamsearch.py +25 -0
  417. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_bfs.py +203 -0
  418. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_dfs.py +307 -0
  419. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgebfs.py +147 -0
  420. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgedfs.py +131 -0
  421. package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +7 -0
  422. package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +1042 -0
  423. package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +413 -0
  424. package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +88 -0
  425. package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +219 -0
  426. package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +1281 -0
  427. package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +106 -0
  428. package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +273 -0
  429. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/__init__.py +0 -0
  430. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_branchings.py +624 -0
  431. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_coding.py +114 -0
  432. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_decomposition.py +79 -0
  433. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_distance_measures.py +99 -0
  434. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_mst.py +934 -0
  435. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_operations.py +53 -0
  436. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_recognition.py +174 -0
  437. package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +500 -0
  438. package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +76 -0
  439. package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +86 -0
  440. package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +77 -0
  441. package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +278 -0
  442. package/runtime/python/okstra_vendor/networkx/classes/__init__.py +13 -0
  443. package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +435 -0
  444. package/runtime/python/okstra_vendor/networkx/classes/digraph.py +1363 -0
  445. package/runtime/python/okstra_vendor/networkx/classes/filters.py +95 -0
  446. package/runtime/python/okstra_vendor/networkx/classes/function.py +1549 -0
  447. package/runtime/python/okstra_vendor/networkx/classes/graph.py +2082 -0
  448. package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +269 -0
  449. package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +977 -0
  450. package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +1294 -0
  451. package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +1447 -0
  452. package/runtime/python/okstra_vendor/networkx/classes/tests/__init__.py +0 -0
  453. package/runtime/python/okstra_vendor/networkx/classes/tests/dispatch_interface.py +192 -0
  454. package/runtime/python/okstra_vendor/networkx/classes/tests/historical_tests.py +476 -0
  455. package/runtime/python/okstra_vendor/networkx/classes/tests/test_coreviews.py +362 -0
  456. package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph.py +331 -0
  457. package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph_historical.py +110 -0
  458. package/runtime/python/okstra_vendor/networkx/classes/tests/test_filters.py +177 -0
  459. package/runtime/python/okstra_vendor/networkx/classes/tests/test_function.py +1045 -0
  460. package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph.py +950 -0
  461. package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph_historical.py +12 -0
  462. package/runtime/python/okstra_vendor/networkx/classes/tests/test_graphviews.py +349 -0
  463. package/runtime/python/okstra_vendor/networkx/classes/tests/test_multidigraph.py +459 -0
  464. package/runtime/python/okstra_vendor/networkx/classes/tests/test_multigraph.py +528 -0
  465. package/runtime/python/okstra_vendor/networkx/classes/tests/test_reportviews.py +1421 -0
  466. package/runtime/python/okstra_vendor/networkx/classes/tests/test_special.py +131 -0
  467. package/runtime/python/okstra_vendor/networkx/classes/tests/test_subgraphviews.py +371 -0
  468. package/runtime/python/okstra_vendor/networkx/conftest.py +261 -0
  469. package/runtime/python/okstra_vendor/networkx/convert.py +502 -0
  470. package/runtime/python/okstra_vendor/networkx/convert_matrix.py +1314 -0
  471. package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +7 -0
  472. package/runtime/python/okstra_vendor/networkx/drawing/layout.py +2036 -0
  473. package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +470 -0
  474. package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +570 -0
  475. package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +361 -0
  476. package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +2978 -0
  477. package/runtime/python/okstra_vendor/networkx/drawing/tests/__init__.py +0 -0
  478. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_complex.png +0 -0
  479. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_empty_graph.png +0 -0
  480. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_house_with_colors.png +0 -0
  481. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_labels_and_colors.png +0 -0
  482. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_shortest_path.png +0 -0
  483. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_house_with_colors.png +0 -0
  484. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_agraph.py +237 -0
  485. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_image_comparison_pylab_mpl.py +229 -0
  486. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_latex.py +285 -0
  487. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_layout.py +631 -0
  488. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pydot.py +146 -0
  489. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pylab.py +1582 -0
  490. package/runtime/python/okstra_vendor/networkx/exception.py +131 -0
  491. package/runtime/python/okstra_vendor/networkx/generators/__init__.py +34 -0
  492. package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
  493. package/runtime/python/okstra_vendor/networkx/generators/atlas.py +227 -0
  494. package/runtime/python/okstra_vendor/networkx/generators/classic.py +1091 -0
  495. package/runtime/python/okstra_vendor/networkx/generators/cographs.py +68 -0
  496. package/runtime/python/okstra_vendor/networkx/generators/community.py +1070 -0
  497. package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +886 -0
  498. package/runtime/python/okstra_vendor/networkx/generators/directed.py +572 -0
  499. package/runtime/python/okstra_vendor/networkx/generators/duplication.py +174 -0
  500. package/runtime/python/okstra_vendor/networkx/generators/ego.py +66 -0
  501. package/runtime/python/okstra_vendor/networkx/generators/expanders.py +499 -0
  502. package/runtime/python/okstra_vendor/networkx/generators/geometric.py +1037 -0
  503. package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +163 -0
  504. package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +443 -0
  505. package/runtime/python/okstra_vendor/networkx/generators/intersection.py +125 -0
  506. package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +70 -0
  507. package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +664 -0
  508. package/runtime/python/okstra_vendor/networkx/generators/lattice.py +405 -0
  509. package/runtime/python/okstra_vendor/networkx/generators/line.py +501 -0
  510. package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +110 -0
  511. package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +259 -0
  512. package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +117 -0
  513. package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +1416 -0
  514. package/runtime/python/okstra_vendor/networkx/generators/small.py +1070 -0
  515. package/runtime/python/okstra_vendor/networkx/generators/social.py +554 -0
  516. package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +120 -0
  517. package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +54 -0
  518. package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +131 -0
  519. package/runtime/python/okstra_vendor/networkx/generators/tests/__init__.py +0 -0
  520. package/runtime/python/okstra_vendor/networkx/generators/tests/test_atlas.py +75 -0
  521. package/runtime/python/okstra_vendor/networkx/generators/tests/test_classic.py +642 -0
  522. package/runtime/python/okstra_vendor/networkx/generators/tests/test_cographs.py +20 -0
  523. package/runtime/python/okstra_vendor/networkx/generators/tests/test_community.py +362 -0
  524. package/runtime/python/okstra_vendor/networkx/generators/tests/test_degree_seq.py +224 -0
  525. package/runtime/python/okstra_vendor/networkx/generators/tests/test_directed.py +189 -0
  526. package/runtime/python/okstra_vendor/networkx/generators/tests/test_duplication.py +103 -0
  527. package/runtime/python/okstra_vendor/networkx/generators/tests/test_ego.py +39 -0
  528. package/runtime/python/okstra_vendor/networkx/generators/tests/test_expanders.py +182 -0
  529. package/runtime/python/okstra_vendor/networkx/generators/tests/test_geometric.py +488 -0
  530. package/runtime/python/okstra_vendor/networkx/generators/tests/test_harary_graph.py +133 -0
  531. package/runtime/python/okstra_vendor/networkx/generators/tests/test_internet_as_graphs.py +221 -0
  532. package/runtime/python/okstra_vendor/networkx/generators/tests/test_intersection.py +28 -0
  533. package/runtime/python/okstra_vendor/networkx/generators/tests/test_interval_graph.py +144 -0
  534. package/runtime/python/okstra_vendor/networkx/generators/tests/test_joint_degree_seq.py +125 -0
  535. package/runtime/python/okstra_vendor/networkx/generators/tests/test_lattice.py +264 -0
  536. package/runtime/python/okstra_vendor/networkx/generators/tests/test_line.py +316 -0
  537. package/runtime/python/okstra_vendor/networkx/generators/tests/test_mycielski.py +30 -0
  538. package/runtime/python/okstra_vendor/networkx/generators/tests/test_nonisomorphic_trees.py +82 -0
  539. package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_clustered.py +33 -0
  540. package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_graphs.py +495 -0
  541. package/runtime/python/okstra_vendor/networkx/generators/tests/test_small.py +220 -0
  542. package/runtime/python/okstra_vendor/networkx/generators/tests/test_spectral_graph_forge.py +49 -0
  543. package/runtime/python/okstra_vendor/networkx/generators/tests/test_stochastic.py +72 -0
  544. package/runtime/python/okstra_vendor/networkx/generators/tests/test_sudoku.py +92 -0
  545. package/runtime/python/okstra_vendor/networkx/generators/tests/test_time_series.py +64 -0
  546. package/runtime/python/okstra_vendor/networkx/generators/tests/test_trees.py +195 -0
  547. package/runtime/python/okstra_vendor/networkx/generators/tests/test_triads.py +15 -0
  548. package/runtime/python/okstra_vendor/networkx/generators/time_series.py +74 -0
  549. package/runtime/python/okstra_vendor/networkx/generators/trees.py +1070 -0
  550. package/runtime/python/okstra_vendor/networkx/generators/triads.py +94 -0
  551. package/runtime/python/okstra_vendor/networkx/lazy_imports.py +188 -0
  552. package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +13 -0
  553. package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +650 -0
  554. package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +466 -0
  555. package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +77 -0
  556. package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +168 -0
  557. package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +512 -0
  558. package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +166 -0
  559. package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +186 -0
  560. package/runtime/python/okstra_vendor/networkx/linalg/tests/__init__.py +0 -0
  561. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_algebraic_connectivity.py +400 -0
  562. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_attrmatrix.py +108 -0
  563. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_bethehessian.py +40 -0
  564. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_graphmatrix.py +275 -0
  565. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_laplacian.py +334 -0
  566. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_modularity.py +86 -0
  567. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_spectrum.py +70 -0
  568. package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +17 -0
  569. package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +330 -0
  570. package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +489 -0
  571. package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +1084 -0
  572. package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +879 -0
  573. package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +427 -0
  574. package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +1053 -0
  575. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +19 -0
  576. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +156 -0
  577. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +190 -0
  578. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +261 -0
  579. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/__init__.py +0 -0
  580. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_adjacency.py +78 -0
  581. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_cytoscape.py +78 -0
  582. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_node_link.py +109 -0
  583. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_tree.py +48 -0
  584. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +137 -0
  585. package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +108 -0
  586. package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +393 -0
  587. package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +113 -0
  588. package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +286 -0
  589. package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +379 -0
  590. package/runtime/python/okstra_vendor/networkx/readwrite/tests/__init__.py +0 -0
  591. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_adjlist.py +354 -0
  592. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_edgelist.py +318 -0
  593. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gexf.py +612 -0
  594. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gml.py +744 -0
  595. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graph6.py +181 -0
  596. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graphml.py +1531 -0
  597. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_leda.py +30 -0
  598. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_p2g.py +63 -0
  599. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_pajek.py +128 -0
  600. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_sparse6.py +166 -0
  601. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_text.py +1742 -0
  602. package/runtime/python/okstra_vendor/networkx/readwrite/text.py +851 -0
  603. package/runtime/python/okstra_vendor/networkx/relabel.py +285 -0
  604. package/runtime/python/okstra_vendor/networkx/tests/__init__.py +0 -0
  605. package/runtime/python/okstra_vendor/networkx/tests/test_all_random_functions.py +248 -0
  606. package/runtime/python/okstra_vendor/networkx/tests/test_convert.py +321 -0
  607. package/runtime/python/okstra_vendor/networkx/tests/test_convert_numpy.py +531 -0
  608. package/runtime/python/okstra_vendor/networkx/tests/test_convert_pandas.py +349 -0
  609. package/runtime/python/okstra_vendor/networkx/tests/test_convert_scipy.py +281 -0
  610. package/runtime/python/okstra_vendor/networkx/tests/test_exceptions.py +40 -0
  611. package/runtime/python/okstra_vendor/networkx/tests/test_import.py +11 -0
  612. package/runtime/python/okstra_vendor/networkx/tests/test_lazy_imports.py +96 -0
  613. package/runtime/python/okstra_vendor/networkx/tests/test_relabel.py +349 -0
  614. package/runtime/python/okstra_vendor/networkx/tests/test_removed_functions_exception_messages.py +8 -0
  615. package/runtime/python/okstra_vendor/networkx/utils/__init__.py +8 -0
  616. package/runtime/python/okstra_vendor/networkx/utils/backends.py +2171 -0
  617. package/runtime/python/okstra_vendor/networkx/utils/configs.py +396 -0
  618. package/runtime/python/okstra_vendor/networkx/utils/decorators.py +1233 -0
  619. package/runtime/python/okstra_vendor/networkx/utils/heaps.py +338 -0
  620. package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +297 -0
  621. package/runtime/python/okstra_vendor/networkx/utils/misc.py +703 -0
  622. package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +198 -0
  623. package/runtime/python/okstra_vendor/networkx/utils/rcm.py +159 -0
  624. package/runtime/python/okstra_vendor/networkx/utils/tests/__init__.py +0 -0
  625. package/runtime/python/okstra_vendor/networkx/utils/tests/test__init.py +11 -0
  626. package/runtime/python/okstra_vendor/networkx/utils/tests/test_backends.py +225 -0
  627. package/runtime/python/okstra_vendor/networkx/utils/tests/test_config.py +263 -0
  628. package/runtime/python/okstra_vendor/networkx/utils/tests/test_decorators.py +510 -0
  629. package/runtime/python/okstra_vendor/networkx/utils/tests/test_heaps.py +131 -0
  630. package/runtime/python/okstra_vendor/networkx/utils/tests/test_mapped_queue.py +268 -0
  631. package/runtime/python/okstra_vendor/networkx/utils/tests/test_misc.py +393 -0
  632. package/runtime/python/okstra_vendor/networkx/utils/tests/test_random_sequence.py +53 -0
  633. package/runtime/python/okstra_vendor/networkx/utils/tests/test_rcm.py +63 -0
  634. package/runtime/python/okstra_vendor/networkx/utils/tests/test_unionfind.py +55 -0
  635. package/runtime/python/okstra_vendor/networkx/utils/union_find.py +106 -0
  636. package/runtime/skills/okstra-graphify/SKILL.md +161 -0
  637. package/runtime/skills/okstra-inspect/SKILL.md +17 -9
  638. package/runtime/templates/reports/settings.template.json +4 -0
  639. package/src/cli-registry.mjs +7 -0
  640. package/src/commands/graphify.mjs +32 -0
  641. package/src/commands/lifecycle/doctor.mjs +9 -0
  642. package/src/lib/skill-catalog.mjs +1 -0
@@ -0,0 +1,966 @@
1
+ from heapq import heappop, heappush
2
+ from itertools import count
3
+
4
+ import networkx as nx
5
+ from networkx.algorithms.shortest_paths.weighted import _weight_function
6
+ from networkx.utils import not_implemented_for, pairwise
7
+
8
+ __all__ = [
9
+ "all_simple_paths",
10
+ "is_simple_path",
11
+ "shortest_simple_paths",
12
+ "all_simple_edge_paths",
13
+ ]
14
+
15
+
16
+ @nx._dispatchable
17
+ def is_simple_path(G, nodes):
18
+ """Returns True if and only if `nodes` form a simple path in `G`.
19
+
20
+ A *simple path* in a graph is a nonempty sequence of nodes in which
21
+ no node appears more than once in the sequence, and each adjacent
22
+ pair of nodes in the sequence is adjacent in the graph.
23
+
24
+ Parameters
25
+ ----------
26
+ G : graph
27
+ A NetworkX graph.
28
+ nodes : list
29
+ A list of one or more nodes in the graph `G`.
30
+
31
+ Returns
32
+ -------
33
+ bool
34
+ Whether the given list of nodes represents a simple path in `G`.
35
+
36
+ Notes
37
+ -----
38
+ An empty list of nodes is not a path but a list of one node is a
39
+ path. Here's an explanation why.
40
+
41
+ This function operates on *node paths*. One could also consider
42
+ *edge paths*. There is a bijection between node paths and edge
43
+ paths.
44
+
45
+ The *length of a path* is the number of edges in the path, so a list
46
+ of nodes of length *n* corresponds to a path of length *n* - 1.
47
+ Thus the smallest edge path would be a list of zero edges, the empty
48
+ path. This corresponds to a list of one node.
49
+
50
+ To convert between a node path and an edge path, you can use code
51
+ like the following::
52
+
53
+ >>> from networkx.utils import pairwise
54
+ >>> nodes = [0, 1, 2, 3]
55
+ >>> edges = list(pairwise(nodes))
56
+ >>> edges
57
+ [(0, 1), (1, 2), (2, 3)]
58
+ >>> nodes = [edges[0][0]] + [v for u, v in edges]
59
+ >>> nodes
60
+ [0, 1, 2, 3]
61
+
62
+ Examples
63
+ --------
64
+ >>> G = nx.cycle_graph(4)
65
+ >>> nx.is_simple_path(G, [2, 3, 0])
66
+ True
67
+ >>> nx.is_simple_path(G, [0, 2])
68
+ False
69
+
70
+ """
71
+ # The empty list is not a valid path. Could also return
72
+ # NetworkXPointlessConcept here.
73
+ if len(nodes) == 0:
74
+ return False
75
+
76
+ # If the list is a single node, just check that the node is actually
77
+ # in the graph.
78
+ if len(nodes) == 1:
79
+ return nodes[0] in G
80
+
81
+ # check that all nodes in the list are in the graph, if at least one
82
+ # is not in the graph, then this is not a simple path
83
+ if not all(n in G for n in nodes):
84
+ return False
85
+
86
+ # If the list contains repeated nodes, then it's not a simple path
87
+ if len(set(nodes)) != len(nodes):
88
+ return False
89
+
90
+ # Test that each adjacent pair of nodes is adjacent.
91
+ return all(v in G[u] for u, v in pairwise(nodes))
92
+
93
+
94
+ @nx._dispatchable
95
+ def all_simple_paths(G, source, target, cutoff=None):
96
+ """Generate all simple paths in the graph G from source to target.
97
+
98
+ A simple path is a path with no repeated nodes.
99
+
100
+ Parameters
101
+ ----------
102
+ G : NetworkX graph
103
+
104
+ source : node
105
+ Starting node for path
106
+
107
+ target : nodes
108
+ Single node or iterable of nodes at which to end path
109
+
110
+ cutoff : integer, optional
111
+ Depth to stop the search. Only paths with length <= `cutoff` are returned.
112
+ where the mathematical "length of a path" is `len(path) -1` (number of edges).
113
+
114
+ Returns
115
+ -------
116
+ path_generator: generator
117
+ A generator that produces lists of simple paths. If there are no paths
118
+ between the source and target within the given cutoff the generator
119
+ produces no output. If it is possible to traverse the same sequence of
120
+ nodes in multiple ways, namely through parallel edges, then it will be
121
+ returned multiple times (once for each viable edge combination).
122
+
123
+ Examples
124
+ --------
125
+ This iterator generates lists of nodes::
126
+
127
+ >>> G = nx.complete_graph(4)
128
+ >>> for path in nx.all_simple_paths(G, source=0, target=3):
129
+ ... print(path)
130
+ ...
131
+ [0, 1, 2, 3]
132
+ [0, 1, 3]
133
+ [0, 2, 1, 3]
134
+ [0, 2, 3]
135
+ [0, 3]
136
+
137
+ You can generate only those paths that are shorter than a certain
138
+ length by using the `cutoff` keyword argument::
139
+
140
+ >>> paths = nx.all_simple_paths(G, source=0, target=3, cutoff=2)
141
+ >>> print(list(paths))
142
+ [[0, 1, 3], [0, 2, 3], [0, 3]]
143
+
144
+ To get each path as the corresponding list of edges, you can use the
145
+ :func:`networkx.utils.pairwise` helper function::
146
+
147
+ >>> paths = nx.all_simple_paths(G, source=0, target=3)
148
+ >>> for path in map(nx.utils.pairwise, paths):
149
+ ... print(list(path))
150
+ [(0, 1), (1, 2), (2, 3)]
151
+ [(0, 1), (1, 3)]
152
+ [(0, 2), (2, 1), (1, 3)]
153
+ [(0, 2), (2, 3)]
154
+ [(0, 3)]
155
+
156
+ Pass an iterable of nodes as target to generate all paths ending in any of several nodes::
157
+
158
+ >>> G = nx.complete_graph(4)
159
+ >>> for path in nx.all_simple_paths(G, source=0, target=[3, 2]):
160
+ ... print(path)
161
+ ...
162
+ [0, 1, 2]
163
+ [0, 1, 2, 3]
164
+ [0, 1, 3]
165
+ [0, 1, 3, 2]
166
+ [0, 2]
167
+ [0, 2, 1, 3]
168
+ [0, 2, 3]
169
+ [0, 3]
170
+ [0, 3, 1, 2]
171
+ [0, 3, 2]
172
+
173
+ The singleton path from ``source`` to itself is considered a simple path and is
174
+ included in the results:
175
+
176
+ >>> G = nx.empty_graph(5)
177
+ >>> list(nx.all_simple_paths(G, source=0, target=0))
178
+ [[0]]
179
+
180
+ >>> G = nx.path_graph(3)
181
+ >>> list(nx.all_simple_paths(G, source=0, target={0, 1, 2}))
182
+ [[0], [0, 1], [0, 1, 2]]
183
+
184
+ Iterate over each path from the root nodes to the leaf nodes in a
185
+ directed acyclic graph using a functional programming approach::
186
+
187
+ >>> from itertools import chain
188
+ >>> from itertools import product
189
+ >>> from itertools import starmap
190
+ >>> from functools import partial
191
+ >>>
192
+ >>> chaini = chain.from_iterable
193
+ >>>
194
+ >>> G = nx.DiGraph([(0, 1), (1, 2), (0, 3), (3, 2)])
195
+ >>> roots = (v for v, d in G.in_degree() if d == 0)
196
+ >>> leaves = (v for v, d in G.out_degree() if d == 0)
197
+ >>> all_paths = partial(nx.all_simple_paths, G)
198
+ >>> list(chaini(starmap(all_paths, product(roots, leaves))))
199
+ [[0, 1, 2], [0, 3, 2]]
200
+
201
+ The same list computed using an iterative approach::
202
+
203
+ >>> G = nx.DiGraph([(0, 1), (1, 2), (0, 3), (3, 2)])
204
+ >>> roots = (v for v, d in G.in_degree() if d == 0)
205
+ >>> leaves = (v for v, d in G.out_degree() if d == 0)
206
+ >>> all_paths = []
207
+ >>> for root in roots:
208
+ ... for leaf in leaves:
209
+ ... paths = nx.all_simple_paths(G, root, leaf)
210
+ ... all_paths.extend(paths)
211
+ >>> all_paths
212
+ [[0, 1, 2], [0, 3, 2]]
213
+
214
+ Iterate over each path from the root nodes to the leaf nodes in a
215
+ directed acyclic graph passing all leaves together to avoid unnecessary
216
+ compute::
217
+
218
+ >>> G = nx.DiGraph([(0, 1), (2, 1), (1, 3), (1, 4)])
219
+ >>> roots = (v for v, d in G.in_degree() if d == 0)
220
+ >>> leaves = [v for v, d in G.out_degree() if d == 0]
221
+ >>> all_paths = []
222
+ >>> for root in roots:
223
+ ... paths = nx.all_simple_paths(G, root, leaves)
224
+ ... all_paths.extend(paths)
225
+ >>> all_paths
226
+ [[0, 1, 3], [0, 1, 4], [2, 1, 3], [2, 1, 4]]
227
+
228
+ If parallel edges offer multiple ways to traverse a given sequence of
229
+ nodes, this sequence of nodes will be returned multiple times:
230
+
231
+ >>> G = nx.MultiDiGraph([(0, 1), (0, 1), (1, 2)])
232
+ >>> list(nx.all_simple_paths(G, 0, 2))
233
+ [[0, 1, 2], [0, 1, 2]]
234
+
235
+ Notes
236
+ -----
237
+ This algorithm uses a modified depth-first search to generate the
238
+ paths [1]_. A single path can be found in $O(V+E)$ time but the
239
+ number of simple paths in a graph can be very large, e.g. $O(n!)$ in
240
+ the complete graph of order $n$.
241
+
242
+ This function does not check that a path exists between `source` and
243
+ `target`. For large graphs, this may result in very long runtimes.
244
+ Consider using `has_path` to check that a path exists between `source` and
245
+ `target` before calling this function on large graphs.
246
+
247
+ References
248
+ ----------
249
+ .. [1] R. Sedgewick, "Algorithms in C, Part 5: Graph Algorithms",
250
+ Addison Wesley Professional, 3rd ed., 2001.
251
+
252
+ See Also
253
+ --------
254
+ all_shortest_paths, shortest_path, has_path
255
+
256
+ """
257
+ for edge_path in all_simple_edge_paths(G, source, target, cutoff):
258
+ yield [source] + [edge[1] for edge in edge_path]
259
+
260
+
261
+ @nx._dispatchable
262
+ def all_simple_edge_paths(G, source, target, cutoff=None):
263
+ """Generate lists of edges for all simple paths in G from source to target.
264
+
265
+ A simple path is a path with no repeated nodes.
266
+
267
+ Parameters
268
+ ----------
269
+ G : NetworkX graph
270
+
271
+ source : node
272
+ Starting node for path
273
+
274
+ target : nodes
275
+ Single node or iterable of nodes at which to end path
276
+
277
+ cutoff : integer, optional
278
+ Depth to stop the search. Only paths with length <= `cutoff` are returned.
279
+ Note that the length of an edge path is the number of edges.
280
+
281
+ Returns
282
+ -------
283
+ path_generator: generator
284
+ A generator that produces lists of simple paths. If there are no paths
285
+ between the source and target within the given cutoff the generator
286
+ produces no output.
287
+ For multigraphs, the list of edges have elements of the form `(u,v,k)`.
288
+ Where `k` corresponds to the edge key.
289
+
290
+ Examples
291
+ --------
292
+
293
+ Print the simple path edges of a Graph::
294
+
295
+ >>> g = nx.Graph([(1, 2), (2, 4), (1, 3), (3, 4)])
296
+ >>> for path in sorted(nx.all_simple_edge_paths(g, 1, 4)):
297
+ ... print(path)
298
+ [(1, 2), (2, 4)]
299
+ [(1, 3), (3, 4)]
300
+
301
+ Print the simple path edges of a MultiGraph. Returned edges come with
302
+ their associated keys::
303
+
304
+ >>> mg = nx.MultiGraph()
305
+ >>> mg.add_edge(1, 2, key="k0")
306
+ 'k0'
307
+ >>> mg.add_edge(1, 2, key="k1")
308
+ 'k1'
309
+ >>> mg.add_edge(2, 3, key="k0")
310
+ 'k0'
311
+ >>> for path in sorted(nx.all_simple_edge_paths(mg, 1, 3)):
312
+ ... print(path)
313
+ [(1, 2, 'k0'), (2, 3, 'k0')]
314
+ [(1, 2, 'k1'), (2, 3, 'k0')]
315
+
316
+ When ``source`` is one of the targets, the empty path starting and ending at
317
+ ``source`` without traversing any edge is considered a valid simple edge path
318
+ and is included in the results:
319
+
320
+ >>> G = nx.Graph()
321
+ >>> G.add_node(0)
322
+ >>> paths = list(nx.all_simple_edge_paths(G, 0, 0))
323
+ >>> for path in paths:
324
+ ... print(path)
325
+ []
326
+ >>> len(paths)
327
+ 1
328
+
329
+ You can use the `cutoff` parameter to only generate paths that are
330
+ shorter than a certain length:
331
+
332
+ >>> g = nx.Graph([(1, 2), (2, 3), (3, 4), (4, 5), (1, 4), (1, 5)])
333
+ >>> for path in sorted(nx.all_simple_edge_paths(g, 1, 5)):
334
+ ... print(path)
335
+ [(1, 2), (2, 3), (3, 4), (4, 5)]
336
+ [(1, 4), (4, 5)]
337
+ [(1, 5)]
338
+ >>> for path in sorted(nx.all_simple_edge_paths(g, 1, 5, cutoff=1)):
339
+ ... print(path)
340
+ [(1, 5)]
341
+ >>> for path in sorted(nx.all_simple_edge_paths(g, 1, 5, cutoff=2)):
342
+ ... print(path)
343
+ [(1, 4), (4, 5)]
344
+ [(1, 5)]
345
+
346
+ Notes
347
+ -----
348
+ This algorithm uses a modified depth-first search to generate the
349
+ paths [1]_. A single path can be found in $O(V+E)$ time but the
350
+ number of simple paths in a graph can be very large, e.g. $O(n!)$ in
351
+ the complete graph of order $n$.
352
+
353
+ References
354
+ ----------
355
+ .. [1] R. Sedgewick, "Algorithms in C, Part 5: Graph Algorithms",
356
+ Addison Wesley Professional, 3rd ed., 2001.
357
+
358
+ See Also
359
+ --------
360
+ all_shortest_paths, shortest_path, all_simple_paths
361
+
362
+ """
363
+ if source not in G:
364
+ raise nx.NodeNotFound(f"source node {source} not in graph")
365
+
366
+ if target in G:
367
+ targets = {target}
368
+ else:
369
+ try:
370
+ targets = set(target)
371
+ except TypeError as err:
372
+ raise nx.NodeNotFound(f"target node {target} not in graph") from err
373
+
374
+ cutoff = cutoff if cutoff is not None else len(G) - 1
375
+
376
+ if cutoff >= 0 and targets:
377
+ yield from _all_simple_edge_paths(G, source, targets, cutoff)
378
+
379
+
380
+ def _all_simple_edge_paths(G, source, targets, cutoff):
381
+ # We simulate recursion with a stack, keeping the current path being explored
382
+ # and the outgoing edge iterators at each point in the stack.
383
+ # To avoid unnecessary checks, the loop is structured in a way such that a path
384
+ # is considered for yielding only after a new node/edge is added.
385
+ # We bootstrap the search by adding a dummy iterator to the stack that only yields
386
+ # a dummy edge to source (so that the trivial path has a chance of being included).
387
+
388
+ get_edges = (
389
+ (lambda node: G.edges(node, keys=True))
390
+ if G.is_multigraph()
391
+ else (lambda node: G.edges(node))
392
+ )
393
+
394
+ # The current_path is a dictionary that maps nodes in the path to the edge that was
395
+ # used to enter that node (instead of a list of edges) because we want both a fast
396
+ # membership test for nodes in the path and the preservation of insertion order.
397
+ current_path = {None: None}
398
+ stack = [iter([(None, source)])]
399
+
400
+ while stack:
401
+ # 1. Try to extend the current path.
402
+ next_edge = next((e for e in stack[-1] if e[1] not in current_path), None)
403
+ if next_edge is None:
404
+ # All edges of the last node in the current path have been explored.
405
+ stack.pop()
406
+ current_path.popitem()
407
+ continue
408
+ previous_node, next_node, *_ = next_edge
409
+
410
+ # 2. Check if we've reached a target.
411
+ if next_node in targets:
412
+ yield (list(current_path.values()) + [next_edge])[2:] # remove dummy edge
413
+
414
+ # 3. Only expand the search through the next node if it makes sense.
415
+ if len(current_path) - 1 < cutoff and (
416
+ targets - current_path.keys() - {next_node}
417
+ ):
418
+ current_path[next_node] = next_edge
419
+ stack.append(iter(get_edges(next_node)))
420
+
421
+
422
+ @not_implemented_for("multigraph")
423
+ @nx._dispatchable(edge_attrs="weight")
424
+ def shortest_simple_paths(G, source, target, weight=None):
425
+ """Generate all simple paths in the graph G from source to target,
426
+ starting from shortest ones.
427
+
428
+ A simple path is a path with no repeated nodes.
429
+
430
+ If a weighted shortest path search is to be used, no negative weights
431
+ are allowed.
432
+
433
+ Parameters
434
+ ----------
435
+ G : NetworkX graph
436
+
437
+ source : node
438
+ Starting node for path
439
+
440
+ target : node
441
+ Ending node for path
442
+
443
+ weight : string or function
444
+ If it is a string, it is the name of the edge attribute to be
445
+ used as a weight.
446
+
447
+ If it is a function, the weight of an edge is the value returned
448
+ by the function. The function must accept exactly three positional
449
+ arguments: the two endpoints of an edge and the dictionary of edge
450
+ attributes for that edge. The function must return a number or None.
451
+ The weight function can be used to hide edges by returning None.
452
+ So ``weight = lambda u, v, d: 1 if d['color']=="red" else None``
453
+ will find the shortest red path.
454
+
455
+ If None all edges are considered to have unit weight. Default
456
+ value None.
457
+
458
+ Returns
459
+ -------
460
+ path_generator: generator
461
+ A generator that produces lists of simple paths, in order from
462
+ shortest to longest.
463
+
464
+ Raises
465
+ ------
466
+ NetworkXNoPath
467
+ If no path exists between source and target.
468
+
469
+ NetworkXError
470
+ If source or target nodes are not in the input graph.
471
+
472
+ NetworkXNotImplemented
473
+ If the input graph is a Multi[Di]Graph.
474
+
475
+ Examples
476
+ --------
477
+
478
+ >>> G = nx.cycle_graph(7)
479
+ >>> paths = list(nx.shortest_simple_paths(G, 0, 3))
480
+ >>> print(paths)
481
+ [[0, 1, 2, 3], [0, 6, 5, 4, 3]]
482
+
483
+ You can use this function to efficiently compute the k shortest/best
484
+ paths between two nodes.
485
+
486
+ >>> from itertools import islice
487
+ >>> def k_shortest_paths(G, source, target, k, weight=None):
488
+ ... return list(
489
+ ... islice(nx.shortest_simple_paths(G, source, target, weight=weight), k)
490
+ ... )
491
+ >>> for path in k_shortest_paths(G, 0, 3, 2):
492
+ ... print(path)
493
+ [0, 1, 2, 3]
494
+ [0, 6, 5, 4, 3]
495
+
496
+ Notes
497
+ -----
498
+ This procedure is based on algorithm by Jin Y. Yen [1]_. Finding
499
+ the first $K$ paths requires $O(KN^3)$ operations.
500
+
501
+ See Also
502
+ --------
503
+ all_shortest_paths
504
+ shortest_path
505
+ all_simple_paths
506
+
507
+ References
508
+ ----------
509
+ .. [1] Jin Y. Yen, "Finding the K Shortest Loopless Paths in a
510
+ Network", Management Science, Vol. 17, No. 11, Theory Series
511
+ (Jul., 1971), pp. 712-716.
512
+
513
+ """
514
+ if source not in G:
515
+ raise nx.NodeNotFound(f"source node {source} not in graph")
516
+
517
+ if target not in G:
518
+ raise nx.NodeNotFound(f"target node {target} not in graph")
519
+
520
+ if weight is None:
521
+ length_func = len
522
+ shortest_path_func = _bidirectional_shortest_path
523
+ else:
524
+ wt = _weight_function(G, weight)
525
+
526
+ def length_func(path):
527
+ return sum(
528
+ wt(u, v, G.get_edge_data(u, v)) for (u, v) in zip(path, path[1:])
529
+ )
530
+
531
+ shortest_path_func = _bidirectional_dijkstra
532
+
533
+ listA = []
534
+ listB = PathBuffer()
535
+ prev_path = None
536
+ while True:
537
+ if not prev_path:
538
+ length, path = shortest_path_func(G, source, target, weight=weight)
539
+ listB.push(length, path)
540
+ else:
541
+ ignore_nodes = set()
542
+ ignore_edges = set()
543
+ for i in range(1, len(prev_path)):
544
+ root = prev_path[:i]
545
+ root_length = length_func(root)
546
+ for path in listA:
547
+ if path[:i] == root:
548
+ ignore_edges.add((path[i - 1], path[i]))
549
+ try:
550
+ length, spur = shortest_path_func(
551
+ G,
552
+ root[-1],
553
+ target,
554
+ ignore_nodes=ignore_nodes,
555
+ ignore_edges=ignore_edges,
556
+ weight=weight,
557
+ )
558
+ path = root[:-1] + spur
559
+ listB.push(root_length + length, path)
560
+ except nx.NetworkXNoPath:
561
+ pass
562
+ ignore_nodes.add(root[-1])
563
+
564
+ if listB:
565
+ path = listB.pop()
566
+ yield path
567
+ listA.append(path)
568
+ prev_path = path
569
+ else:
570
+ break
571
+
572
+
573
+ class PathBuffer:
574
+ def __init__(self):
575
+ self.paths = set()
576
+ self.sortedpaths = []
577
+ self.counter = count()
578
+
579
+ def __len__(self):
580
+ return len(self.sortedpaths)
581
+
582
+ def push(self, cost, path):
583
+ hashable_path = tuple(path)
584
+ if hashable_path not in self.paths:
585
+ heappush(self.sortedpaths, (cost, next(self.counter), path))
586
+ self.paths.add(hashable_path)
587
+
588
+ def pop(self):
589
+ (cost, num, path) = heappop(self.sortedpaths)
590
+ hashable_path = tuple(path)
591
+ self.paths.remove(hashable_path)
592
+ return path
593
+
594
+
595
+ def _bidirectional_shortest_path(
596
+ G, source, target, ignore_nodes=None, ignore_edges=None, weight=None
597
+ ):
598
+ """Returns the shortest path between source and target ignoring
599
+ nodes and edges in the containers ignore_nodes and ignore_edges.
600
+
601
+ This is a custom modification of the standard bidirectional shortest
602
+ path implementation at networkx.algorithms.unweighted
603
+
604
+ Parameters
605
+ ----------
606
+ G : NetworkX graph
607
+
608
+ source : node
609
+ starting node for path
610
+
611
+ target : node
612
+ ending node for path
613
+
614
+ ignore_nodes : container of nodes
615
+ nodes to ignore, optional
616
+
617
+ ignore_edges : container of edges
618
+ edges to ignore, optional
619
+
620
+ weight : None
621
+ This function accepts a weight argument for convenience of
622
+ shortest_simple_paths function. It will be ignored.
623
+
624
+ Returns
625
+ -------
626
+ path: list
627
+ List of nodes in a path from source to target.
628
+
629
+ Raises
630
+ ------
631
+ NetworkXNoPath
632
+ If no path exists between source and target.
633
+
634
+ See Also
635
+ --------
636
+ shortest_path
637
+
638
+ """
639
+ # call helper to do the real work
640
+ results = _bidirectional_pred_succ(G, source, target, ignore_nodes, ignore_edges)
641
+ pred, succ, w = results
642
+
643
+ # build path from pred+w+succ
644
+ path = []
645
+ # from w to target
646
+ while w is not None:
647
+ path.append(w)
648
+ w = succ[w]
649
+ # from source to w
650
+ w = pred[path[0]]
651
+ while w is not None:
652
+ path.insert(0, w)
653
+ w = pred[w]
654
+
655
+ return len(path), path
656
+
657
+
658
+ def _bidirectional_pred_succ(G, source, target, ignore_nodes=None, ignore_edges=None):
659
+ """Bidirectional shortest path helper.
660
+ Returns (pred,succ,w) where
661
+ pred is a dictionary of predecessors from w to the source, and
662
+ succ is a dictionary of successors from w to the target.
663
+ """
664
+ # does BFS from both source and target and meets in the middle
665
+ if ignore_nodes and (source in ignore_nodes or target in ignore_nodes):
666
+ raise nx.NetworkXNoPath(f"No path between {source} and {target}.")
667
+ if target == source:
668
+ return ({target: None}, {source: None}, source)
669
+
670
+ # handle either directed or undirected
671
+ if G.is_directed():
672
+ Gpred = G.predecessors
673
+ Gsucc = G.successors
674
+ else:
675
+ Gpred = G.neighbors
676
+ Gsucc = G.neighbors
677
+
678
+ # support optional nodes filter
679
+ if ignore_nodes:
680
+
681
+ def filter_iter(nodes):
682
+ def iterate(v):
683
+ for w in nodes(v):
684
+ if w not in ignore_nodes:
685
+ yield w
686
+
687
+ return iterate
688
+
689
+ Gpred = filter_iter(Gpred)
690
+ Gsucc = filter_iter(Gsucc)
691
+
692
+ # support optional edges filter
693
+ if ignore_edges:
694
+ if G.is_directed():
695
+
696
+ def filter_pred_iter(pred_iter):
697
+ def iterate(v):
698
+ for w in pred_iter(v):
699
+ if (w, v) not in ignore_edges:
700
+ yield w
701
+
702
+ return iterate
703
+
704
+ def filter_succ_iter(succ_iter):
705
+ def iterate(v):
706
+ for w in succ_iter(v):
707
+ if (v, w) not in ignore_edges:
708
+ yield w
709
+
710
+ return iterate
711
+
712
+ Gpred = filter_pred_iter(Gpred)
713
+ Gsucc = filter_succ_iter(Gsucc)
714
+
715
+ else:
716
+
717
+ def filter_iter(nodes):
718
+ def iterate(v):
719
+ for w in nodes(v):
720
+ if (v, w) not in ignore_edges and (w, v) not in ignore_edges:
721
+ yield w
722
+
723
+ return iterate
724
+
725
+ Gpred = filter_iter(Gpred)
726
+ Gsucc = filter_iter(Gsucc)
727
+
728
+ # predecessor and successors in search
729
+ pred = {source: None}
730
+ succ = {target: None}
731
+
732
+ # initialize fringes, start with forward
733
+ forward_fringe = [source]
734
+ reverse_fringe = [target]
735
+
736
+ while forward_fringe and reverse_fringe:
737
+ if len(forward_fringe) <= len(reverse_fringe):
738
+ this_level = forward_fringe
739
+ forward_fringe = []
740
+ for v in this_level:
741
+ for w in Gsucc(v):
742
+ if w not in pred:
743
+ forward_fringe.append(w)
744
+ pred[w] = v
745
+ if w in succ:
746
+ # found path
747
+ return pred, succ, w
748
+ else:
749
+ this_level = reverse_fringe
750
+ reverse_fringe = []
751
+ for v in this_level:
752
+ for w in Gpred(v):
753
+ if w not in succ:
754
+ succ[w] = v
755
+ reverse_fringe.append(w)
756
+ if w in pred:
757
+ # found path
758
+ return pred, succ, w
759
+
760
+ raise nx.NetworkXNoPath(f"No path between {source} and {target}.")
761
+
762
+
763
+ def _bidirectional_dijkstra(
764
+ G, source, target, weight="weight", ignore_nodes=None, ignore_edges=None
765
+ ):
766
+ """Dijkstra's algorithm for shortest paths using bidirectional search.
767
+
768
+ This function returns the shortest path between source and target
769
+ ignoring nodes and edges in the containers ignore_nodes and
770
+ ignore_edges.
771
+
772
+ This is a custom modification of the standard Dijkstra bidirectional
773
+ shortest path implementation at networkx.algorithms.weighted
774
+
775
+ Parameters
776
+ ----------
777
+ G : NetworkX graph
778
+
779
+ source : node
780
+ Starting node.
781
+
782
+ target : node
783
+ Ending node.
784
+
785
+ weight: string, function, optional (default='weight')
786
+ Edge data key or weight function corresponding to the edge weight
787
+ If this is a function, the weight of an edge is the value
788
+ returned by the function. The function must accept exactly three
789
+ positional arguments: the two endpoints of an edge and the
790
+ dictionary of edge attributes for that edge. The function must
791
+ return a number or None to indicate a hidden edge.
792
+
793
+ ignore_nodes : container of nodes
794
+ nodes to ignore, optional
795
+
796
+ ignore_edges : container of edges
797
+ edges to ignore, optional
798
+
799
+ Returns
800
+ -------
801
+ length : number
802
+ Shortest path length.
803
+
804
+ Returns a tuple of two dictionaries keyed by node.
805
+ The first dictionary stores distance from the source.
806
+ The second stores the path from the source to that node.
807
+
808
+ Raises
809
+ ------
810
+ NetworkXNoPath
811
+ If no path exists between source and target.
812
+
813
+ Notes
814
+ -----
815
+ Edge weight attributes must be numerical.
816
+ Distances are calculated as sums of weighted edges traversed.
817
+
818
+ The weight function can be used to hide edges by returning None.
819
+ So ``weight = lambda u, v, d: 1 if d['color']=="red" else None``
820
+ will find the shortest red path.
821
+
822
+ In practice bidirectional Dijkstra is much more than twice as fast as
823
+ ordinary Dijkstra.
824
+
825
+ Ordinary Dijkstra expands nodes in a sphere-like manner from the
826
+ source. The radius of this sphere will eventually be the length
827
+ of the shortest path. Bidirectional Dijkstra will expand nodes
828
+ from both the source and the target, making two spheres of half
829
+ this radius. Volume of the first sphere is pi*r*r while the
830
+ others are 2*pi*r/2*r/2, making up half the volume.
831
+
832
+ This algorithm is not guaranteed to work if edge weights
833
+ are negative or are floating point numbers
834
+ (overflows and roundoff errors can cause problems).
835
+
836
+ See Also
837
+ --------
838
+ shortest_path
839
+ shortest_path_length
840
+ """
841
+ if ignore_nodes and (source in ignore_nodes or target in ignore_nodes):
842
+ raise nx.NetworkXNoPath(f"No path between {source} and {target}.")
843
+ if source == target:
844
+ if source not in G:
845
+ raise nx.NodeNotFound(f"Node {source} not in graph")
846
+ return (0, [source])
847
+
848
+ # handle either directed or undirected
849
+ if G.is_directed():
850
+ Gpred = G.predecessors
851
+ Gsucc = G.successors
852
+ else:
853
+ Gpred = G.neighbors
854
+ Gsucc = G.neighbors
855
+
856
+ # support optional nodes filter
857
+ if ignore_nodes:
858
+
859
+ def filter_iter(nodes):
860
+ def iterate(v):
861
+ for w in nodes(v):
862
+ if w not in ignore_nodes:
863
+ yield w
864
+
865
+ return iterate
866
+
867
+ Gpred = filter_iter(Gpred)
868
+ Gsucc = filter_iter(Gsucc)
869
+
870
+ # support optional edges filter
871
+ if ignore_edges:
872
+ if G.is_directed():
873
+
874
+ def filter_pred_iter(pred_iter):
875
+ def iterate(v):
876
+ for w in pred_iter(v):
877
+ if (w, v) not in ignore_edges:
878
+ yield w
879
+
880
+ return iterate
881
+
882
+ def filter_succ_iter(succ_iter):
883
+ def iterate(v):
884
+ for w in succ_iter(v):
885
+ if (v, w) not in ignore_edges:
886
+ yield w
887
+
888
+ return iterate
889
+
890
+ Gpred = filter_pred_iter(Gpred)
891
+ Gsucc = filter_succ_iter(Gsucc)
892
+
893
+ else:
894
+
895
+ def filter_iter(nodes):
896
+ def iterate(v):
897
+ for w in nodes(v):
898
+ if (v, w) not in ignore_edges and (w, v) not in ignore_edges:
899
+ yield w
900
+
901
+ return iterate
902
+
903
+ Gpred = filter_iter(Gpred)
904
+ Gsucc = filter_iter(Gsucc)
905
+
906
+ wt = _weight_function(G, weight)
907
+ # Init: Forward Backward
908
+ dists = [{}, {}] # dictionary of final distances
909
+ paths = [{source: [source]}, {target: [target]}] # dictionary of paths
910
+ fringe = [[], []] # heap of (distance, node) tuples for
911
+ # extracting next node to expand
912
+ seen = [{source: 0}, {target: 0}] # dictionary of distances to
913
+ # nodes seen
914
+ c = count()
915
+ # initialize fringe heap
916
+ heappush(fringe[0], (0, next(c), source))
917
+ heappush(fringe[1], (0, next(c), target))
918
+ # neighs for extracting correct neighbor information
919
+ neighs = [Gsucc, Gpred]
920
+ # variables to hold shortest discovered path
921
+ # finaldist = 1e30000
922
+ finalpath = []
923
+ dir = 1
924
+ while fringe[0] and fringe[1]:
925
+ # choose direction
926
+ # dir == 0 is forward direction and dir == 1 is back
927
+ dir = 1 - dir
928
+ # extract closest to expand
929
+ (dist, _, v) = heappop(fringe[dir])
930
+ if v in dists[dir]:
931
+ # Shortest path to v has already been found
932
+ continue
933
+ # update distance
934
+ dists[dir][v] = dist # equal to seen[dir][v]
935
+ if v in dists[1 - dir]:
936
+ # if we have scanned v in both directions we are done
937
+ # we have now discovered the shortest path
938
+ return (finaldist, finalpath)
939
+
940
+ for w in neighs[dir](v):
941
+ if dir == 0: # forward
942
+ minweight = wt(v, w, G.get_edge_data(v, w))
943
+ else: # back, must remember to change v,w->w,v
944
+ minweight = wt(w, v, G.get_edge_data(w, v))
945
+ if minweight is None:
946
+ continue
947
+ vwLength = dists[dir][v] + minweight
948
+
949
+ if w in dists[dir]:
950
+ if vwLength < dists[dir][w]:
951
+ raise ValueError("Contradictory paths found: negative weights?")
952
+ elif w not in seen[dir] or vwLength < seen[dir][w]:
953
+ # relaxing
954
+ seen[dir][w] = vwLength
955
+ heappush(fringe[dir], (vwLength, next(c), w))
956
+ paths[dir][w] = paths[dir][v] + [w]
957
+ if w in seen[0] and w in seen[1]:
958
+ # see if this path is better than the already
959
+ # discovered shortest path
960
+ totaldist = seen[0][w] + seen[1][w]
961
+ if finalpath == [] or finaldist > totaldist:
962
+ finaldist = totaldist
963
+ revpath = paths[1][w][:]
964
+ revpath.reverse()
965
+ finalpath = paths[0][w] + revpath[1:]
966
+ raise nx.NetworkXNoPath(f"No path between {source} and {target}.")