okstra 0.130.3 → 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 (367) 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 +21 -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/report_views.py +32 -5
  27. package/runtime/python/okstra_ctl/run.py +15 -3
  28. package/runtime/python/okstra_ctl/worker_prompt_contract.py +14 -6
  29. package/runtime/python/okstra_ctl/worker_prompt_policy.py +19 -1
  30. package/runtime/python/okstra_vendor/__init__.py +0 -44
  31. package/runtime/schemas/final-report-v1.0.schema.json +101 -6
  32. package/runtime/skills/okstra-run/SKILL.md +11 -4
  33. package/runtime/skills/okstra-setup/SKILL.md +3 -2
  34. package/runtime/skills/okstra-setup/references/project-config.md +16 -7
  35. package/runtime/templates/reports/final-report.template.md +18 -12
  36. package/runtime/templates/reports/i18n/en.json +1 -0
  37. package/runtime/templates/reports/i18n/ko.json +1 -0
  38. package/runtime/templates/reports/report.css +18 -0
  39. package/runtime/validators/lib/fixtures.sh +6 -0
  40. package/runtime/validators/validate-run.py +1722 -98
  41. package/src/cli-registry.mjs +0 -7
  42. package/src/commands/lifecycle/doctor.mjs +0 -9
  43. package/src/lib/skill-catalog.mjs +0 -1
  44. package/docs/for-ai/skills/okstra-graphify.md +0 -64
  45. package/runtime/python/okstra_ctl/graphify_cmd.py +0 -225
  46. package/runtime/python/okstra_vendor/graphify/.vendored-version +0 -1
  47. package/runtime/python/okstra_vendor/graphify/__init__.py +0 -28
  48. package/runtime/python/okstra_vendor/graphify/__main__.py +0 -1371
  49. package/runtime/python/okstra_vendor/graphify/analyze.py +0 -540
  50. package/runtime/python/okstra_vendor/graphify/benchmark.py +0 -129
  51. package/runtime/python/okstra_vendor/graphify/build.py +0 -107
  52. package/runtime/python/okstra_vendor/graphify/cache.py +0 -169
  53. package/runtime/python/okstra_vendor/graphify/cluster.py +0 -137
  54. package/runtime/python/okstra_vendor/graphify/detect.py +0 -510
  55. package/runtime/python/okstra_vendor/graphify/export.py +0 -1014
  56. package/runtime/python/okstra_vendor/graphify/extract.py +0 -3277
  57. package/runtime/python/okstra_vendor/graphify/hooks.py +0 -220
  58. package/runtime/python/okstra_vendor/graphify/ingest.py +0 -297
  59. package/runtime/python/okstra_vendor/graphify/manifest.py +0 -4
  60. package/runtime/python/okstra_vendor/graphify/report.py +0 -175
  61. package/runtime/python/okstra_vendor/graphify/security.py +0 -203
  62. package/runtime/python/okstra_vendor/graphify/serve.py +0 -373
  63. package/runtime/python/okstra_vendor/graphify/skill-aider.md +0 -1184
  64. package/runtime/python/okstra_vendor/graphify/skill-claw.md +0 -1184
  65. package/runtime/python/okstra_vendor/graphify/skill-codex.md +0 -1242
  66. package/runtime/python/okstra_vendor/graphify/skill-copilot.md +0 -1268
  67. package/runtime/python/okstra_vendor/graphify/skill-droid.md +0 -1239
  68. package/runtime/python/okstra_vendor/graphify/skill-kiro.md +0 -1183
  69. package/runtime/python/okstra_vendor/graphify/skill-opencode.md +0 -1238
  70. package/runtime/python/okstra_vendor/graphify/skill-trae.md +0 -1208
  71. package/runtime/python/okstra_vendor/graphify/skill-vscode.md +0 -253
  72. package/runtime/python/okstra_vendor/graphify/skill-windows.md +0 -1245
  73. package/runtime/python/okstra_vendor/graphify/skill.md +0 -1319
  74. package/runtime/python/okstra_vendor/graphify/transcribe.py +0 -182
  75. package/runtime/python/okstra_vendor/graphify/validate.py +0 -72
  76. package/runtime/python/okstra_vendor/graphify/watch.py +0 -188
  77. package/runtime/python/okstra_vendor/graphify/wiki.py +0 -214
  78. package/runtime/python/okstra_vendor/networkx/__init__.py +0 -62
  79. package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +0 -134
  80. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +0 -26
  81. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +0 -259
  82. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +0 -71
  83. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +0 -412
  84. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +0 -396
  85. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +0 -150
  86. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +0 -149
  87. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +0 -369
  88. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +0 -44
  89. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +0 -143
  90. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +0 -53
  91. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +0 -265
  92. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +0 -1508
  93. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +0 -255
  94. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +0 -83
  95. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +0 -5
  96. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +0 -122
  97. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +0 -302
  98. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +0 -255
  99. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +0 -160
  100. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +0 -127
  101. package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +0 -164
  102. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +0 -88
  103. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +0 -322
  104. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +0 -290
  105. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +0 -289
  106. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +0 -57
  107. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +0 -360
  108. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +0 -105
  109. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +0 -603
  110. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +0 -316
  111. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +0 -590
  112. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +0 -232
  113. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +0 -526
  114. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +0 -112
  115. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +0 -69
  116. package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +0 -168
  117. package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +0 -205
  118. package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +0 -164
  119. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +0 -20
  120. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +0 -591
  121. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +0 -236
  122. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +0 -282
  123. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +0 -364
  124. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +0 -227
  125. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +0 -96
  126. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +0 -150
  127. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +0 -107
  128. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +0 -357
  129. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +0 -130
  130. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +0 -787
  131. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +0 -88
  132. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +0 -331
  133. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +0 -150
  134. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +0 -200
  135. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +0 -128
  136. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +0 -209
  137. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +0 -141
  138. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +0 -361
  139. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +0 -181
  140. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +0 -95
  141. package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +0 -172
  142. package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +0 -443
  143. package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +0 -818
  144. package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +0 -732
  145. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +0 -4
  146. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +0 -505
  147. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +0 -565
  148. package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +0 -163
  149. package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +0 -28
  150. package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +0 -153
  151. package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +0 -354
  152. package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +0 -171
  153. package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +0 -30
  154. package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +0 -216
  155. package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +0 -79
  156. package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +0 -338
  157. package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +0 -162
  158. package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +0 -220
  159. package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +0 -384
  160. package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +0 -227
  161. package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +0 -452
  162. package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +0 -347
  163. package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +0 -6
  164. package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +0 -115
  165. package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +0 -394
  166. package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +0 -282
  167. package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +0 -71
  168. package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +0 -359
  169. package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +0 -196
  170. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +0 -11
  171. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +0 -811
  172. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +0 -616
  173. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +0 -408
  174. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +0 -1270
  175. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +0 -592
  176. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +0 -220
  177. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +0 -235
  178. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +0 -152
  179. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +0 -88
  180. package/runtime/python/okstra_vendor/networkx/algorithms/core.py +0 -588
  181. package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +0 -142
  182. package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +0 -416
  183. package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +0 -1234
  184. package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +0 -677
  185. package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +0 -1392
  186. package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +0 -1095
  187. package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +0 -272
  188. package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +0 -142
  189. package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +0 -268
  190. package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +0 -167
  191. package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +0 -470
  192. package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +0 -11
  193. package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +0 -370
  194. package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +0 -407
  195. package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +0 -238
  196. package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +0 -241
  197. package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +0 -178
  198. package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +0 -611
  199. package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +0 -356
  200. package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +0 -662
  201. package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +0 -425
  202. package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +0 -300
  203. package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +0 -194
  204. package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +0 -435
  205. package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +0 -483
  206. package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +0 -57
  207. package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +0 -196
  208. package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +0 -107
  209. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +0 -7
  210. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +0 -1306
  211. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +0 -336
  212. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +0 -1262
  213. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +0 -352
  214. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +0 -308
  215. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +0 -264
  216. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +0 -1102
  217. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +0 -192
  218. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +0 -2
  219. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +0 -337
  220. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +0 -498
  221. package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +0 -687
  222. package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +0 -280
  223. package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +0 -1148
  224. package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +0 -27
  225. package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +0 -738
  226. package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +0 -78
  227. package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +0 -59
  228. package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +0 -219
  229. package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +0 -155
  230. package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +0 -4
  231. package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +0 -324
  232. package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +0 -468
  233. package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +0 -633
  234. package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +0 -77
  235. package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +0 -73
  236. package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +0 -464
  237. package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +0 -1463
  238. package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +0 -306
  239. package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +0 -98
  240. package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +0 -167
  241. package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +0 -138
  242. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +0 -5
  243. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +0 -239
  244. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +0 -264
  245. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +0 -716
  246. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +0 -625
  247. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +0 -2542
  248. package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +0 -2107
  249. package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +0 -966
  250. package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +0 -404
  251. package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +0 -30
  252. package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +0 -296
  253. package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +0 -374
  254. package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +0 -564
  255. package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +0 -406
  256. package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +0 -981
  257. package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +0 -142
  258. package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +0 -406
  259. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +0 -5
  260. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +0 -90
  261. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +0 -576
  262. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +0 -529
  263. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +0 -185
  264. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +0 -182
  265. package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +0 -7
  266. package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +0 -1042
  267. package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +0 -413
  268. package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +0 -88
  269. package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +0 -219
  270. package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +0 -1281
  271. package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +0 -106
  272. package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +0 -273
  273. package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +0 -500
  274. package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +0 -76
  275. package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +0 -86
  276. package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +0 -77
  277. package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +0 -278
  278. package/runtime/python/okstra_vendor/networkx/classes/__init__.py +0 -13
  279. package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +0 -435
  280. package/runtime/python/okstra_vendor/networkx/classes/digraph.py +0 -1363
  281. package/runtime/python/okstra_vendor/networkx/classes/filters.py +0 -95
  282. package/runtime/python/okstra_vendor/networkx/classes/function.py +0 -1549
  283. package/runtime/python/okstra_vendor/networkx/classes/graph.py +0 -2082
  284. package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +0 -269
  285. package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +0 -977
  286. package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +0 -1294
  287. package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +0 -1447
  288. package/runtime/python/okstra_vendor/networkx/convert.py +0 -502
  289. package/runtime/python/okstra_vendor/networkx/convert_matrix.py +0 -1314
  290. package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +0 -7
  291. package/runtime/python/okstra_vendor/networkx/drawing/layout.py +0 -2036
  292. package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +0 -470
  293. package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +0 -570
  294. package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +0 -361
  295. package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +0 -2978
  296. package/runtime/python/okstra_vendor/networkx/exception.py +0 -131
  297. package/runtime/python/okstra_vendor/networkx/generators/__init__.py +0 -34
  298. package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
  299. package/runtime/python/okstra_vendor/networkx/generators/atlas.py +0 -227
  300. package/runtime/python/okstra_vendor/networkx/generators/classic.py +0 -1091
  301. package/runtime/python/okstra_vendor/networkx/generators/cographs.py +0 -68
  302. package/runtime/python/okstra_vendor/networkx/generators/community.py +0 -1070
  303. package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +0 -886
  304. package/runtime/python/okstra_vendor/networkx/generators/directed.py +0 -572
  305. package/runtime/python/okstra_vendor/networkx/generators/duplication.py +0 -174
  306. package/runtime/python/okstra_vendor/networkx/generators/ego.py +0 -66
  307. package/runtime/python/okstra_vendor/networkx/generators/expanders.py +0 -499
  308. package/runtime/python/okstra_vendor/networkx/generators/geometric.py +0 -1037
  309. package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +0 -163
  310. package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +0 -443
  311. package/runtime/python/okstra_vendor/networkx/generators/intersection.py +0 -125
  312. package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +0 -70
  313. package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +0 -664
  314. package/runtime/python/okstra_vendor/networkx/generators/lattice.py +0 -405
  315. package/runtime/python/okstra_vendor/networkx/generators/line.py +0 -501
  316. package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +0 -110
  317. package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +0 -259
  318. package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +0 -117
  319. package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +0 -1416
  320. package/runtime/python/okstra_vendor/networkx/generators/small.py +0 -1070
  321. package/runtime/python/okstra_vendor/networkx/generators/social.py +0 -554
  322. package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +0 -120
  323. package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +0 -54
  324. package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +0 -131
  325. package/runtime/python/okstra_vendor/networkx/generators/time_series.py +0 -74
  326. package/runtime/python/okstra_vendor/networkx/generators/trees.py +0 -1070
  327. package/runtime/python/okstra_vendor/networkx/generators/triads.py +0 -94
  328. package/runtime/python/okstra_vendor/networkx/lazy_imports.py +0 -188
  329. package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +0 -13
  330. package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +0 -650
  331. package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +0 -466
  332. package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +0 -77
  333. package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +0 -168
  334. package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +0 -512
  335. package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +0 -166
  336. package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +0 -186
  337. package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +0 -17
  338. package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +0 -330
  339. package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +0 -489
  340. package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +0 -1084
  341. package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +0 -879
  342. package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +0 -427
  343. package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +0 -1053
  344. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +0 -19
  345. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +0 -156
  346. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +0 -190
  347. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +0 -261
  348. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +0 -137
  349. package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +0 -108
  350. package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +0 -393
  351. package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +0 -113
  352. package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +0 -286
  353. package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +0 -379
  354. package/runtime/python/okstra_vendor/networkx/readwrite/text.py +0 -851
  355. package/runtime/python/okstra_vendor/networkx/relabel.py +0 -285
  356. package/runtime/python/okstra_vendor/networkx/utils/__init__.py +0 -8
  357. package/runtime/python/okstra_vendor/networkx/utils/backends.py +0 -2171
  358. package/runtime/python/okstra_vendor/networkx/utils/configs.py +0 -396
  359. package/runtime/python/okstra_vendor/networkx/utils/decorators.py +0 -1233
  360. package/runtime/python/okstra_vendor/networkx/utils/heaps.py +0 -338
  361. package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +0 -297
  362. package/runtime/python/okstra_vendor/networkx/utils/misc.py +0 -703
  363. package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +0 -198
  364. package/runtime/python/okstra_vendor/networkx/utils/rcm.py +0 -159
  365. package/runtime/python/okstra_vendor/networkx/utils/union_find.py +0 -106
  366. package/runtime/skills/okstra-graphify/SKILL.md +0 -169
  367. package/src/commands/graphify.mjs +0 -32
