okstra 0.130.4 → 0.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/README.md +0 -1
  2. package/docs/architecture.md +2 -2
  3. package/docs/cli.md +1 -1
  4. package/docs/for-ai/README.md +0 -2
  5. package/docs/for-ai/skills/okstra-run.md +13 -2
  6. package/docs/for-ai/skills/okstra-setup.md +4 -1
  7. package/docs/project-structure-overview.md +5 -4
  8. package/docs/task-process/implementation-planning.md +13 -0
  9. package/docs/task-process/implementation.md +17 -2
  10. package/package.json +1 -1
  11. package/runtime/BUILD.json +2 -2
  12. package/runtime/agents/workers/report-writer-worker.md +7 -0
  13. package/runtime/bin/lib/okstra/usage.sh +4 -4
  14. package/runtime/prompts/lead/okstra-lead-contract.md +2 -2
  15. package/runtime/prompts/lead/plan-body-verification.md +26 -5
  16. package/runtime/prompts/lead/report-writer.md +6 -2
  17. package/runtime/prompts/profiles/_common-contract.md +2 -1
  18. package/runtime/prompts/profiles/_implementation-deliverable.md +6 -1
  19. package/runtime/prompts/profiles/_implementation-executor.md +2 -2
  20. package/runtime/prompts/profiles/_implementation-verifier.md +33 -10
  21. package/runtime/prompts/profiles/final-verification.md +21 -6
  22. package/runtime/prompts/profiles/implementation-planning.md +16 -4
  23. package/runtime/python/okstra_ctl/codex_dispatch.py +31 -0
  24. package/runtime/python/okstra_ctl/conformance.py +49 -11
  25. package/runtime/python/okstra_ctl/report_finalize.py +52 -1
  26. package/runtime/python/okstra_ctl/run.py +15 -3
  27. package/runtime/python/okstra_ctl/worker_prompt_contract.py +14 -6
  28. package/runtime/python/okstra_ctl/worker_prompt_policy.py +19 -1
  29. package/runtime/python/okstra_vendor/__init__.py +0 -44
  30. package/runtime/schemas/final-report-v1.0.schema.json +99 -5
  31. package/runtime/skills/okstra-run/SKILL.md +11 -4
  32. package/runtime/skills/okstra-setup/SKILL.md +3 -2
  33. package/runtime/skills/okstra-setup/references/project-config.md +16 -7
  34. package/runtime/templates/reports/final-report.template.md +15 -9
  35. package/runtime/templates/reports/i18n/en.json +1 -0
  36. package/runtime/templates/reports/i18n/ko.json +1 -0
  37. package/runtime/validators/lib/fixtures.sh +6 -0
  38. package/runtime/validators/validate-run.py +1722 -98
  39. package/src/cli-registry.mjs +0 -7
  40. package/src/commands/lifecycle/doctor.mjs +0 -9
  41. package/src/lib/skill-catalog.mjs +0 -1
  42. package/docs/for-ai/skills/okstra-graphify.md +0 -64
  43. package/runtime/python/okstra_ctl/graphify_cmd.py +0 -225
  44. package/runtime/python/okstra_vendor/graphify/.vendored-version +0 -1
  45. package/runtime/python/okstra_vendor/graphify/__init__.py +0 -28
  46. package/runtime/python/okstra_vendor/graphify/__main__.py +0 -1371
  47. package/runtime/python/okstra_vendor/graphify/analyze.py +0 -540
  48. package/runtime/python/okstra_vendor/graphify/benchmark.py +0 -129
  49. package/runtime/python/okstra_vendor/graphify/build.py +0 -107
  50. package/runtime/python/okstra_vendor/graphify/cache.py +0 -169
  51. package/runtime/python/okstra_vendor/graphify/cluster.py +0 -137
  52. package/runtime/python/okstra_vendor/graphify/detect.py +0 -510
  53. package/runtime/python/okstra_vendor/graphify/export.py +0 -1014
  54. package/runtime/python/okstra_vendor/graphify/extract.py +0 -3277
  55. package/runtime/python/okstra_vendor/graphify/hooks.py +0 -220
  56. package/runtime/python/okstra_vendor/graphify/ingest.py +0 -297
  57. package/runtime/python/okstra_vendor/graphify/manifest.py +0 -4
  58. package/runtime/python/okstra_vendor/graphify/report.py +0 -175
  59. package/runtime/python/okstra_vendor/graphify/security.py +0 -203
  60. package/runtime/python/okstra_vendor/graphify/serve.py +0 -373
  61. package/runtime/python/okstra_vendor/graphify/skill-aider.md +0 -1184
  62. package/runtime/python/okstra_vendor/graphify/skill-claw.md +0 -1184
  63. package/runtime/python/okstra_vendor/graphify/skill-codex.md +0 -1242
  64. package/runtime/python/okstra_vendor/graphify/skill-copilot.md +0 -1268
  65. package/runtime/python/okstra_vendor/graphify/skill-droid.md +0 -1239
  66. package/runtime/python/okstra_vendor/graphify/skill-kiro.md +0 -1183
  67. package/runtime/python/okstra_vendor/graphify/skill-opencode.md +0 -1238
  68. package/runtime/python/okstra_vendor/graphify/skill-trae.md +0 -1208
  69. package/runtime/python/okstra_vendor/graphify/skill-vscode.md +0 -253
  70. package/runtime/python/okstra_vendor/graphify/skill-windows.md +0 -1245
  71. package/runtime/python/okstra_vendor/graphify/skill.md +0 -1319
  72. package/runtime/python/okstra_vendor/graphify/transcribe.py +0 -182
  73. package/runtime/python/okstra_vendor/graphify/validate.py +0 -72
  74. package/runtime/python/okstra_vendor/graphify/watch.py +0 -188
  75. package/runtime/python/okstra_vendor/graphify/wiki.py +0 -214
  76. package/runtime/python/okstra_vendor/networkx/__init__.py +0 -62
  77. package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +0 -134
  78. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +0 -26
  79. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +0 -259
  80. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +0 -71
  81. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +0 -412
  82. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +0 -396
  83. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +0 -150
  84. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +0 -149
  85. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +0 -369
  86. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +0 -44
  87. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +0 -143
  88. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +0 -53
  89. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +0 -265
  90. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +0 -1508
  91. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +0 -255
  92. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +0 -83
  93. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +0 -5
  94. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +0 -122
  95. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +0 -302
  96. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +0 -255
  97. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +0 -160
  98. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +0 -127
  99. package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +0 -164
  100. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +0 -88
  101. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +0 -322
  102. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +0 -290
  103. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +0 -289
  104. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +0 -57
  105. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +0 -360
  106. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +0 -105
  107. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +0 -603
  108. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +0 -316
  109. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +0 -590
  110. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +0 -232
  111. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +0 -526
  112. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +0 -112
  113. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +0 -69
  114. package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +0 -168
  115. package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +0 -205
  116. package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +0 -164
  117. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +0 -20
  118. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +0 -591
  119. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +0 -236
  120. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +0 -282
  121. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +0 -364
  122. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +0 -227
  123. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +0 -96
  124. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +0 -150
  125. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +0 -107
  126. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +0 -357
  127. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +0 -130
  128. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +0 -787
  129. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +0 -88
  130. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +0 -331
  131. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +0 -150
  132. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +0 -200
  133. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +0 -128
  134. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +0 -209
  135. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +0 -141
  136. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +0 -361
  137. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +0 -181
  138. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +0 -95
  139. package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +0 -172
  140. package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +0 -443
  141. package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +0 -818
  142. package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +0 -732
  143. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +0 -4
  144. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +0 -505
  145. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +0 -565
  146. package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +0 -163
  147. package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +0 -28
  148. package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +0 -153
  149. package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +0 -354
  150. package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +0 -171
  151. package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +0 -30
  152. package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +0 -216
  153. package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +0 -79
  154. package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +0 -338
  155. package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +0 -162
  156. package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +0 -220
  157. package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +0 -384
  158. package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +0 -227
  159. package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +0 -452
  160. package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +0 -347
  161. package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +0 -6
  162. package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +0 -115
  163. package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +0 -394
  164. package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +0 -282
  165. package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +0 -71
  166. package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +0 -359
  167. package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +0 -196
  168. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +0 -11
  169. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +0 -811
  170. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +0 -616
  171. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +0 -408
  172. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +0 -1270
  173. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +0 -592
  174. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +0 -220
  175. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +0 -235
  176. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +0 -152
  177. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +0 -88
  178. package/runtime/python/okstra_vendor/networkx/algorithms/core.py +0 -588
  179. package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +0 -142
  180. package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +0 -416
  181. package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +0 -1234
  182. package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +0 -677
  183. package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +0 -1392
  184. package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +0 -1095
  185. package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +0 -272
  186. package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +0 -142
  187. package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +0 -268
  188. package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +0 -167
  189. package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +0 -470
  190. package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +0 -11
  191. package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +0 -370
  192. package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +0 -407
  193. package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +0 -238
  194. package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +0 -241
  195. package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +0 -178
  196. package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +0 -611
  197. package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +0 -356
  198. package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +0 -662
  199. package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +0 -425
  200. package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +0 -300
  201. package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +0 -194
  202. package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +0 -435
  203. package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +0 -483
  204. package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +0 -57
  205. package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +0 -196
  206. package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +0 -107
  207. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +0 -7
  208. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +0 -1306
  209. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +0 -336
  210. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +0 -1262
  211. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +0 -352
  212. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +0 -308
  213. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +0 -264
  214. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +0 -1102
  215. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +0 -192
  216. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +0 -2
  217. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +0 -337
  218. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +0 -498
  219. package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +0 -687
  220. package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +0 -280
  221. package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +0 -1148
  222. package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +0 -27
  223. package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +0 -738
  224. package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +0 -78
  225. package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +0 -59
  226. package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +0 -219
  227. package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +0 -155
  228. package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +0 -4
  229. package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +0 -324
  230. package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +0 -468
  231. package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +0 -633
  232. package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +0 -77
  233. package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +0 -73
  234. package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +0 -464
  235. package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +0 -1463
  236. package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +0 -306
  237. package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +0 -98
  238. package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +0 -167
  239. package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +0 -138
  240. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +0 -5
  241. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +0 -239
  242. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +0 -264
  243. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +0 -716
  244. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +0 -625
  245. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +0 -2542
  246. package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +0 -2107
  247. package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +0 -966
  248. package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +0 -404
  249. package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +0 -30
  250. package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +0 -296
  251. package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +0 -374
  252. package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +0 -564
  253. package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +0 -406
  254. package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +0 -981
  255. package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +0 -142
  256. package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +0 -406
  257. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +0 -5
  258. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +0 -90
  259. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +0 -576
  260. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +0 -529
  261. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +0 -185
  262. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +0 -182
  263. package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +0 -7
  264. package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +0 -1042
  265. package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +0 -413
  266. package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +0 -88
  267. package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +0 -219
  268. package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +0 -1281
  269. package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +0 -106
  270. package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +0 -273
  271. package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +0 -500
  272. package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +0 -76
  273. package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +0 -86
  274. package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +0 -77
  275. package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +0 -278
  276. package/runtime/python/okstra_vendor/networkx/classes/__init__.py +0 -13
  277. package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +0 -435
  278. package/runtime/python/okstra_vendor/networkx/classes/digraph.py +0 -1363
  279. package/runtime/python/okstra_vendor/networkx/classes/filters.py +0 -95
  280. package/runtime/python/okstra_vendor/networkx/classes/function.py +0 -1549
  281. package/runtime/python/okstra_vendor/networkx/classes/graph.py +0 -2082
  282. package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +0 -269
  283. package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +0 -977
  284. package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +0 -1294
  285. package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +0 -1447
  286. package/runtime/python/okstra_vendor/networkx/convert.py +0 -502
  287. package/runtime/python/okstra_vendor/networkx/convert_matrix.py +0 -1314
  288. package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +0 -7
  289. package/runtime/python/okstra_vendor/networkx/drawing/layout.py +0 -2036
  290. package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +0 -470
  291. package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +0 -570
  292. package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +0 -361
  293. package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +0 -2978
  294. package/runtime/python/okstra_vendor/networkx/exception.py +0 -131
  295. package/runtime/python/okstra_vendor/networkx/generators/__init__.py +0 -34
  296. package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
  297. package/runtime/python/okstra_vendor/networkx/generators/atlas.py +0 -227
  298. package/runtime/python/okstra_vendor/networkx/generators/classic.py +0 -1091
  299. package/runtime/python/okstra_vendor/networkx/generators/cographs.py +0 -68
  300. package/runtime/python/okstra_vendor/networkx/generators/community.py +0 -1070
  301. package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +0 -886
  302. package/runtime/python/okstra_vendor/networkx/generators/directed.py +0 -572
  303. package/runtime/python/okstra_vendor/networkx/generators/duplication.py +0 -174
  304. package/runtime/python/okstra_vendor/networkx/generators/ego.py +0 -66
  305. package/runtime/python/okstra_vendor/networkx/generators/expanders.py +0 -499
  306. package/runtime/python/okstra_vendor/networkx/generators/geometric.py +0 -1037
  307. package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +0 -163
  308. package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +0 -443
  309. package/runtime/python/okstra_vendor/networkx/generators/intersection.py +0 -125
  310. package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +0 -70
  311. package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +0 -664
  312. package/runtime/python/okstra_vendor/networkx/generators/lattice.py +0 -405
  313. package/runtime/python/okstra_vendor/networkx/generators/line.py +0 -501
  314. package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +0 -110
  315. package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +0 -259
  316. package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +0 -117
  317. package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +0 -1416
  318. package/runtime/python/okstra_vendor/networkx/generators/small.py +0 -1070
  319. package/runtime/python/okstra_vendor/networkx/generators/social.py +0 -554
  320. package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +0 -120
  321. package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +0 -54
  322. package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +0 -131
  323. package/runtime/python/okstra_vendor/networkx/generators/time_series.py +0 -74
  324. package/runtime/python/okstra_vendor/networkx/generators/trees.py +0 -1070
  325. package/runtime/python/okstra_vendor/networkx/generators/triads.py +0 -94
  326. package/runtime/python/okstra_vendor/networkx/lazy_imports.py +0 -188
  327. package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +0 -13
  328. package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +0 -650
  329. package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +0 -466
  330. package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +0 -77
  331. package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +0 -168
  332. package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +0 -512
  333. package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +0 -166
  334. package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +0 -186
  335. package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +0 -17
  336. package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +0 -330
  337. package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +0 -489
  338. package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +0 -1084
  339. package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +0 -879
  340. package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +0 -427
  341. package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +0 -1053
  342. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +0 -19
  343. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +0 -156
  344. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +0 -190
  345. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +0 -261
  346. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +0 -137
  347. package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +0 -108
  348. package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +0 -393
  349. package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +0 -113
  350. package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +0 -286
  351. package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +0 -379
  352. package/runtime/python/okstra_vendor/networkx/readwrite/text.py +0 -851
  353. package/runtime/python/okstra_vendor/networkx/relabel.py +0 -285
  354. package/runtime/python/okstra_vendor/networkx/utils/__init__.py +0 -8
  355. package/runtime/python/okstra_vendor/networkx/utils/backends.py +0 -2171
  356. package/runtime/python/okstra_vendor/networkx/utils/configs.py +0 -396
  357. package/runtime/python/okstra_vendor/networkx/utils/decorators.py +0 -1233
  358. package/runtime/python/okstra_vendor/networkx/utils/heaps.py +0 -338
  359. package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +0 -297
  360. package/runtime/python/okstra_vendor/networkx/utils/misc.py +0 -703
  361. package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +0 -198
  362. package/runtime/python/okstra_vendor/networkx/utils/rcm.py +0 -159
  363. package/runtime/python/okstra_vendor/networkx/utils/union_find.py +0 -106
  364. package/runtime/skills/okstra-graphify/SKILL.md +0 -169
  365. package/src/commands/graphify.mjs +0 -32
