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,588 +0,0 @@
1
- """
2
- Find the k-cores of a graph.
3
-
4
- The k-core is found by recursively pruning nodes with degrees less than k.
5
-
6
- See the following references for details:
7
-
8
- An O(m) Algorithm for Cores Decomposition of Networks
9
- Vladimir Batagelj and Matjaz Zaversnik, 2003.
10
- https://arxiv.org/abs/cs.DS/0310049
11
-
12
- Generalized Cores
13
- Vladimir Batagelj and Matjaz Zaversnik, 2002.
14
- https://arxiv.org/pdf/cs/0202039
15
-
16
- For directed graphs a more general notion is that of D-cores which
17
- looks at (k, l) restrictions on (in, out) degree. The (k, k) D-core
18
- is the k-core.
19
-
20
- D-cores: Measuring Collaboration of Directed Graphs Based on Degeneracy
21
- Christos Giatsidis, Dimitrios M. Thilikos, Michalis Vazirgiannis, ICDM 2011.
22
- http://www.graphdegeneracy.org/dcores_ICDM_2011.pdf
23
-
24
- Multi-scale structure and topological anomaly detection via a new network \
25
- statistic: The onion decomposition
26
- L. Hébert-Dufresne, J. A. Grochow, and A. Allard
27
- Scientific Reports 6, 31708 (2016)
28
- http://doi.org/10.1038/srep31708
29
-
30
- """
31
-
32
- import networkx as nx
33
-
34
- __all__ = [
35
- "core_number",
36
- "k_core",
37
- "k_shell",
38
- "k_crust",
39
- "k_corona",
40
- "k_truss",
41
- "onion_layers",
42
- ]
43
-
44
-
45
- @nx.utils.not_implemented_for("multigraph")
46
- @nx._dispatchable
47
- def core_number(G):
48
- """Returns the core number for each node.
49
-
50
- A k-core is a maximal subgraph that contains nodes of degree k or more.
51
-
52
- The core number of a node is the largest value k of a k-core containing
53
- that node.
54
-
55
- Parameters
56
- ----------
57
- G : NetworkX graph
58
- An undirected or directed graph
59
-
60
- Returns
61
- -------
62
- core_number : dictionary
63
- A dictionary keyed by node to the core number.
64
-
65
- Raises
66
- ------
67
- NetworkXNotImplemented
68
- If `G` is a multigraph or contains self loops.
69
-
70
- Notes
71
- -----
72
- For directed graphs the node degree is defined to be the
73
- in-degree + out-degree.
74
-
75
- Examples
76
- --------
77
- >>> degrees = [0, 1, 2, 2, 2, 2, 3]
78
- >>> H = nx.havel_hakimi_graph(degrees)
79
- >>> nx.core_number(H)
80
- {0: 1, 1: 2, 2: 2, 3: 2, 4: 1, 5: 2, 6: 0}
81
- >>> G = nx.DiGraph()
82
- >>> G.add_edges_from([(1, 2), (2, 1), (2, 3), (2, 4), (3, 4), (4, 3)])
83
- >>> nx.core_number(G)
84
- {1: 2, 2: 2, 3: 2, 4: 2}
85
-
86
- References
87
- ----------
88
- .. [1] An O(m) Algorithm for Cores Decomposition of Networks
89
- Vladimir Batagelj and Matjaz Zaversnik, 2003.
90
- https://arxiv.org/abs/cs.DS/0310049
91
- """
92
- if nx.number_of_selfloops(G) > 0:
93
- msg = (
94
- "Input graph has self loops which is not permitted; "
95
- "Consider using G.remove_edges_from(nx.selfloop_edges(G))."
96
- )
97
- raise nx.NetworkXNotImplemented(msg)
98
- degrees = dict(G.degree())
99
- # Sort nodes by degree.
100
- nodes = sorted(degrees, key=degrees.get)
101
- bin_boundaries = [0]
102
- curr_degree = 0
103
- for i, v in enumerate(nodes):
104
- if degrees[v] > curr_degree:
105
- bin_boundaries.extend([i] * (degrees[v] - curr_degree))
106
- curr_degree = degrees[v]
107
- node_pos = {v: pos for pos, v in enumerate(nodes)}
108
- # The initial guess for the core number of a node is its degree.
109
- core = degrees
110
- nbrs = {v: list(nx.all_neighbors(G, v)) for v in G}
111
- for v in nodes:
112
- for u in nbrs[v]:
113
- if core[u] > core[v]:
114
- nbrs[u].remove(v)
115
- pos = node_pos[u]
116
- bin_start = bin_boundaries[core[u]]
117
- node_pos[u] = bin_start
118
- node_pos[nodes[bin_start]] = pos
119
- nodes[bin_start], nodes[pos] = nodes[pos], nodes[bin_start]
120
- bin_boundaries[core[u]] += 1
121
- core[u] -= 1
122
- return core
123
-
124
-
125
- def _core_subgraph(G, k_filter, k=None, core=None):
126
- """Returns the subgraph induced by nodes passing filter `k_filter`.
127
-
128
- Parameters
129
- ----------
130
- G : NetworkX graph
131
- The graph or directed graph to process
132
- k_filter : filter function
133
- This function filters the nodes chosen. It takes three inputs:
134
- A node of G, the filter's cutoff, and the core dict of the graph.
135
- The function should return a Boolean value.
136
- k : int, optional
137
- The order of the core. If not specified use the max core number.
138
- This value is used as the cutoff for the filter.
139
- core : dict, optional
140
- Precomputed core numbers keyed by node for the graph `G`.
141
- If not specified, the core numbers will be computed from `G`.
142
-
143
- """
144
- if core is None:
145
- core = core_number(G)
146
- if k is None:
147
- k = max(core.values())
148
- nodes = (v for v in core if k_filter(v, k, core))
149
- return G.subgraph(nodes).copy()
150
-
151
-
152
- @nx.utils.not_implemented_for("multigraph")
153
- @nx._dispatchable(preserve_all_attrs=True, returns_graph=True)
154
- def k_core(G, k=None, core_number=None):
155
- """Returns the k-core of G.
156
-
157
- A k-core is a maximal subgraph that contains nodes of degree `k` or more.
158
-
159
- Parameters
160
- ----------
161
- G : NetworkX graph
162
- A graph or directed graph
163
- k : int, optional
164
- The order of the core. If not specified return the main core.
165
- core_number : dictionary, optional
166
- Precomputed core numbers for the graph G.
167
-
168
- Returns
169
- -------
170
- G : NetworkX graph
171
- The k-core subgraph
172
-
173
- Raises
174
- ------
175
- NetworkXNotImplemented
176
- The k-core is not defined for multigraphs or graphs with self loops.
177
-
178
- Notes
179
- -----
180
- The main core is the core with `k` as the largest core_number.
181
-
182
- For directed graphs the node degree is defined to be the
183
- in-degree + out-degree.
184
-
185
- Graph, node, and edge attributes are copied to the subgraph.
186
-
187
- Examples
188
- --------
189
- >>> degrees = [0, 1, 2, 2, 2, 2, 3]
190
- >>> H = nx.havel_hakimi_graph(degrees)
191
- >>> H.degree
192
- DegreeView({0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 3, 6: 0})
193
- >>> nx.k_core(H).nodes
194
- NodeView((1, 2, 3, 5))
195
-
196
- See Also
197
- --------
198
- core_number
199
-
200
- References
201
- ----------
202
- .. [1] An O(m) Algorithm for Cores Decomposition of Networks
203
- Vladimir Batagelj and Matjaz Zaversnik, 2003.
204
- https://arxiv.org/abs/cs.DS/0310049
205
- """
206
-
207
- def k_filter(v, k, c):
208
- return c[v] >= k
209
-
210
- return _core_subgraph(G, k_filter, k, core_number)
211
-
212
-
213
- @nx.utils.not_implemented_for("multigraph")
214
- @nx._dispatchable(preserve_all_attrs=True, returns_graph=True)
215
- def k_shell(G, k=None, core_number=None):
216
- """Returns the k-shell of G.
217
-
218
- The k-shell is the subgraph induced by nodes with core number k.
219
- That is, nodes in the k-core that are not in the (k+1)-core.
220
-
221
- Parameters
222
- ----------
223
- G : NetworkX graph
224
- A graph or directed graph.
225
- k : int, optional
226
- The order of the shell. If not specified return the outer shell.
227
- core_number : dictionary, optional
228
- Precomputed core numbers for the graph G.
229
-
230
-
231
- Returns
232
- -------
233
- G : NetworkX graph
234
- The k-shell subgraph
235
-
236
- Raises
237
- ------
238
- NetworkXNotImplemented
239
- The k-shell is not implemented for multigraphs or graphs with self loops.
240
-
241
- Notes
242
- -----
243
- This is similar to k_corona but in that case only neighbors in the
244
- k-core are considered.
245
-
246
- For directed graphs the node degree is defined to be the
247
- in-degree + out-degree.
248
-
249
- Graph, node, and edge attributes are copied to the subgraph.
250
-
251
- Examples
252
- --------
253
- >>> degrees = [0, 1, 2, 2, 2, 2, 3]
254
- >>> H = nx.havel_hakimi_graph(degrees)
255
- >>> H.degree
256
- DegreeView({0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 3, 6: 0})
257
- >>> nx.k_shell(H, k=1).nodes
258
- NodeView((0, 4))
259
-
260
- See Also
261
- --------
262
- core_number
263
- k_corona
264
-
265
-
266
- References
267
- ----------
268
- .. [1] A model of Internet topology using k-shell decomposition
269
- Shai Carmi, Shlomo Havlin, Scott Kirkpatrick, Yuval Shavitt,
270
- and Eran Shir, PNAS July 3, 2007 vol. 104 no. 27 11150-11154
271
- http://www.pnas.org/content/104/27/11150.full
272
- """
273
-
274
- def k_filter(v, k, c):
275
- return c[v] == k
276
-
277
- return _core_subgraph(G, k_filter, k, core_number)
278
-
279
-
280
- @nx.utils.not_implemented_for("multigraph")
281
- @nx._dispatchable(preserve_all_attrs=True, returns_graph=True)
282
- def k_crust(G, k=None, core_number=None):
283
- """Returns the k-crust of G.
284
-
285
- The k-crust is the graph G with the edges of the k-core removed
286
- and isolated nodes found after the removal of edges are also removed.
287
-
288
- Parameters
289
- ----------
290
- G : NetworkX graph
291
- A graph or directed graph.
292
- k : int, optional
293
- The order of the shell. If not specified return the main crust.
294
- core_number : dictionary, optional
295
- Precomputed core numbers for the graph G.
296
-
297
- Returns
298
- -------
299
- G : NetworkX graph
300
- The k-crust subgraph
301
-
302
- Raises
303
- ------
304
- NetworkXNotImplemented
305
- The k-crust is not implemented for multigraphs or graphs with self loops.
306
-
307
- Notes
308
- -----
309
- This definition of k-crust is different than the definition in [1]_.
310
- The k-crust in [1]_ is equivalent to the k+1 crust of this algorithm.
311
-
312
- For directed graphs the node degree is defined to be the
313
- in-degree + out-degree.
314
-
315
- Graph, node, and edge attributes are copied to the subgraph.
316
-
317
- Examples
318
- --------
319
- >>> degrees = [0, 1, 2, 2, 2, 2, 3]
320
- >>> H = nx.havel_hakimi_graph(degrees)
321
- >>> H.degree
322
- DegreeView({0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 3, 6: 0})
323
- >>> nx.k_crust(H, k=1).nodes
324
- NodeView((0, 4, 6))
325
-
326
- See Also
327
- --------
328
- core_number
329
-
330
- References
331
- ----------
332
- .. [1] A model of Internet topology using k-shell decomposition
333
- Shai Carmi, Shlomo Havlin, Scott Kirkpatrick, Yuval Shavitt,
334
- and Eran Shir, PNAS July 3, 2007 vol. 104 no. 27 11150-11154
335
- http://www.pnas.org/content/104/27/11150.full
336
- """
337
- # Default for k is one less than in _core_subgraph, so just inline.
338
- # Filter is c[v] <= k
339
- if core_number is None:
340
- core_number = nx.core_number(G)
341
- if k is None:
342
- k = max(core_number.values()) - 1
343
- nodes = (v for v in core_number if core_number[v] <= k)
344
- return G.subgraph(nodes).copy()
345
-
346
-
347
- @nx.utils.not_implemented_for("multigraph")
348
- @nx._dispatchable(preserve_all_attrs=True, returns_graph=True)
349
- def k_corona(G, k, core_number=None):
350
- """Returns the k-corona of G.
351
-
352
- The k-corona is the subgraph of nodes in the k-core which have
353
- exactly k neighbors in the k-core.
354
-
355
- Parameters
356
- ----------
357
- G : NetworkX graph
358
- A graph or directed graph
359
- k : int
360
- The order of the corona.
361
- core_number : dictionary, optional
362
- Precomputed core numbers for the graph G.
363
-
364
- Returns
365
- -------
366
- G : NetworkX graph
367
- The k-corona subgraph
368
-
369
- Raises
370
- ------
371
- NetworkXNotImplemented
372
- The k-corona is not defined for multigraphs or graphs with self loops.
373
-
374
- Notes
375
- -----
376
- For directed graphs the node degree is defined to be the
377
- in-degree + out-degree.
378
-
379
- Graph, node, and edge attributes are copied to the subgraph.
380
-
381
- Examples
382
- --------
383
- >>> degrees = [0, 1, 2, 2, 2, 2, 3]
384
- >>> H = nx.havel_hakimi_graph(degrees)
385
- >>> H.degree
386
- DegreeView({0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 3, 6: 0})
387
- >>> nx.k_corona(H, k=2).nodes
388
- NodeView((1, 2, 3, 5))
389
-
390
- See Also
391
- --------
392
- core_number
393
-
394
- References
395
- ----------
396
- .. [1] k -core (bootstrap) percolation on complex networks:
397
- Critical phenomena and nonlocal effects,
398
- A. V. Goltsev, S. N. Dorogovtsev, and J. F. F. Mendes,
399
- Phys. Rev. E 73, 056101 (2006)
400
- http://link.aps.org/doi/10.1103/PhysRevE.73.056101
401
- """
402
-
403
- def func(v, k, c):
404
- return c[v] == k and k == sum(1 for w in G[v] if c[w] >= k)
405
-
406
- return _core_subgraph(G, func, k, core_number)
407
-
408
-
409
- @nx.utils.not_implemented_for("directed")
410
- @nx.utils.not_implemented_for("multigraph")
411
- @nx._dispatchable(preserve_all_attrs=True, returns_graph=True)
412
- def k_truss(G, k):
413
- """Returns the k-truss of `G`.
414
-
415
- The k-truss is the maximal induced subgraph of `G` which contains at least
416
- three vertices where every edge is incident to at least `k-2` triangles.
417
-
418
- Parameters
419
- ----------
420
- G : NetworkX graph
421
- An undirected graph
422
- k : int
423
- The order of the truss
424
-
425
- Returns
426
- -------
427
- H : NetworkX graph
428
- The k-truss subgraph
429
-
430
- Raises
431
- ------
432
- NetworkXNotImplemented
433
- If `G` is a multigraph or directed graph or if it contains self loops.
434
-
435
- Notes
436
- -----
437
- A k-clique is a (k-2)-truss and a k-truss is a (k+1)-core.
438
-
439
- Graph, node, and edge attributes are copied to the subgraph.
440
-
441
- K-trusses were originally defined in [2] which states that the k-truss
442
- is the maximal induced subgraph where each edge belongs to at least
443
- `k-2` triangles. A more recent paper, [1], uses a slightly different
444
- definition requiring that each edge belong to at least `k` triangles.
445
- This implementation uses the original definition of `k-2` triangles.
446
-
447
- Examples
448
- --------
449
- >>> degrees = [0, 1, 2, 2, 2, 2, 3]
450
- >>> H = nx.havel_hakimi_graph(degrees)
451
- >>> H.degree
452
- DegreeView({0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 3, 6: 0})
453
- >>> nx.k_truss(H, k=2).nodes
454
- NodeView((0, 1, 2, 3, 4, 5))
455
-
456
- References
457
- ----------
458
- .. [1] Bounds and Algorithms for k-truss. Paul Burkhardt, Vance Faber,
459
- David G. Harris, 2018. https://arxiv.org/abs/1806.05523v2
460
- .. [2] Trusses: Cohesive Subgraphs for Social Network Analysis. Jonathan
461
- Cohen, 2005.
462
- """
463
- if nx.number_of_selfloops(G) > 0:
464
- msg = (
465
- "Input graph has self loops which is not permitted; "
466
- "Consider using G.remove_edges_from(nx.selfloop_edges(G))."
467
- )
468
- raise nx.NetworkXNotImplemented(msg)
469
-
470
- H = G.copy()
471
-
472
- n_dropped = 1
473
- while n_dropped > 0:
474
- n_dropped = 0
475
- to_drop = []
476
- seen = set()
477
- for u in H:
478
- nbrs_u = set(H[u])
479
- seen.add(u)
480
- new_nbrs = [v for v in nbrs_u if v not in seen]
481
- for v in new_nbrs:
482
- if len(nbrs_u & set(H[v])) < (k - 2):
483
- to_drop.append((u, v))
484
- H.remove_edges_from(to_drop)
485
- n_dropped = len(to_drop)
486
- H.remove_nodes_from(list(nx.isolates(H)))
487
-
488
- return H
489
-
490
-
491
- @nx.utils.not_implemented_for("multigraph")
492
- @nx.utils.not_implemented_for("directed")
493
- @nx._dispatchable
494
- def onion_layers(G):
495
- """Returns the layer of each vertex in an onion decomposition of the graph.
496
-
497
- The onion decomposition refines the k-core decomposition by providing
498
- information on the internal organization of each k-shell. It is usually
499
- used alongside the `core numbers`.
500
-
501
- Parameters
502
- ----------
503
- G : NetworkX graph
504
- An undirected graph without self loops.
505
-
506
- Returns
507
- -------
508
- od_layers : dictionary
509
- A dictionary keyed by node to the onion layer. The layers are
510
- contiguous integers starting at 1.
511
-
512
- Raises
513
- ------
514
- NetworkXNotImplemented
515
- If `G` is a multigraph or directed graph or if it contains self loops.
516
-
517
- Examples
518
- --------
519
- >>> degrees = [0, 1, 2, 2, 2, 2, 3]
520
- >>> H = nx.havel_hakimi_graph(degrees)
521
- >>> H.degree
522
- DegreeView({0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 3, 6: 0})
523
- >>> nx.onion_layers(H)
524
- {6: 1, 0: 2, 4: 3, 1: 4, 2: 4, 3: 4, 5: 4}
525
-
526
- See Also
527
- --------
528
- core_number
529
-
530
- References
531
- ----------
532
- .. [1] Multi-scale structure and topological anomaly detection via a new
533
- network statistic: The onion decomposition
534
- L. Hébert-Dufresne, J. A. Grochow, and A. Allard
535
- Scientific Reports 6, 31708 (2016)
536
- http://doi.org/10.1038/srep31708
537
- .. [2] Percolation and the effective structure of complex networks
538
- A. Allard and L. Hébert-Dufresne
539
- Physical Review X 9, 011023 (2019)
540
- http://doi.org/10.1103/PhysRevX.9.011023
541
- """
542
- if nx.number_of_selfloops(G) > 0:
543
- msg = (
544
- "Input graph contains self loops which is not permitted; "
545
- "Consider using G.remove_edges_from(nx.selfloop_edges(G))."
546
- )
547
- raise nx.NetworkXNotImplemented(msg)
548
- # Dictionaries to register the k-core/onion decompositions.
549
- od_layers = {}
550
- # Adjacency list
551
- neighbors = {v: list(nx.all_neighbors(G, v)) for v in G}
552
- # Effective degree of nodes.
553
- degrees = dict(G.degree())
554
- # Performs the onion decomposition.
555
- current_core = 1
556
- current_layer = 1
557
- # Sets vertices of degree 0 to layer 1, if any.
558
- isolated_nodes = list(nx.isolates(G))
559
- if len(isolated_nodes) > 0:
560
- for v in isolated_nodes:
561
- od_layers[v] = current_layer
562
- degrees.pop(v)
563
- current_layer = 2
564
- # Finds the layer for the remaining nodes.
565
- while len(degrees) > 0:
566
- # Sets the order for looking at nodes.
567
- nodes = sorted(degrees, key=degrees.get)
568
- # Sets properly the current core.
569
- min_degree = degrees[nodes[0]]
570
- if min_degree > current_core:
571
- current_core = min_degree
572
- # Identifies vertices in the current layer.
573
- this_layer = []
574
- for n in nodes:
575
- if degrees[n] > current_core:
576
- break
577
- this_layer.append(n)
578
- # Identifies the core/layer of the vertices in the current layer.
579
- for v in this_layer:
580
- od_layers[v] = current_layer
581
- for n in neighbors[v]:
582
- neighbors[n].remove(v)
583
- degrees[n] = degrees[n] - 1
584
- degrees.pop(v)
585
- # Updates the layer count.
586
- current_layer = current_layer + 1
587
- # Returns the dictionaries containing the onion layer of each vertices.
588
- return od_layers