@@ -1,564 +0,0 @@
1
- """
2
- Graph summarization finds smaller representations of graphs resulting in faster
3
- runtime of algorithms, reduced storage needs, and noise reduction.
4
- Summarization has applications in areas such as visualization, pattern mining,
5
- clustering and community detection, and more. Core graph summarization
6
- techniques are grouping/aggregation, bit-compression,
7
- simplification/sparsification, and influence based. Graph summarization
8
- algorithms often produce either summary graphs in the form of supergraphs or
9
- sparsified graphs, or a list of independent structures. Supergraphs are the
10
- most common product, which consist of supernodes and original nodes and are
11
- connected by edges and superedges, which represent aggregate edges between
12
- nodes and supernodes.
13
-
14
- Grouping/aggregation based techniques compress graphs by representing
15
- close/connected nodes and edges in a graph by a single node/edge in a
16
- supergraph. Nodes can be grouped together into supernodes based on their
17
- structural similarities or proximity within a graph to reduce the total number
18
- of nodes in a graph. Edge-grouping techniques group edges into lossy/lossless
19
- nodes called compressor or virtual nodes to reduce the total number of edges in
20
- a graph. Edge-grouping techniques can be lossless, meaning that they can be
21
- used to re-create the original graph, or techniques can be lossy, requiring
22
- less space to store the summary graph, but at the expense of lower
23
- reconstruction accuracy of the original graph.
24
-
25
- Bit-compression techniques minimize the amount of information needed to
26
- describe the original graph, while revealing structural patterns in the
27
- original graph. The two-part minimum description length (MDL) is often used to
28
- represent the model and the original graph in terms of the model. A key
29
- difference between graph compression and graph summarization is that graph
30
- summarization focuses on finding structural patterns within the original graph,
31
- whereas graph compression focuses on compressions the original graph to be as
32
- small as possible. **NOTE**: Some bit-compression methods exist solely to
33
- compress a graph without creating a summary graph or finding comprehensible
34
- structural patterns.
35
-
36
- Simplification/Sparsification techniques attempt to create a sparse
37
- representation of a graph by removing unimportant nodes and edges from the
38
- graph. Sparsified graphs differ from supergraphs created by
39
- grouping/aggregation by only containing a subset of the original nodes and
40
- edges of the original graph.
41
-
42
- Influence based techniques aim to find a high-level description of influence
43
- propagation in a large graph. These methods are scarce and have been mostly
44
- applied to social graphs.
45
-
46
- *dedensification* is a grouping/aggregation based technique to compress the
47
- neighborhoods around high-degree nodes in unweighted graphs by adding
48
- compressor nodes that summarize multiple edges of the same type to
49
- high-degree nodes (nodes with a degree greater than a given threshold).
50
- Dedensification was developed for the purpose of increasing performance of
51
- query processing around high-degree nodes in graph databases and enables direct
52
- operations on the compressed graph. The structural patterns surrounding
53
- high-degree nodes in the original is preserved while using fewer edges and
54
- adding a small number of compressor nodes. The degree of nodes present in the
55
- original graph is also preserved. The current implementation of dedensification
56
- supports graphs with one edge type.
57
-
58
- For more information on graph summarization, see `Graph Summarization Methods
59
- and Applications: A Survey <https://dl.acm.org/doi/abs/10.1145/3186727>`_
60
- """
61
-
62
- from collections import Counter, defaultdict
63
-
64
- import networkx as nx
65
-
66
- __all__ = ["dedensify", "snap_aggregation"]
67
-
68
-
69
- @nx._dispatchable(mutates_input={"not copy": 3}, returns_graph=True)
70
- def dedensify(G, threshold, prefix=None, copy=True):
71
- """Compresses neighborhoods around high-degree nodes
72
-
73
- Reduces the number of edges to high-degree nodes by adding compressor nodes
74
- that summarize multiple edges of the same type to high-degree nodes (nodes
75
- with a degree greater than a given threshold). Dedensification also has
76
- the added benefit of reducing the number of edges around high-degree nodes.
77
- The implementation currently supports graphs with a single edge type.
78
-
79
- Parameters
80
- ----------
81
- G: graph
82
- A networkx graph
83
- threshold: int
84
- Minimum degree threshold of a node to be considered a high degree node.
85
- The threshold must be greater than or equal to 2.
86
- prefix: str or None, optional (default: None)
87
- An optional prefix for denoting compressor nodes
88
- copy: bool, optional (default: True)
89
- Indicates if dedensification should be done inplace
90
-
91
- Returns
92
- -------
93
- dedensified networkx graph : (graph, set)
94
- 2-tuple of the dedensified graph and set of compressor nodes
95
-
96
- Notes
97
- -----
98
- According to the algorithm in [1]_, removes edges in a graph by
99
- compressing/decompressing the neighborhoods around high degree nodes by
100
- adding compressor nodes that summarize multiple edges of the same type
101
- to high-degree nodes. Dedensification will only add a compressor node when
102
- doing so will reduce the total number of edges in the given graph. This
103
- implementation currently supports graphs with a single edge type.
104
-
105
- Examples
106
- --------
107
- Dedensification will only add compressor nodes when doing so would result
108
- in fewer edges::
109
-
110
- >>> original_graph = nx.DiGraph()
111
- >>> original_graph.add_nodes_from(
112
- ... ["1", "2", "3", "4", "5", "6", "A", "B", "C"]
113
- ... )
114
- >>> original_graph.add_edges_from(
115
- ... [
116
- ... ("1", "C"), ("1", "B"),
117
- ... ("2", "C"), ("2", "B"), ("2", "A"),
118
- ... ("3", "B"), ("3", "A"), ("3", "6"),
119
- ... ("4", "C"), ("4", "B"), ("4", "A"),
120
- ... ("5", "B"), ("5", "A"),
121
- ... ("6", "5"),
122
- ... ("A", "6")
123
- ... ]
124
- ... )
125
- >>> c_graph, c_nodes = nx.dedensify(original_graph, threshold=2)
126
- >>> original_graph.number_of_edges()
127
- 15
128
- >>> c_graph.number_of_edges()
129
- 14
130
-
131
- A dedensified, directed graph can be "densified" to reconstruct the
132
- original graph::
133
-
134
- >>> original_graph = nx.DiGraph()
135
- >>> original_graph.add_nodes_from(
136
- ... ["1", "2", "3", "4", "5", "6", "A", "B", "C"]
137
- ... )
138
- >>> original_graph.add_edges_from(
139
- ... [
140
- ... ("1", "C"), ("1", "B"),
141
- ... ("2", "C"), ("2", "B"), ("2", "A"),
142
- ... ("3", "B"), ("3", "A"), ("3", "6"),
143
- ... ("4", "C"), ("4", "B"), ("4", "A"),
144
- ... ("5", "B"), ("5", "A"),
145
- ... ("6", "5"),
146
- ... ("A", "6")
147
- ... ]
148
- ... )
149
- >>> c_graph, c_nodes = nx.dedensify(original_graph, threshold=2)
150
- >>> # re-densifies the compressed graph into the original graph
151
- >>> for c_node in c_nodes:
152
- ... all_neighbors = set(nx.all_neighbors(c_graph, c_node))
153
- ... out_neighbors = set(c_graph.neighbors(c_node))
154
- ... for out_neighbor in out_neighbors:
155
- ... c_graph.remove_edge(c_node, out_neighbor)
156
- ... in_neighbors = all_neighbors - out_neighbors
157
- ... for in_neighbor in in_neighbors:
158
- ... c_graph.remove_edge(in_neighbor, c_node)
159
- ... for out_neighbor in out_neighbors:
160
- ... c_graph.add_edge(in_neighbor, out_neighbor)
161
- ... c_graph.remove_node(c_node)
162
- ...
163
- >>> nx.is_isomorphic(original_graph, c_graph)
164
- True
165
-
166
- References
167
- ----------
168
- .. [1] Maccioni, A., & Abadi, D. J. (2016, August).
169
- Scalable pattern matching over compressed graphs via dedensification.
170
- In Proceedings of the 22nd ACM SIGKDD International Conference on
171
- Knowledge Discovery and Data Mining (pp. 1755-1764).
172
- http://www.cs.umd.edu/~abadi/papers/graph-dedense.pdf
173
- """
174
- if threshold < 2:
175
- raise nx.NetworkXError("The degree threshold must be >= 2")
176
-
177
- degrees = G.in_degree if G.is_directed() else G.degree
178
- # Group nodes based on degree threshold
179
- high_degree_nodes = {n for n, d in degrees if d > threshold}
180
- low_degree_nodes = G.nodes() - high_degree_nodes
181
-
182
- auxiliary = {}
183
- for node in G:
184
- high_degree_nbrs = frozenset(high_degree_nodes & set(G[node]))
185
- if high_degree_nbrs:
186
- if high_degree_nbrs in auxiliary:
187
- auxiliary[high_degree_nbrs].add(node)
188
- else:
189
- auxiliary[high_degree_nbrs] = {node}
190
-
191
- if copy:
192
- G = G.copy()
193
-
194
- compressor_nodes = set()
195
- for index, (high_degree_nodes, low_degree_nodes) in enumerate(auxiliary.items()):
196
- low_degree_node_count = len(low_degree_nodes)
197
- high_degree_node_count = len(high_degree_nodes)
198
- old_edges = high_degree_node_count * low_degree_node_count
199
- new_edges = high_degree_node_count + low_degree_node_count
200
- if old_edges <= new_edges:
201
- continue
202
- compression_node = "".join(str(node) for node in high_degree_nodes)
203
- if prefix:
204
- compression_node = str(prefix) + compression_node
205
- for node in low_degree_nodes:
206
- for high_node in high_degree_nodes:
207
- if G.has_edge(node, high_node):
208
- G.remove_edge(node, high_node)
209
-
210
- G.add_edge(node, compression_node)
211
- for node in high_degree_nodes:
212
- G.add_edge(compression_node, node)
213
- compressor_nodes.add(compression_node)
214
- return G, compressor_nodes
215
-
216
-
217
- def _snap_build_graph(
218
- G,
219
- groups,
220
- node_attributes,
221
- edge_attributes,
222
- neighbor_info,
223
- edge_types,
224
- prefix,
225
- supernode_attribute,
226
- superedge_attribute,
227
- ):
228
- """
229
- Build the summary graph from the data structures produced in the SNAP aggregation algorithm
230
-
231
- Used in the SNAP aggregation algorithm to build the output summary graph and supernode
232
- lookup dictionary. This process uses the original graph and the data structures to
233
- create the supernodes with the correct node attributes, and the superedges with the correct
234
- edge attributes
235
-
236
- Parameters
237
- ----------
238
- G: networkx.Graph
239
- the original graph to be summarized
240
- groups: dict
241
- A dictionary of unique group IDs and their corresponding node groups
242
- node_attributes: iterable
243
- An iterable of the node attributes considered in the summarization process
244
- edge_attributes: iterable
245
- An iterable of the edge attributes considered in the summarization process
246
- neighbor_info: dict
247
- A data structure indicating the number of edges a node has with the
248
- groups in the current summarization of each edge type
249
- edge_types: dict
250
- dictionary of edges in the graph and their corresponding attributes recognized
251
- in the summarization
252
- prefix: string
253
- The prefix to be added to all supernodes
254
- supernode_attribute: str
255
- The node attribute for recording the supernode groupings of nodes
256
- superedge_attribute: str
257
- The edge attribute for recording the edge types represented by superedges
258
-
259
- Returns
260
- -------
261
- summary graph: Networkx graph
262
- """
263
- output = G.__class__()
264
- node_label_lookup = {}
265
- for index, group_id in enumerate(groups):
266
- group_set = groups[group_id]
267
- supernode = f"{prefix}{index}"
268
- node_label_lookup[group_id] = supernode
269
- supernode_attributes = {
270
- attr: G.nodes[next(iter(group_set))][attr] for attr in node_attributes
271
- }
272
- supernode_attributes[supernode_attribute] = group_set
273
- output.add_node(supernode, **supernode_attributes)
274
-
275
- for group_id in groups:
276
- group_set = groups[group_id]
277
- source_supernode = node_label_lookup[group_id]
278
- for other_group, group_edge_types in neighbor_info[
279
- next(iter(group_set))
280
- ].items():
281
- if group_edge_types:
282
- target_supernode = node_label_lookup[other_group]
283
- summary_graph_edge = (source_supernode, target_supernode)
284
-
285
- edge_types = [
286
- dict(zip(edge_attributes, edge_type))
287
- for edge_type in group_edge_types
288
- ]
289
-
290
- has_edge = output.has_edge(*summary_graph_edge)
291
- if output.is_multigraph():
292
- if not has_edge:
293
- for edge_type in edge_types:
294
- output.add_edge(*summary_graph_edge, **edge_type)
295
- elif not output.is_directed():
296
- existing_edge_data = output.get_edge_data(*summary_graph_edge)
297
- for edge_type in edge_types:
298
- if edge_type not in existing_edge_data.values():
299
- output.add_edge(*summary_graph_edge, **edge_type)
300
- else:
301
- superedge_attributes = {superedge_attribute: edge_types}
302
- output.add_edge(*summary_graph_edge, **superedge_attributes)
303
-
304
- return output
305
-
306
-
307
- def _snap_eligible_group(G, groups, group_lookup, edge_types):
308
- """
309
- Determines if a group is eligible to be split.
310
-
311
- A group is eligible to be split if all nodes in the group have edges of the same type(s)
312
- with the same other groups.
313
-
314
- Parameters
315
- ----------
316
- G: graph
317
- graph to be summarized
318
- groups: dict
319
- A dictionary of unique group IDs and their corresponding node groups
320
- group_lookup: dict
321
- dictionary of nodes and their current corresponding group ID
322
- edge_types: dict
323
- dictionary of edges in the graph and their corresponding attributes recognized
324
- in the summarization
325
-
326
- Returns
327
- -------
328
- tuple: group ID to split, and neighbor-groups participation_counts data structure
329
- """
330
- nbr_info = {node: {gid: Counter() for gid in groups} for node in group_lookup}
331
- for group_id in groups:
332
- current_group = groups[group_id]
333
-
334
- # build nbr_info for nodes in group
335
- for node in current_group:
336
- nbr_info[node] = {group_id: Counter() for group_id in groups}
337
- edges = G.edges(node, keys=True) if G.is_multigraph() else G.edges(node)
338
- for edge in edges:
339
- neighbor = edge[1]
340
- edge_type = edge_types[edge]
341
- neighbor_group_id = group_lookup[neighbor]
342
- nbr_info[node][neighbor_group_id][edge_type] += 1
343
-
344
- # check if group_id is eligible to be split
345
- group_size = len(current_group)
346
- for other_group_id in groups:
347
- edge_counts = Counter()
348
- for node in current_group:
349
- edge_counts.update(nbr_info[node][other_group_id].keys())
350
-
351
- if not all(count == group_size for count in edge_counts.values()):
352
- # only the nbr_info of the returned group_id is required for handling group splits
353
- return group_id, nbr_info
354
-
355
- # if no eligible groups, complete nbr_info is calculated
356
- return None, nbr_info
357
-
358
-
359
- def _snap_split(groups, neighbor_info, group_lookup, group_id):
360
- """
361
- Splits a group based on edge types and updates the groups accordingly
362
-
363
- Splits the group with the given group_id based on the edge types
364
- of the nodes so that each new grouping will all have the same
365
- edges with other nodes.
366
-
367
- Parameters
368
- ----------
369
- groups: dict
370
- A dictionary of unique group IDs and their corresponding node groups
371
- neighbor_info: dict
372
- A data structure indicating the number of edges a node has with the
373
- groups in the current summarization of each edge type
374
- edge_types: dict
375
- dictionary of edges in the graph and their corresponding attributes recognized
376
- in the summarization
377
- group_lookup: dict
378
- dictionary of nodes and their current corresponding group ID
379
- group_id: object
380
- ID of group to be split
381
-
382
- Returns
383
- -------
384
- dict
385
- The updated groups based on the split
386
- """
387
- new_group_mappings = defaultdict(set)
388
- for node in groups[group_id]:
389
- signature = tuple(
390
- frozenset(edge_types) for edge_types in neighbor_info[node].values()
391
- )
392
- new_group_mappings[signature].add(node)
393
-
394
- # leave the biggest new_group as the original group
395
- new_groups = sorted(new_group_mappings.values(), key=len)
396
- for new_group in new_groups[:-1]:
397
- # Assign unused integer as the new_group_id
398
- # ids are tuples, so will not interact with the original group_ids
399
- new_group_id = len(groups)
400
- groups[new_group_id] = new_group
401
- groups[group_id] -= new_group
402
- for node in new_group:
403
- group_lookup[node] = new_group_id
404
-
405
- return groups
406
-
407
-
408
- @nx._dispatchable(
409
- node_attrs="[node_attributes]", edge_attrs="[edge_attributes]", returns_graph=True
410
- )
411
- def snap_aggregation(
412
- G,
413
- node_attributes,
414
- edge_attributes=(),
415
- prefix="Supernode-",
416
- supernode_attribute="group",
417
- superedge_attribute="types",
418
- ):
419
- """Creates a summary graph based on attributes and connectivity.
420
-
421
- This function uses the Summarization by Grouping Nodes on Attributes
422
- and Pairwise edges (SNAP) algorithm for summarizing a given
423
- graph by grouping nodes by node attributes and their edge attributes
424
- into supernodes in a summary graph. This name SNAP should not be
425
- confused with the Stanford Network Analysis Project (SNAP).
426
-
427
- Here is a high-level view of how this algorithm works:
428
-
429
- 1) Group nodes by node attribute values.
430
-
431
- 2) Iteratively split groups until all nodes in each group have edges
432
- to nodes in the same groups. That is, until all the groups are homogeneous
433
- in their member nodes' edges to other groups. For example,
434
- if all the nodes in group A only have edge to nodes in group B, then the
435
- group is homogeneous and does not need to be split. If all nodes in group B
436
- have edges with nodes in groups {A, C}, but some also have edges with other
437
- nodes in B, then group B is not homogeneous and needs to be split into
438
- groups have edges with {A, C} and a group of nodes having
439
- edges with {A, B, C}. This way, viewers of the summary graph can
440
- assume that all nodes in the group have the exact same node attributes and
441
- the exact same edges.
442
-
443
- 3) Build the output summary graph, where the groups are represented by
444
- super-nodes. Edges represent the edges shared between all the nodes in each
445
- respective groups.
446
-
447
- A SNAP summary graph can be used to visualize graphs that are too large to display
448
- or visually analyze, or to efficiently identify sets of similar nodes with similar connectivity
449
- patterns to other sets of similar nodes based on specified node and/or edge attributes in a graph.
450
-
451
- Parameters
452
- ----------
453
- G: graph
454
- Networkx Graph to be summarized
455
- node_attributes: iterable, required
456
- An iterable of the node attributes used to group nodes in the summarization process. Nodes
457
- with the same values for these attributes will be grouped together in the summary graph.
458
- edge_attributes: iterable, optional
459
- An iterable of the edge attributes considered in the summarization process. If provided, unique
460
- combinations of the attribute values found in the graph are used to
461
- determine the edge types in the graph. If not provided, all edges
462
- are considered to be of the same type.
463
- prefix: str
464
- The prefix used to denote supernodes in the summary graph. Defaults to 'Supernode-'.
465
- supernode_attribute: str
466
- The node attribute for recording the supernode groupings of nodes. Defaults to 'group'.
467
- superedge_attribute: str
468
- The edge attribute for recording the edge types of multiple edges. Defaults to 'types'.
469
-
470
- Returns
471
- -------
472
- networkx.Graph: summary graph
473
-
474
- Examples
475
- --------
476
- SNAP aggregation takes a graph and summarizes it in the context of user-provided
477
- node and edge attributes such that a viewer can more easily extract and
478
- analyze the information represented by the graph
479
-
480
- >>> nodes = {
481
- ... "A": dict(color="Red"),
482
- ... "B": dict(color="Red"),
483
- ... "C": dict(color="Red"),
484
- ... "D": dict(color="Red"),
485
- ... "E": dict(color="Blue"),
486
- ... "F": dict(color="Blue"),
487
- ... }
488
- >>> edges = [
489
- ... ("A", "E", "Strong"),
490
- ... ("B", "F", "Strong"),
491
- ... ("C", "E", "Weak"),
492
- ... ("D", "F", "Weak"),
493
- ... ]
494
- >>> G = nx.Graph()
495
- >>> for node in nodes:
496
- ... attributes = nodes[node]
497
- ... G.add_node(node, **attributes)
498
- >>> for source, target, type in edges:
499
- ... G.add_edge(source, target, type=type)
500
- >>> node_attributes = ("color",)
501
- >>> edge_attributes = ("type",)
502
- >>> summary_graph = nx.snap_aggregation(
503
- ... G, node_attributes=node_attributes, edge_attributes=edge_attributes
504
- ... )
505
-
506
- Notes
507
- -----
508
- The summary graph produced is called a maximum Attribute-edge
509
- compatible (AR-compatible) grouping. According to [1]_, an
510
- AR-compatible grouping means that all nodes in each group have the same
511
- exact node attribute values and the same exact edges and
512
- edge types to one or more nodes in the same groups. The maximal
513
- AR-compatible grouping is the grouping with the minimal cardinality.
514
-
515
- The AR-compatible grouping is the most detailed grouping provided by
516
- any of the SNAP algorithms.
517
-
518
- References
519
- ----------
520
- .. [1] Y. Tian, R. A. Hankins, and J. M. Patel. Efficient aggregation
521
- for graph summarization. In Proc. 2008 ACM-SIGMOD Int. Conf.
522
- Management of Data (SIGMOD’08), pages 567–580, Vancouver, Canada,
523
- June 2008.
524
- """
525
- edge_types = {
526
- edge: tuple(attrs.get(attr) for attr in edge_attributes)
527
- for edge, attrs in G.edges.items()
528
- }
529
- if not G.is_directed():
530
- if G.is_multigraph():
531
- # list is needed to avoid mutating while iterating
532
- edges = [((v, u, k), etype) for (u, v, k), etype in edge_types.items()]
533
- else:
534
- # list is needed to avoid mutating while iterating
535
- edges = [((v, u), etype) for (u, v), etype in edge_types.items()]
536
- edge_types.update(edges)
537
-
538
- group_lookup = {
539
- node: tuple(attrs[attr] for attr in node_attributes)
540
- for node, attrs in G.nodes.items()
541
- }
542
- groups = defaultdict(set)
543
- for node, node_type in group_lookup.items():
544
- groups[node_type].add(node)
545
-
546
- eligible_group_id, nbr_info = _snap_eligible_group(
547
- G, groups, group_lookup, edge_types
548
- )
549
- while eligible_group_id:
550
- groups = _snap_split(groups, nbr_info, group_lookup, eligible_group_id)
551
- eligible_group_id, nbr_info = _snap_eligible_group(
552
- G, groups, group_lookup, edge_types
553
- )
554
- return _snap_build_graph(
555
- G,
556
- groups,
557
- node_attributes,
558
- edge_attributes,
559
- nbr_info,
560
- edge_types,
561
- prefix,
562
- supernode_attribute,
563
- superedge_attribute,
564
- )