@@ -1,364 +0,0 @@
1
- """Current-flow betweenness centrality measures."""
2
-
3
- import networkx as nx
4
- from networkx.algorithms.centrality.flow_matrix import (
5
- CGInverseLaplacian,
6
- FullInverseLaplacian,
7
- SuperLUInverseLaplacian,
8
- flow_matrix_row,
9
- )
10
- from networkx.utils import (
11
- not_implemented_for,
12
- py_random_state,
13
- reverse_cuthill_mckee_ordering,
14
- )
15
-
16
- __all__ = [
17
- "current_flow_betweenness_centrality",
18
- "approximate_current_flow_betweenness_centrality",
19
- "edge_current_flow_betweenness_centrality",
20
- ]
21
-
22
-
23
- @not_implemented_for("directed")
24
- @py_random_state("seed")
25
- @nx._dispatchable(edge_attrs="weight")
26
- def approximate_current_flow_betweenness_centrality(
27
- G,
28
- normalized=True,
29
- weight=None,
30
- dtype=float,
31
- solver="full",
32
- epsilon=0.5,
33
- kmax=10000,
34
- seed=None,
35
- *,
36
- sample_weight=1,
37
- ):
38
- r"""Compute the approximate current-flow betweenness centrality for nodes.
39
-
40
- Approximates the current-flow betweenness centrality within absolute
41
- error of epsilon with high probability [1]_.
42
-
43
-
44
- Parameters
45
- ----------
46
- G : graph
47
- A NetworkX graph
48
-
49
- normalized : bool, optional (default=True)
50
- If True the betweenness values are normalized by 2/[(n-1)(n-2)] where
51
- n is the number of nodes in G.
52
-
53
- weight : string or None, optional (default=None)
54
- Key for edge data used as the edge weight.
55
- If None, then use 1 as each edge weight.
56
- The weight reflects the capacity or the strength of the
57
- edge.
58
-
59
- dtype : data type (float)
60
- Default data type for internal matrices.
61
- Set to np.float32 for lower memory consumption.
62
-
63
- solver : string (default='full')
64
- Type of linear solver to use for computing the flow matrix.
65
- Options are "full" (uses most memory), "lu" (recommended), and
66
- "cg" (uses least memory).
67
-
68
- epsilon: float
69
- Absolute error tolerance. Note that smaller values of `epsilon` lead to
70
- higher numbers of sample pairs (``k``) and thus more computation time. The number
71
- of sample pairs is approximately ``(c/epsilon)^2 * log(n)`` where ``n`` is the
72
- number of nodes.
73
-
74
- kmax: int
75
- Maximum number of sample node pairs to use for approximation.
76
-
77
- sample_weight : float (default=1)
78
- Multiplicative factor for the number of sample node pairs used in approximation.
79
- Higher values may improve accuracy at the expense of increased computation time.
80
-
81
- seed : integer, random_state, or None (default)
82
- Indicator of random number generation state.
83
- See :ref:`Randomness<randomness>`.
84
-
85
- Returns
86
- -------
87
- nodes : dictionary
88
- Dictionary of nodes with betweenness centrality as the value.
89
-
90
- See Also
91
- --------
92
- current_flow_betweenness_centrality
93
-
94
- Notes
95
- -----
96
- The running time is $O((1/\epsilon^2)m{\sqrt k} \log n)$
97
- and the space required is $O(m)$ for $n$ nodes and $m$ edges.
98
-
99
- If the edges have a 'weight' attribute they will be used as
100
- weights in this algorithm. Unspecified weights are set to 1.
101
-
102
- References
103
- ----------
104
- .. [1] Ulrik Brandes and Daniel Fleischer:
105
- Centrality Measures Based on Current Flow.
106
- Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS '05).
107
- LNCS 3404, pp. 533-544. Springer-Verlag, 2005.
108
- https://doi.org/10.1007/978-3-540-31856-9_44
109
- """
110
- import numpy as np
111
-
112
- if not nx.is_connected(G):
113
- raise nx.NetworkXError("Graph not connected.")
114
-
115
- n = G.number_of_nodes()
116
-
117
- # For small graphs (n < 3), betweenness centrality is always 0 for all nodes
118
- # since no node can be "between" any pair of other nodes
119
- if n < 3:
120
- return dict.fromkeys(G, 0.0)
121
-
122
- if epsilon <= 0:
123
- raise nx.NetworkXError(f"Epsilon must be positive. Got {epsilon=}.")
124
-
125
- if sample_weight <= 0:
126
- raise nx.NetworkXError(f"Sample weight must be positive. Got {sample_weight=}.")
127
-
128
- nb = (n - 1.0) * (n - 2.0) # normalization factor
129
- cstar = n * (n - 1) / nb
130
- k = int(sample_weight * np.ceil((cstar / epsilon) ** 2 * np.log(n)))
131
- if k > kmax:
132
- msg = f"Number random pairs k>kmax ({k}>{kmax}) "
133
- raise nx.NetworkXError(msg, "Increase kmax or epsilon")
134
-
135
- solvername = {
136
- "full": FullInverseLaplacian,
137
- "lu": SuperLUInverseLaplacian,
138
- "cg": CGInverseLaplacian,
139
- }
140
- ordering = list(reverse_cuthill_mckee_ordering(G))
141
- # make a copy with integer labels according to rcm ordering
142
- # this could be done without a copy if we really wanted to
143
- H = nx.relabel_nodes(G, dict(zip(ordering, range(n))))
144
- L = nx.laplacian_matrix(H, nodelist=range(n), weight=weight).asformat("csc")
145
- L = L.astype(dtype)
146
- C = solvername[solver](L, dtype=dtype) # initialize solver
147
- betweenness = dict.fromkeys(H, 0.0)
148
- cstar2k = cstar / (2 * k)
149
- for _ in range(k):
150
- s, t = pair = seed.sample(range(n), 2)
151
- b = np.zeros(n, dtype=dtype)
152
- b[s] = 1
153
- b[t] = -1
154
- p = C.solve(b)
155
- for v in H:
156
- if v in pair:
157
- continue
158
- for nbr in H[v]:
159
- w = H[v][nbr].get(weight, 1.0)
160
- betweenness[v] += float(w * np.abs(p[v] - p[nbr]) * cstar2k)
161
- if normalized:
162
- factor = 1.0
163
- else:
164
- factor = nb / 2.0
165
- # remap to original node names and "unnormalize" if required
166
- return {ordering[k]: v * factor for k, v in betweenness.items()}
167
-
168
-
169
- @not_implemented_for("directed")
170
- @nx._dispatchable(edge_attrs="weight")
171
- def current_flow_betweenness_centrality(
172
- G, normalized=True, weight=None, dtype=float, solver="full"
173
- ):
174
- r"""Compute current-flow betweenness centrality for nodes.
175
-
176
- Current-flow betweenness centrality uses an electrical current
177
- model for information spreading in contrast to betweenness
178
- centrality which uses shortest paths.
179
-
180
- Current-flow betweenness centrality is also known as
181
- random-walk betweenness centrality [2]_.
182
-
183
- Parameters
184
- ----------
185
- G : graph
186
- A NetworkX graph
187
-
188
- normalized : bool, optional (default=True)
189
- If True the betweenness values are normalized by 2/[(n-1)(n-2)] where
190
- n is the number of nodes in G.
191
-
192
- weight : string or None, optional (default=None)
193
- Key for edge data used as the edge weight.
194
- If None, then use 1 as each edge weight.
195
- The weight reflects the capacity or the strength of the
196
- edge.
197
-
198
- dtype : data type (float)
199
- Default data type for internal matrices.
200
- Set to np.float32 for lower memory consumption.
201
-
202
- solver : string (default='full')
203
- Type of linear solver to use for computing the flow matrix.
204
- Options are "full" (uses most memory), "lu" (recommended), and
205
- "cg" (uses least memory).
206
-
207
- Returns
208
- -------
209
- nodes : dictionary
210
- Dictionary of nodes with betweenness centrality as the value.
211
-
212
- See Also
213
- --------
214
- approximate_current_flow_betweenness_centrality
215
- betweenness_centrality
216
- edge_betweenness_centrality
217
- edge_current_flow_betweenness_centrality
218
-
219
- Notes
220
- -----
221
- Current-flow betweenness can be computed in $O(I(n-1)+mn \log n)$
222
- time [1]_, where $I(n-1)$ is the time needed to compute the
223
- inverse Laplacian. For a full matrix this is $O(n^3)$ but using
224
- sparse methods you can achieve $O(nm{\sqrt k})$ where $k$ is the
225
- Laplacian matrix condition number.
226
-
227
- The space required is $O(nw)$ where $w$ is the width of the sparse
228
- Laplacian matrix. Worse case is $w=n$ for $O(n^2)$.
229
-
230
- If the edges have a 'weight' attribute they will be used as
231
- weights in this algorithm. Unspecified weights are set to 1.
232
-
233
- References
234
- ----------
235
- .. [1] Centrality Measures Based on Current Flow.
236
- Ulrik Brandes and Daniel Fleischer,
237
- Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS '05).
238
- LNCS 3404, pp. 533-544. Springer-Verlag, 2005.
239
- https://doi.org/10.1007/978-3-540-31856-9_44
240
-
241
- .. [2] A measure of betweenness centrality based on random walks,
242
- M. E. J. Newman, Social Networks 27, 39-54 (2005).
243
- """
244
- if not nx.is_connected(G):
245
- raise nx.NetworkXError("Graph not connected.")
246
- N = G.number_of_nodes()
247
- ordering = list(reverse_cuthill_mckee_ordering(G))
248
- # make a copy with integer labels according to rcm ordering
249
- # this could be done without a copy if we really wanted to
250
- H = nx.relabel_nodes(G, dict(zip(ordering, range(N))))
251
- betweenness = dict.fromkeys(H, 0.0) # b[n]=0 for n in H
252
- for row, (s, t) in flow_matrix_row(H, weight=weight, dtype=dtype, solver=solver):
253
- pos = dict(zip(row.argsort()[::-1], range(N)))
254
- for i in range(N):
255
- betweenness[s] += (i - pos[i]) * row.item(i)
256
- betweenness[t] += (N - i - 1 - pos[i]) * row.item(i)
257
- if normalized:
258
- nb = (N - 1.0) * (N - 2.0) # normalization factor
259
- else:
260
- nb = 2.0
261
- return {ordering[n]: (b - n) * 2.0 / nb for n, b in betweenness.items()}
262
-
263
-
264
- @not_implemented_for("directed")
265
- @nx._dispatchable(edge_attrs="weight")
266
- def edge_current_flow_betweenness_centrality(
267
- G, normalized=True, weight=None, dtype=float, solver="full"
268
- ):
269
- r"""Compute current-flow betweenness centrality for edges.
270
-
271
- Current-flow betweenness centrality uses an electrical current
272
- model for information spreading in contrast to betweenness
273
- centrality which uses shortest paths.
274
-
275
- Current-flow betweenness centrality is also known as
276
- random-walk betweenness centrality [2]_.
277
-
278
- Parameters
279
- ----------
280
- G : graph
281
- A NetworkX graph
282
-
283
- normalized : bool, optional (default=True)
284
- If True the betweenness values are normalized by 2/[(n-1)(n-2)] where
285
- n is the number of nodes in G.
286
-
287
- weight : string or None, optional (default=None)
288
- Key for edge data used as the edge weight.
289
- If None, then use 1 as each edge weight.
290
- The weight reflects the capacity or the strength of the
291
- edge.
292
-
293
- dtype : data type (default=float)
294
- Default data type for internal matrices.
295
- Set to np.float32 for lower memory consumption.
296
-
297
- solver : string (default='full')
298
- Type of linear solver to use for computing the flow matrix.
299
- Options are "full" (uses most memory), "lu" (recommended), and
300
- "cg" (uses least memory).
301
-
302
- Returns
303
- -------
304
- nodes : dictionary
305
- Dictionary of edge tuples with betweenness centrality as the value.
306
-
307
- Raises
308
- ------
309
- NetworkXError
310
- The algorithm does not support DiGraphs.
311
- If the input graph is an instance of DiGraph class, NetworkXError
312
- is raised.
313
-
314
- See Also
315
- --------
316
- betweenness_centrality
317
- edge_betweenness_centrality
318
- current_flow_betweenness_centrality
319
-
320
- Notes
321
- -----
322
- Current-flow betweenness can be computed in $O(I(n-1)+mn \log n)$
323
- time [1]_, where $I(n-1)$ is the time needed to compute the
324
- inverse Laplacian. For a full matrix this is $O(n^3)$ but using
325
- sparse methods you can achieve $O(nm{\sqrt k})$ where $k$ is the
326
- Laplacian matrix condition number.
327
-
328
- The space required is $O(nw)$ where $w$ is the width of the sparse
329
- Laplacian matrix. Worse case is $w=n$ for $O(n^2)$.
330
-
331
- If the edges have a 'weight' attribute they will be used as
332
- weights in this algorithm. Unspecified weights are set to 1.
333
-
334
- References
335
- ----------
336
- .. [1] Centrality Measures Based on Current Flow.
337
- Ulrik Brandes and Daniel Fleischer,
338
- Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS '05).
339
- LNCS 3404, pp. 533-544. Springer-Verlag, 2005.
340
- https://doi.org/10.1007/978-3-540-31856-9_44
341
-
342
- .. [2] A measure of betweenness centrality based on random walks,
343
- M. E. J. Newman, Social Networks 27, 39-54 (2005).
344
- """
345
- if not nx.is_connected(G):
346
- raise nx.NetworkXError("Graph not connected.")
347
- N = G.number_of_nodes()
348
- ordering = list(reverse_cuthill_mckee_ordering(G))
349
- # make a copy with integer labels according to rcm ordering
350
- # this could be done without a copy if we really wanted to
351
- H = nx.relabel_nodes(G, dict(zip(ordering, range(N))))
352
- edges = (tuple(sorted((u, v))) for u, v in H.edges())
353
- betweenness = dict.fromkeys(edges, 0.0)
354
- if normalized:
355
- nb = (N - 1.0) * (N - 2.0) # normalization factor
356
- else:
357
- nb = 2.0
358
- for row, (e) in flow_matrix_row(H, weight=weight, dtype=dtype, solver=solver):
359
- pos = dict(zip(row.argsort()[::-1], range(1, N + 1)))
360
- for i in range(N):
361
- betweenness[e] += (i + 1 - pos[i]) * row.item(i)
362
- betweenness[e] += (N - i - pos[i]) * row.item(i)
363
- betweenness[e] /= nb
364
- return {(ordering[s], ordering[t]): b for (s, t), b in betweenness.items()}
@@ -1,227 +0,0 @@
1
- """Current-flow betweenness centrality measures for subsets of nodes."""
2
-
3
- import networkx as nx
4
- from networkx.algorithms.centrality.flow_matrix import flow_matrix_row
5
- from networkx.utils import not_implemented_for, reverse_cuthill_mckee_ordering
6
-
7
- __all__ = [
8
- "current_flow_betweenness_centrality_subset",
9
- "edge_current_flow_betweenness_centrality_subset",
10
- ]
11
-
12
-
13
- @not_implemented_for("directed")
14
- @nx._dispatchable(edge_attrs="weight")
15
- def current_flow_betweenness_centrality_subset(
16
- G, sources, targets, normalized=True, weight=None, dtype=float, solver="lu"
17
- ):
18
- r"""Compute current-flow betweenness centrality for subsets of nodes.
19
-
20
- Current-flow betweenness centrality uses an electrical current
21
- model for information spreading in contrast to betweenness
22
- centrality which uses shortest paths.
23
-
24
- Current-flow betweenness centrality is also known as
25
- random-walk betweenness centrality [2]_.
26
-
27
- Parameters
28
- ----------
29
- G : graph
30
- A NetworkX graph
31
-
32
- sources: list of nodes
33
- Nodes to use as sources for current
34
-
35
- targets: list of nodes
36
- Nodes to use as sinks for current
37
-
38
- normalized : bool, optional (default=True)
39
- If True the betweenness values are normalized by b=b/(n-1)(n-2) where
40
- n is the number of nodes in G.
41
-
42
- weight : string or None, optional (default=None)
43
- Key for edge data used as the edge weight.
44
- If None, then use 1 as each edge weight.
45
- The weight reflects the capacity or the strength of the
46
- edge.
47
-
48
- dtype: data type (float)
49
- Default data type for internal matrices.
50
- Set to np.float32 for lower memory consumption.
51
-
52
- solver: string (default='lu')
53
- Type of linear solver to use for computing the flow matrix.
54
- Options are "full" (uses most memory), "lu" (recommended), and
55
- "cg" (uses least memory).
56
-
57
- Returns
58
- -------
59
- nodes : dictionary
60
- Dictionary of nodes with betweenness centrality as the value.
61
-
62
- See Also
63
- --------
64
- approximate_current_flow_betweenness_centrality
65
- betweenness_centrality
66
- edge_betweenness_centrality
67
- edge_current_flow_betweenness_centrality
68
-
69
- Notes
70
- -----
71
- Current-flow betweenness can be computed in $O(I(n-1)+mn \log n)$
72
- time [1]_, where $I(n-1)$ is the time needed to compute the
73
- inverse Laplacian. For a full matrix this is $O(n^3)$ but using
74
- sparse methods you can achieve $O(nm{\sqrt k})$ where $k$ is the
75
- Laplacian matrix condition number.
76
-
77
- The space required is $O(nw)$ where $w$ is the width of the sparse
78
- Laplacian matrix. Worse case is $w=n$ for $O(n^2)$.
79
-
80
- If the edges have a 'weight' attribute they will be used as
81
- weights in this algorithm. Unspecified weights are set to 1.
82
-
83
- References
84
- ----------
85
- .. [1] Centrality Measures Based on Current Flow.
86
- Ulrik Brandes and Daniel Fleischer,
87
- Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS '05).
88
- LNCS 3404, pp. 533-544. Springer-Verlag, 2005.
89
- https://doi.org/10.1007/978-3-540-31856-9_44
90
-
91
- .. [2] A measure of betweenness centrality based on random walks,
92
- M. E. J. Newman, Social Networks 27, 39-54 (2005).
93
- """
94
- import numpy as np
95
-
96
- from networkx.utils import reverse_cuthill_mckee_ordering
97
-
98
- if not nx.is_connected(G):
99
- raise nx.NetworkXError("Graph not connected.")
100
- N = G.number_of_nodes()
101
- ordering = list(reverse_cuthill_mckee_ordering(G))
102
- # make a copy with integer labels according to rcm ordering
103
- # this could be done without a copy if we really wanted to
104
- mapping = dict(zip(ordering, range(N)))
105
- H = nx.relabel_nodes(G, mapping)
106
- betweenness = dict.fromkeys(H, 0.0) # b[n]=0 for n in H
107
- for row, (s, t) in flow_matrix_row(H, weight=weight, dtype=dtype, solver=solver):
108
- for ss in sources:
109
- i = mapping[ss]
110
- for tt in targets:
111
- j = mapping[tt]
112
- betweenness[s] += 0.5 * abs(row.item(i) - row.item(j))
113
- betweenness[t] += 0.5 * abs(row.item(i) - row.item(j))
114
- if normalized:
115
- nb = (N - 1.0) * (N - 2.0) # normalization factor
116
- else:
117
- nb = 2.0
118
- for node in H:
119
- betweenness[node] = betweenness[node] / nb + 1.0 / (2 - N)
120
- return {ordering[node]: value for node, value in betweenness.items()}
121
-
122
-
123
- @not_implemented_for("directed")
124
- @nx._dispatchable(edge_attrs="weight")
125
- def edge_current_flow_betweenness_centrality_subset(
126
- G, sources, targets, normalized=True, weight=None, dtype=float, solver="lu"
127
- ):
128
- r"""Compute current-flow betweenness centrality for edges using subsets
129
- of nodes.
130
-
131
- Current-flow betweenness centrality uses an electrical current
132
- model for information spreading in contrast to betweenness
133
- centrality which uses shortest paths.
134
-
135
- Current-flow betweenness centrality is also known as
136
- random-walk betweenness centrality [2]_.
137
-
138
- Parameters
139
- ----------
140
- G : graph
141
- A NetworkX graph
142
-
143
- sources: list of nodes
144
- Nodes to use as sources for current
145
-
146
- targets: list of nodes
147
- Nodes to use as sinks for current
148
-
149
- normalized : bool, optional (default=True)
150
- If True the betweenness values are normalized by b=b/(n-1)(n-2) where
151
- n is the number of nodes in G.
152
-
153
- weight : string or None, optional (default=None)
154
- Key for edge data used as the edge weight.
155
- If None, then use 1 as each edge weight.
156
- The weight reflects the capacity or the strength of the
157
- edge.
158
-
159
- dtype: data type (float)
160
- Default data type for internal matrices.
161
- Set to np.float32 for lower memory consumption.
162
-
163
- solver: string (default='lu')
164
- Type of linear solver to use for computing the flow matrix.
165
- Options are "full" (uses most memory), "lu" (recommended), and
166
- "cg" (uses least memory).
167
-
168
- Returns
169
- -------
170
- nodes : dict
171
- Dictionary of edge tuples with betweenness centrality as the value.
172
-
173
- See Also
174
- --------
175
- betweenness_centrality
176
- edge_betweenness_centrality
177
- current_flow_betweenness_centrality
178
-
179
- Notes
180
- -----
181
- Current-flow betweenness can be computed in $O(I(n-1)+mn \log n)$
182
- time [1]_, where $I(n-1)$ is the time needed to compute the
183
- inverse Laplacian. For a full matrix this is $O(n^3)$ but using
184
- sparse methods you can achieve $O(nm{\sqrt k})$ where $k$ is the
185
- Laplacian matrix condition number.
186
-
187
- The space required is $O(nw)$ where $w$ is the width of the sparse
188
- Laplacian matrix. Worse case is $w=n$ for $O(n^2)$.
189
-
190
- If the edges have a 'weight' attribute they will be used as
191
- weights in this algorithm. Unspecified weights are set to 1.
192
-
193
- References
194
- ----------
195
- .. [1] Centrality Measures Based on Current Flow.
196
- Ulrik Brandes and Daniel Fleischer,
197
- Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS '05).
198
- LNCS 3404, pp. 533-544. Springer-Verlag, 2005.
199
- https://doi.org/10.1007/978-3-540-31856-9_44
200
-
201
- .. [2] A measure of betweenness centrality based on random walks,
202
- M. E. J. Newman, Social Networks 27, 39-54 (2005).
203
- """
204
- import numpy as np
205
-
206
- if not nx.is_connected(G):
207
- raise nx.NetworkXError("Graph not connected.")
208
- N = G.number_of_nodes()
209
- ordering = list(reverse_cuthill_mckee_ordering(G))
210
- # make a copy with integer labels according to rcm ordering
211
- # this could be done without a copy if we really wanted to
212
- mapping = dict(zip(ordering, range(N)))
213
- H = nx.relabel_nodes(G, mapping)
214
- edges = (tuple(sorted((u, v))) for u, v in H.edges())
215
- betweenness = dict.fromkeys(edges, 0.0)
216
- if normalized:
217
- nb = (N - 1.0) * (N - 2.0) # normalization factor
218
- else:
219
- nb = 2.0
220
- for row, (e) in flow_matrix_row(H, weight=weight, dtype=dtype, solver=solver):
221
- for ss in sources:
222
- i = mapping[ss]
223
- for tt in targets:
224
- j = mapping[tt]
225
- betweenness[e] += 0.5 * abs(row.item(i) - row.item(j))
226
- betweenness[e] /= nb
227
- return {(ordering[s], ordering[t]): value for (s, t), value in betweenness.items()}
@@ -1,96 +0,0 @@
1
- """Current-flow closeness centrality measures."""
2
-
3
- import networkx as nx
4
- from networkx.algorithms.centrality.flow_matrix import (
5
- CGInverseLaplacian,
6
- FullInverseLaplacian,
7
- SuperLUInverseLaplacian,
8
- )
9
- from networkx.utils import not_implemented_for, reverse_cuthill_mckee_ordering
10
-
11
- __all__ = ["current_flow_closeness_centrality", "information_centrality"]
12
-
13
-
14
- @not_implemented_for("directed")
15
- @nx._dispatchable(edge_attrs="weight")
16
- def current_flow_closeness_centrality(G, weight=None, dtype=float, solver="lu"):
17
- """Compute current-flow closeness centrality for nodes.
18
-
19
- Current-flow closeness centrality is variant of closeness
20
- centrality based on effective resistance between nodes in
21
- a network. This metric is also known as information centrality.
22
-
23
- Parameters
24
- ----------
25
- G : graph
26
- A NetworkX graph.
27
-
28
- weight : None or string, optional (default=None)
29
- If None, all edge weights are considered equal.
30
- Otherwise holds the name of the edge attribute used as weight.
31
- The weight reflects the capacity or the strength of the
32
- edge.
33
-
34
- dtype: data type (default=float)
35
- Default data type for internal matrices.
36
- Set to np.float32 for lower memory consumption.
37
-
38
- solver: string (default='lu')
39
- Type of linear solver to use for computing the flow matrix.
40
- Options are "full" (uses most memory), "lu" (recommended), and
41
- "cg" (uses least memory).
42
-
43
- Returns
44
- -------
45
- nodes : dictionary
46
- Dictionary of nodes with current flow closeness centrality as the value.
47
-
48
- See Also
49
- --------
50
- closeness_centrality
51
-
52
- Notes
53
- -----
54
- The algorithm is from Brandes [1]_.
55
-
56
- See also [2]_ for the original definition of information centrality.
57
-
58
- References
59
- ----------
60
- .. [1] Ulrik Brandes and Daniel Fleischer,
61
- Centrality Measures Based on Current Flow.
62
- Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS '05).
63
- LNCS 3404, pp. 533-544. Springer-Verlag, 2005.
64
- https://doi.org/10.1007/978-3-540-31856-9_44
65
-
66
- .. [2] Karen Stephenson and Marvin Zelen:
67
- Rethinking centrality: Methods and examples.
68
- Social Networks 11(1):1-37, 1989.
69
- https://doi.org/10.1016/0378-8733(89)90016-6
70
- """
71
- if not nx.is_connected(G):
72
- raise nx.NetworkXError("Graph not connected.")
73
- solvername = {
74
- "full": FullInverseLaplacian,
75
- "lu": SuperLUInverseLaplacian,
76
- "cg": CGInverseLaplacian,
77
- }
78
- N = G.number_of_nodes()
79
- ordering = list(reverse_cuthill_mckee_ordering(G))
80
- # make a copy with integer labels according to rcm ordering
81
- # this could be done without a copy if we really wanted to
82
- H = nx.relabel_nodes(G, dict(zip(ordering, range(N))))
83
- betweenness = dict.fromkeys(H, 0.0) # b[n]=0 for n in H
84
- N = H.number_of_nodes()
85
- L = nx.laplacian_matrix(H, nodelist=range(N), weight=weight).asformat("csc")
86
- L = L.astype(dtype)
87
- C2 = solvername[solver](L, width=1, dtype=dtype) # initialize solver
88
- for v in H:
89
- col = C2.get_row(v)
90
- for w in H:
91
- betweenness[v] += col.item(v) - 2 * col.item(w)
92
- betweenness[w] += col.item(v)
93
- return {ordering[node]: 1 / value for node, value in betweenness.items()}
94
-
95
-
96
- information_centrality = current_flow_closeness_centrality