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,200 +0,0 @@
1
- """Load centrality."""
2
-
3
- from operator import itemgetter
4
-
5
- import networkx as nx
6
-
7
- __all__ = ["load_centrality", "edge_load_centrality"]
8
-
9
-
10
- @nx._dispatchable(edge_attrs="weight")
11
- def newman_betweenness_centrality(G, v=None, cutoff=None, normalized=True, weight=None):
12
- """Compute load centrality for nodes.
13
-
14
- The load centrality of a node is the fraction of all shortest
15
- paths that pass through that node.
16
-
17
- Parameters
18
- ----------
19
- G : graph
20
- A networkx graph.
21
-
22
- normalized : bool, optional (default=True)
23
- If True the betweenness values are normalized by b=b/(n-1)(n-2) where
24
- n is the number of nodes in G.
25
-
26
- weight : None or string, optional (default=None)
27
- If None, edge weights are ignored.
28
- Otherwise holds the name of the edge attribute used as weight.
29
- The weight of an edge is treated as the length or distance between the two sides.
30
-
31
- cutoff : bool, optional (default=None)
32
- If specified, only consider paths of length <= cutoff.
33
-
34
- Returns
35
- -------
36
- nodes : dictionary
37
- Dictionary of nodes with centrality as the value.
38
-
39
- See Also
40
- --------
41
- betweenness_centrality
42
-
43
- Notes
44
- -----
45
- Load centrality is slightly different than betweenness. It was originally
46
- introduced by [2]_. For this load algorithm see [1]_.
47
-
48
- References
49
- ----------
50
- .. [1] Mark E. J. Newman:
51
- Scientific collaboration networks. II.
52
- Shortest paths, weighted networks, and centrality.
53
- Physical Review E 64, 016132, 2001.
54
- http://journals.aps.org/pre/abstract/10.1103/PhysRevE.64.016132
55
- .. [2] Kwang-Il Goh, Byungnam Kahng and Doochul Kim
56
- Universal behavior of Load Distribution in Scale-Free Networks.
57
- Physical Review Letters 87(27):1–4, 2001.
58
- https://doi.org/10.1103/PhysRevLett.87.278701
59
- """
60
- if v is not None: # only one node
61
- betweenness = 0.0
62
- for source in G:
63
- ubetween = _node_betweenness(G, source, cutoff, False, weight)
64
- betweenness += ubetween[v] if v in ubetween else 0
65
- if normalized:
66
- order = G.order()
67
- if order <= 2:
68
- return betweenness # no normalization b=0 for all nodes
69
- betweenness *= 1.0 / ((order - 1) * (order - 2))
70
- else:
71
- betweenness = {}.fromkeys(G, 0.0)
72
- for source in betweenness:
73
- ubetween = _node_betweenness(G, source, cutoff, False, weight)
74
- for vk in ubetween:
75
- betweenness[vk] += ubetween[vk]
76
- if normalized:
77
- order = G.order()
78
- if order <= 2:
79
- return betweenness # no normalization b=0 for all nodes
80
- scale = 1.0 / ((order - 1) * (order - 2))
81
- for v in betweenness:
82
- betweenness[v] *= scale
83
- return betweenness # all nodes
84
-
85
-
86
- def _node_betweenness(G, source, cutoff=False, normalized=True, weight=None):
87
- """Node betweenness_centrality helper:
88
-
89
- See betweenness_centrality for what you probably want.
90
- This actually computes "load" and not betweenness.
91
- See https://networkx.lanl.gov/ticket/103
92
-
93
- This calculates the load of each node for paths from a single source.
94
- (The fraction of number of shortests paths from source that go
95
- through each node.)
96
-
97
- To get the load for a node you need to do all-pairs shortest paths.
98
-
99
- If weight is not None then use Dijkstra for finding shortest paths.
100
- """
101
- # get the predecessor and path length data
102
- if weight is None:
103
- (pred, length) = nx.predecessor(G, source, cutoff=cutoff, return_seen=True)
104
- else:
105
- (pred, length) = nx.dijkstra_predecessor_and_distance(G, source, cutoff, weight)
106
-
107
- # order the nodes by path length
108
- onodes = [(l, vert) for (vert, l) in length.items()]
109
- onodes.sort()
110
- onodes[:] = [vert for (l, vert) in onodes if l > 0]
111
-
112
- # initialize betweenness
113
- between = {}.fromkeys(length, 1.0)
114
-
115
- while onodes:
116
- v = onodes.pop()
117
- if v in pred:
118
- num_paths = len(pred[v]) # Discount betweenness if more than
119
- for x in pred[v]: # one shortest path.
120
- if x == source: # stop if hit source because all remaining v
121
- break # also have pred[v]==[source]
122
- between[x] += between[v] / num_paths
123
- # remove source
124
- for v in between:
125
- between[v] -= 1
126
- # rescale to be between 0 and 1
127
- if normalized:
128
- l = len(between)
129
- if l > 2:
130
- # scale by 1/the number of possible paths
131
- scale = 1 / ((l - 1) * (l - 2))
132
- for v in between:
133
- between[v] *= scale
134
- return between
135
-
136
-
137
- load_centrality = newman_betweenness_centrality
138
-
139
-
140
- @nx._dispatchable
141
- def edge_load_centrality(G, cutoff=False):
142
- """Compute edge load.
143
-
144
- WARNING: This concept of edge load has not been analysed
145
- or discussed outside of NetworkX that we know of.
146
- It is based loosely on load_centrality in the sense that
147
- it counts the number of shortest paths which cross each edge.
148
- This function is for demonstration and testing purposes.
149
-
150
- Parameters
151
- ----------
152
- G : graph
153
- A networkx graph
154
-
155
- cutoff : bool, optional (default=False)
156
- If specified, only consider paths of length <= cutoff.
157
-
158
- Returns
159
- -------
160
- A dict keyed by edge 2-tuple to the number of shortest paths
161
- which use that edge. Where more than one path is shortest
162
- the count is divided equally among paths.
163
- """
164
- betweenness = {}
165
- for u, v in G.edges():
166
- betweenness[(u, v)] = 0.0
167
- betweenness[(v, u)] = 0.0
168
-
169
- for source in G:
170
- ubetween = _edge_betweenness(G, source, cutoff=cutoff)
171
- for e, ubetweenv in ubetween.items():
172
- betweenness[e] += ubetweenv # cumulative total
173
- return betweenness
174
-
175
-
176
- def _edge_betweenness(G, source, nodes=None, cutoff=False):
177
- """Edge betweenness helper."""
178
- # get the predecessor data
179
- (pred, length) = nx.predecessor(G, source, cutoff=cutoff, return_seen=True)
180
- # order the nodes by path length
181
- onodes = [n for n, d in sorted(length.items(), key=itemgetter(1))]
182
- # initialize betweenness, doesn't account for any edge weights
183
- between = {}
184
- for u, v in G.edges(nodes):
185
- between[(u, v)] = 1.0
186
- between[(v, u)] = 1.0
187
-
188
- while onodes: # work through all paths
189
- v = onodes.pop()
190
- if v in pred:
191
- # Discount betweenness if more than one shortest path.
192
- num_paths = len(pred[v])
193
- for w in pred[v]:
194
- if w in pred:
195
- # Discount betweenness, mult path
196
- num_paths = len(pred[w])
197
- for x in pred[w]:
198
- between[(w, x)] += between[(v, w)] / num_paths
199
- between[(x, w)] += between[(w, v)] / num_paths
200
- return between
@@ -1,128 +0,0 @@
1
- """Percolation centrality measures."""
2
-
3
- import networkx as nx
4
- from networkx.algorithms.centrality.betweenness import (
5
- _single_source_dijkstra_path_basic as dijkstra,
6
- )
7
- from networkx.algorithms.centrality.betweenness import (
8
- _single_source_shortest_path_basic as shortest_path,
9
- )
10
-
11
- __all__ = ["percolation_centrality"]
12
-
13
-
14
- @nx._dispatchable(node_attrs="attribute", edge_attrs="weight")
15
- def percolation_centrality(G, attribute="percolation", states=None, weight=None):
16
- r"""Compute the percolation centrality for nodes.
17
-
18
- Percolation centrality of a node $v$, at a given time, is defined
19
- as the proportion of ‘percolated paths’ that go through that node.
20
-
21
- This measure quantifies relative impact of nodes based on their
22
- topological connectivity, as well as their percolation states.
23
-
24
- Percolation states of nodes are used to depict network percolation
25
- scenarios (such as during infection transmission in a social network
26
- of individuals, spreading of computer viruses on computer networks, or
27
- transmission of disease over a network of towns) over time. In this
28
- measure usually the percolation state is expressed as a decimal
29
- between 0.0 and 1.0.
30
-
31
- When all nodes are in the same percolated state this measure is
32
- equivalent to betweenness centrality.
33
-
34
- Parameters
35
- ----------
36
- G : graph
37
- A NetworkX graph.
38
-
39
- attribute : None or string, optional (default='percolation')
40
- Name of the node attribute to use for percolation state, used
41
- if `states` is None. If a node does not set the attribute the
42
- state of that node will be set to the default value of 1.
43
- If all nodes do not have the attribute all nodes will be set to
44
- 1 and the centrality measure will be equivalent to betweenness centrality.
45
-
46
- states : None or dict, optional (default=None)
47
- Specify percolation states for the nodes, nodes as keys states
48
- as values.
49
-
50
- weight : None or string, optional (default=None)
51
- If None, all edge weights are considered equal.
52
- Otherwise holds the name of the edge attribute used as weight.
53
- The weight of an edge is treated as the length or distance between the two sides.
54
-
55
-
56
- Returns
57
- -------
58
- nodes : dictionary
59
- Dictionary of nodes with percolation centrality as the value.
60
-
61
- See Also
62
- --------
63
- betweenness_centrality
64
-
65
- Notes
66
- -----
67
- The algorithm is from Mahendra Piraveenan, Mikhail Prokopenko, and
68
- Liaquat Hossain [1]_
69
- Pair dependencies are calculated and accumulated using [2]_
70
-
71
- For weighted graphs the edge weights must be greater than zero.
72
- Zero edge weights can produce an infinite number of equal length
73
- paths between pairs of nodes.
74
-
75
- References
76
- ----------
77
- .. [1] Mahendra Piraveenan, Mikhail Prokopenko, Liaquat Hossain
78
- Percolation Centrality: Quantifying Graph-Theoretic Impact of Nodes
79
- during Percolation in Networks
80
- http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0053095
81
- .. [2] Ulrik Brandes:
82
- A Faster Algorithm for Betweenness Centrality.
83
- Journal of Mathematical Sociology 25(2):163-177, 2001.
84
- https://doi.org/10.1080/0022250X.2001.9990249
85
- """
86
- percolation = dict.fromkeys(G, 0.0) # b[v]=0 for v in G
87
-
88
- nodes = G
89
-
90
- if states is None:
91
- states = nx.get_node_attributes(nodes, attribute, default=1)
92
-
93
- # sum of all percolation states
94
- p_sigma_x_t = 0.0
95
- for v in states.values():
96
- p_sigma_x_t += v
97
-
98
- for s in nodes:
99
- # single source shortest paths
100
- if weight is None: # use BFS
101
- S, P, sigma, _ = shortest_path(G, s)
102
- else: # use Dijkstra's algorithm
103
- S, P, sigma, _ = dijkstra(G, s, weight)
104
- # accumulation
105
- percolation = _accumulate_percolation(
106
- percolation, S, P, sigma, s, states, p_sigma_x_t
107
- )
108
-
109
- n = len(G)
110
-
111
- for v in percolation:
112
- percolation[v] *= 1 / (n - 2)
113
-
114
- return percolation
115
-
116
-
117
- def _accumulate_percolation(percolation, S, P, sigma, s, states, p_sigma_x_t):
118
- delta = dict.fromkeys(S, 0)
119
- while S:
120
- w = S.pop()
121
- coeff = (1 + delta[w]) / sigma[w]
122
- for v in P[w]:
123
- delta[v] += sigma[v] * coeff
124
- if w != s:
125
- # percolation weight
126
- pw_s_w = states[s] / (p_sigma_x_t - states[w])
127
- percolation[w] += delta[w] * pw_s_w
128
- return percolation
@@ -1,209 +0,0 @@
1
- """Functions for computing reaching centrality of a node or a graph."""
2
-
3
- import networkx as nx
4
- from networkx.utils import pairwise
5
-
6
- __all__ = ["global_reaching_centrality", "local_reaching_centrality"]
7
-
8
-
9
- def _average_weight(G, path, weight=None):
10
- """Returns the average weight of an edge in a weighted path.
11
-
12
- Parameters
13
- ----------
14
- G : graph
15
- A networkx graph.
16
-
17
- path: list
18
- A list of vertices that define the path.
19
-
20
- weight : None or string, optional (default=None)
21
- If None, edge weights are ignored. Then the average weight of an edge
22
- is assumed to be the multiplicative inverse of the length of the path.
23
- Otherwise holds the name of the edge attribute used as weight.
24
- """
25
- path_length = len(path) - 1
26
- if path_length <= 0:
27
- return 0
28
- if weight is None:
29
- return 1 / path_length
30
- total_weight = sum(G.edges[i, j][weight] for i, j in pairwise(path))
31
- return total_weight / path_length
32
-
33
-
34
- @nx._dispatchable(edge_attrs="weight")
35
- def global_reaching_centrality(G, weight=None, normalized=True):
36
- """Returns the global reaching centrality of a directed graph.
37
-
38
- The *global reaching centrality* of a weighted directed graph is the
39
- average over all nodes of the difference between the local reaching
40
- centrality of the node and the greatest local reaching centrality of
41
- any node in the graph [1]_. For more information on the local
42
- reaching centrality, see :func:`local_reaching_centrality`.
43
- Informally, the local reaching centrality is the proportion of the
44
- graph that is reachable from the neighbors of the node.
45
-
46
- Parameters
47
- ----------
48
- G : DiGraph
49
- A networkx DiGraph.
50
-
51
- weight : None or string, optional (default=None)
52
- Attribute to use for edge weights. If ``None``, each edge weight
53
- is assumed to be one. A higher weight implies a stronger
54
- connection between nodes and a *shorter* path length.
55
-
56
- normalized : bool, optional (default=True)
57
- Whether to normalize the edge weights by the total sum of edge
58
- weights.
59
-
60
- Returns
61
- -------
62
- h : float
63
- The global reaching centrality of the graph.
64
-
65
- Examples
66
- --------
67
- >>> G = nx.DiGraph()
68
- >>> G.add_edge(1, 2)
69
- >>> G.add_edge(1, 3)
70
- >>> nx.global_reaching_centrality(G)
71
- 1.0
72
- >>> G.add_edge(3, 2)
73
- >>> nx.global_reaching_centrality(G)
74
- 0.75
75
-
76
- See also
77
- --------
78
- local_reaching_centrality
79
-
80
- References
81
- ----------
82
- .. [1] Mones, Enys, Lilla Vicsek, and Tamás Vicsek.
83
- "Hierarchy Measure for Complex Networks."
84
- *PLoS ONE* 7.3 (2012): e33799.
85
- https://doi.org/10.1371/journal.pone.0033799
86
- """
87
- if nx.is_negatively_weighted(G, weight=weight):
88
- raise nx.NetworkXError("edge weights must be positive")
89
- total_weight = G.size(weight=weight)
90
- if total_weight <= 0:
91
- raise nx.NetworkXError("Size of G must be positive")
92
- # If provided, weights must be interpreted as connection strength
93
- # (so higher weights are more likely to be chosen). However, the
94
- # shortest path algorithms in NetworkX assume the provided "weight"
95
- # is actually a distance (so edges with higher weight are less
96
- # likely to be chosen). Therefore we need to invert the weights when
97
- # computing shortest paths.
98
- #
99
- # If weight is None, we leave it as-is so that the shortest path
100
- # algorithm can use a faster, unweighted algorithm.
101
- if weight is not None:
102
-
103
- def as_distance(u, v, d):
104
- return total_weight / d.get(weight, 1)
105
-
106
- shortest_paths = dict(nx.shortest_path(G, weight=as_distance))
107
- else:
108
- shortest_paths = dict(nx.shortest_path(G))
109
-
110
- centrality = local_reaching_centrality
111
- # TODO This can be trivially parallelized.
112
- lrc = [
113
- centrality(G, node, paths=paths, weight=weight, normalized=normalized)
114
- for node, paths in shortest_paths.items()
115
- ]
116
-
117
- max_lrc = max(lrc)
118
- return sum(max_lrc - c for c in lrc) / (len(G) - 1)
119
-
120
-
121
- @nx._dispatchable(edge_attrs="weight")
122
- def local_reaching_centrality(G, v, paths=None, weight=None, normalized=True):
123
- """Returns the local reaching centrality of a node in a directed
124
- graph.
125
-
126
- The *local reaching centrality* of a node in a directed graph is the
127
- proportion of other nodes reachable from that node [1]_.
128
-
129
- Parameters
130
- ----------
131
- G : DiGraph
132
- A NetworkX DiGraph.
133
-
134
- v : node
135
- A node in the directed graph `G`.
136
-
137
- paths : dictionary (default=None)
138
- If this is not `None` it must be a dictionary representation
139
- of single-source shortest paths, as computed by, for example,
140
- :func:`networkx.shortest_path` with source node `v`. Use this
141
- keyword argument if you intend to invoke this function many
142
- times but don't want the paths to be recomputed each time.
143
-
144
- weight : None or string, optional (default=None)
145
- Attribute to use for edge weights. If `None`, each edge weight
146
- is assumed to be one. A higher weight implies a stronger
147
- connection between nodes and a *shorter* path length.
148
-
149
- normalized : bool, optional (default=True)
150
- Whether to normalize the edge weights by the total sum of edge
151
- weights.
152
-
153
- Returns
154
- -------
155
- h : float
156
- The local reaching centrality of the node ``v`` in the graph
157
- ``G``.
158
-
159
- Examples
160
- --------
161
- >>> G = nx.DiGraph()
162
- >>> G.add_edges_from([(1, 2), (1, 3)])
163
- >>> nx.local_reaching_centrality(G, 3)
164
- 0.0
165
- >>> G.add_edge(3, 2)
166
- >>> nx.local_reaching_centrality(G, 3)
167
- 0.5
168
-
169
- See also
170
- --------
171
- global_reaching_centrality
172
-
173
- References
174
- ----------
175
- .. [1] Mones, Enys, Lilla Vicsek, and Tamás Vicsek.
176
- "Hierarchy Measure for Complex Networks."
177
- *PLoS ONE* 7.3 (2012): e33799.
178
- https://doi.org/10.1371/journal.pone.0033799
179
- """
180
- # Corner case: graph with single node containing a self-loop
181
- if (total_weight := G.size(weight=weight)) > 0 and len(G) == 1:
182
- raise nx.NetworkXError(
183
- "local_reaching_centrality of a single node with self-loop not well-defined"
184
- )
185
- if paths is None:
186
- if nx.is_negatively_weighted(G, weight=weight):
187
- raise nx.NetworkXError("edge weights must be positive")
188
- if total_weight <= 0:
189
- raise nx.NetworkXError("Size of G must be positive")
190
- if weight is not None:
191
- # Interpret weights as lengths.
192
- def as_distance(u, v, d):
193
- return total_weight / d.get(weight, 1)
194
-
195
- paths = nx.shortest_path(G, source=v, weight=as_distance)
196
- else:
197
- paths = nx.shortest_path(G, source=v)
198
- # If the graph is unweighted, simply return the proportion of nodes
199
- # reachable from the source node ``v``.
200
- if weight is None and G.is_directed():
201
- return (len(paths) - 1) / (len(G) - 1)
202
- if normalized and weight is not None:
203
- norm = G.size(weight=weight) / G.size()
204
- else:
205
- norm = 1
206
- # TODO This can be trivially parallelized.
207
- avgw = (_average_weight(G, path, weight=weight) for path in paths.values())
208
- sum_avg_weight = sum(avgw) / norm
209
- return sum_avg_weight / (len(G) - 1)
@@ -1,141 +0,0 @@
1
- """Copyright (c) 2015 – Thomson Licensing, SAS
2
-
3
- Redistribution and use in source and binary forms, with or without
4
- modification, are permitted (subject to the limitations in the
5
- disclaimer below) provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright
8
- notice, this list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright
11
- notice, this list of conditions and the following disclaimer in the
12
- documentation and/or other materials provided with the distribution.
13
-
14
- * Neither the name of Thomson Licensing, or Technicolor, nor the names
15
- of its contributors may be used to endorse or promote products derived
16
- from this software without specific prior written permission.
17
-
18
- NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
19
- GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
20
- HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
21
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- """
32
-
33
- import networkx as nx
34
- from networkx.utils import not_implemented_for
35
-
36
- # Authors: Erwan Le Merrer (erwan.lemerrer@technicolor.com)
37
-
38
- __all__ = ["second_order_centrality"]
39
-
40
-
41
- @not_implemented_for("directed")
42
- @nx._dispatchable(edge_attrs="weight")
43
- def second_order_centrality(G, weight="weight"):
44
- """Compute the second order centrality for nodes of G.
45
-
46
- The second order centrality of a given node is the standard deviation of
47
- the return times to that node of a perpetual random walk on G:
48
-
49
- Parameters
50
- ----------
51
- G : graph
52
- A NetworkX connected and undirected graph.
53
-
54
- weight : string or None, optional (default="weight")
55
- The name of an edge attribute that holds the numerical value
56
- used as a weight. If None then each edge has weight 1.
57
-
58
- Returns
59
- -------
60
- nodes : dictionary
61
- Dictionary keyed by node with second order centrality as the value.
62
-
63
- Examples
64
- --------
65
- >>> G = nx.star_graph(10)
66
- >>> soc = nx.second_order_centrality(G)
67
- >>> print(sorted(soc.items(), key=lambda x: x[1])[0][0]) # pick first id
68
- 0
69
-
70
- Raises
71
- ------
72
- NetworkXException
73
- If the graph G is empty, non connected or has negative weights.
74
-
75
- See Also
76
- --------
77
- betweenness_centrality
78
-
79
- Notes
80
- -----
81
- Lower values of second order centrality indicate higher centrality.
82
-
83
- The algorithm is from Kermarrec, Le Merrer, Sericola and Trédan [1]_.
84
-
85
- This code implements the analytical version of the algorithm, i.e.,
86
- there is no simulation of a random walk process involved. The random walk
87
- is here unbiased (corresponding to eq 6 of the paper [1]_), thus the
88
- centrality values are the standard deviations for random walk return times
89
- on the transformed input graph G (equal in-degree at each nodes by adding
90
- self-loops).
91
-
92
- Complexity of this implementation, made to run locally on a single machine,
93
- is O(n^3), with n the size of G, which makes it viable only for small
94
- graphs.
95
-
96
- References
97
- ----------
98
- .. [1] Anne-Marie Kermarrec, Erwan Le Merrer, Bruno Sericola, Gilles Trédan
99
- "Second order centrality: Distributed assessment of nodes criticity in
100
- complex networks", Elsevier Computer Communications 34(5):619-628, 2011.
101
- """
102
- import numpy as np
103
-
104
- n = len(G)
105
-
106
- if n == 0:
107
- raise nx.NetworkXException("Empty graph.")
108
- if not nx.is_connected(G):
109
- raise nx.NetworkXException("Non connected graph.")
110
- if any(d.get(weight, 0) < 0 for u, v, d in G.edges(data=True)):
111
- raise nx.NetworkXException("Graph has negative edge weights.")
112
-
113
- # balancing G for Metropolis-Hastings random walks
114
- G = nx.DiGraph(G)
115
- in_deg = dict(G.in_degree(weight=weight))
116
- d_max = max(in_deg.values())
117
- for i, deg in in_deg.items():
118
- if deg < d_max:
119
- G.add_edge(i, i, weight=d_max - deg)
120
-
121
- P = nx.to_numpy_array(G)
122
- P /= P.sum(axis=1)[:, np.newaxis] # to transition probability matrix
123
-
124
- def _Qj(P, j):
125
- P = P.copy()
126
- P[:, j] = 0
127
- return P
128
-
129
- M = np.empty([n, n])
130
-
131
- for i in range(n):
132
- M[:, i] = np.linalg.solve(
133
- np.identity(n) - _Qj(P, i), np.ones([n, 1])[:, 0]
134
- ) # eq 3
135
-
136
- return dict(
137
- zip(
138
- G.nodes,
139
- (float(np.sqrt(2 * np.sum(M[:, i]) - n * (n + 1))) for i in range(n)),
140
- )
141
- ) # eq 6