okstra 0.130.4 → 0.131.1

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 +2019 -96
  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,302 +0,0 @@
1
- """Node assortativity coefficients and correlation measures."""
2
-
3
- import networkx as nx
4
- from networkx.algorithms.assortativity.mixing import (
5
- attribute_mixing_matrix,
6
- degree_mixing_matrix,
7
- )
8
- from networkx.algorithms.assortativity.pairs import node_degree_xy
9
-
10
- __all__ = [
11
- "degree_pearson_correlation_coefficient",
12
- "degree_assortativity_coefficient",
13
- "attribute_assortativity_coefficient",
14
- "numeric_assortativity_coefficient",
15
- ]
16
-
17
-
18
- @nx._dispatchable(edge_attrs="weight")
19
- def degree_assortativity_coefficient(G, x="out", y="in", weight=None, nodes=None):
20
- """Compute degree assortativity of graph.
21
-
22
- Assortativity measures the similarity of connections
23
- in the graph with respect to the node degree.
24
-
25
- Parameters
26
- ----------
27
- G : NetworkX graph
28
-
29
- x: string ('in','out')
30
- The degree type for source node (directed graphs only).
31
-
32
- y: string ('in','out')
33
- The degree type for target node (directed graphs only).
34
-
35
- weight: string or None, optional (default=None)
36
- The edge attribute that holds the numerical value used
37
- as a weight. If None, then each edge has weight 1.
38
- The degree is the sum of the edge weights adjacent to the node.
39
-
40
- nodes: list or iterable (optional)
41
- Compute degree assortativity only for nodes in container.
42
- The default is all nodes.
43
-
44
- Returns
45
- -------
46
- r : float
47
- Assortativity of graph by degree.
48
-
49
- Examples
50
- --------
51
- >>> G = nx.path_graph(4)
52
- >>> r = nx.degree_assortativity_coefficient(G)
53
- >>> print(f"{r:3.1f}")
54
- -0.5
55
-
56
- See Also
57
- --------
58
- attribute_assortativity_coefficient
59
- numeric_assortativity_coefficient
60
- degree_mixing_dict
61
- degree_mixing_matrix
62
-
63
- Notes
64
- -----
65
- This computes Eq. (21) in Ref. [1]_ , where e is the joint
66
- probability distribution (mixing matrix) of the degrees. If G is
67
- directed than the matrix e is the joint probability of the
68
- user-specified degree type for the source and target.
69
-
70
- References
71
- ----------
72
- .. [1] M. E. J. Newman, Mixing patterns in networks,
73
- Physical Review E, 67 026126, 2003
74
- .. [2] Foster, J.G., Foster, D.V., Grassberger, P. & Paczuski, M.
75
- Edge direction and the structure of networks, PNAS 107, 10815-20 (2010).
76
- """
77
- if nodes is None:
78
- nodes = G.nodes
79
-
80
- degrees = None
81
-
82
- if G.is_directed():
83
- indeg = (
84
- {d for _, d in G.in_degree(nodes, weight=weight)}
85
- if "in" in (x, y)
86
- else set()
87
- )
88
- outdeg = (
89
- {d for _, d in G.out_degree(nodes, weight=weight)}
90
- if "out" in (x, y)
91
- else set()
92
- )
93
- degrees = set.union(indeg, outdeg)
94
- else:
95
- degrees = {d for _, d in G.degree(nodes, weight=weight)}
96
-
97
- mapping = {d: i for i, d in enumerate(degrees)}
98
- M = degree_mixing_matrix(G, x=x, y=y, nodes=nodes, weight=weight, mapping=mapping)
99
-
100
- return _numeric_ac(M, mapping=mapping)
101
-
102
-
103
- @nx._dispatchable(edge_attrs="weight")
104
- def degree_pearson_correlation_coefficient(G, x="out", y="in", weight=None, nodes=None):
105
- """Compute degree assortativity of graph.
106
-
107
- Assortativity measures the similarity of connections
108
- in the graph with respect to the node degree.
109
-
110
- This is the same as degree_assortativity_coefficient but uses the
111
- potentially faster scipy.stats.pearsonr function.
112
-
113
- Parameters
114
- ----------
115
- G : NetworkX graph
116
-
117
- x: string ('in','out')
118
- The degree type for source node (directed graphs only).
119
-
120
- y: string ('in','out')
121
- The degree type for target node (directed graphs only).
122
-
123
- weight: string or None, optional (default=None)
124
- The edge attribute that holds the numerical value used
125
- as a weight. If None, then each edge has weight 1.
126
- The degree is the sum of the edge weights adjacent to the node.
127
-
128
- nodes: list or iterable (optional)
129
- Compute pearson correlation of degrees only for specified nodes.
130
- The default is all nodes.
131
-
132
- Returns
133
- -------
134
- r : float
135
- Assortativity of graph by degree.
136
-
137
- Examples
138
- --------
139
- >>> G = nx.path_graph(4)
140
- >>> r = nx.degree_pearson_correlation_coefficient(G)
141
- >>> print(f"{r:3.1f}")
142
- -0.5
143
-
144
- Notes
145
- -----
146
- This calls scipy.stats.pearsonr.
147
-
148
- References
149
- ----------
150
- .. [1] M. E. J. Newman, Mixing patterns in networks
151
- Physical Review E, 67 026126, 2003
152
- .. [2] Foster, J.G., Foster, D.V., Grassberger, P. & Paczuski, M.
153
- Edge direction and the structure of networks, PNAS 107, 10815-20 (2010).
154
- """
155
- import scipy as sp
156
-
157
- xy = node_degree_xy(G, x=x, y=y, nodes=nodes, weight=weight)
158
- x, y = zip(*xy)
159
- return float(sp.stats.pearsonr(x, y)[0])
160
-
161
-
162
- @nx._dispatchable(node_attrs="attribute")
163
- def attribute_assortativity_coefficient(G, attribute, nodes=None):
164
- """Compute assortativity for node attributes.
165
-
166
- Assortativity measures the similarity of connections
167
- in the graph with respect to the given attribute.
168
-
169
- Parameters
170
- ----------
171
- G : NetworkX graph
172
-
173
- attribute : string
174
- Node attribute key
175
-
176
- nodes: list or iterable (optional)
177
- Compute attribute assortativity for nodes in container.
178
- The default is all nodes.
179
-
180
- Returns
181
- -------
182
- r: float
183
- Assortativity of graph for given attribute
184
-
185
- Examples
186
- --------
187
- >>> G = nx.Graph()
188
- >>> G.add_nodes_from([0, 1], color="red")
189
- >>> G.add_nodes_from([2, 3], color="blue")
190
- >>> G.add_edges_from([(0, 1), (2, 3)])
191
- >>> print(nx.attribute_assortativity_coefficient(G, "color"))
192
- 1.0
193
-
194
- Notes
195
- -----
196
- This computes Eq. (2) in Ref. [1]_ , (trace(M)-sum(M^2))/(1-sum(M^2)),
197
- where M is the joint probability distribution (mixing matrix)
198
- of the specified attribute.
199
-
200
- References
201
- ----------
202
- .. [1] M. E. J. Newman, Mixing patterns in networks,
203
- Physical Review E, 67 026126, 2003
204
- """
205
- M = attribute_mixing_matrix(G, attribute, nodes)
206
- return attribute_ac(M)
207
-
208
-
209
- @nx._dispatchable(node_attrs="attribute")
210
- def numeric_assortativity_coefficient(G, attribute, nodes=None):
211
- """Compute assortativity for numerical node attributes.
212
-
213
- Assortativity measures the similarity of connections
214
- in the graph with respect to the given numeric attribute.
215
-
216
- Parameters
217
- ----------
218
- G : NetworkX graph
219
-
220
- attribute : string
221
- Node attribute key.
222
-
223
- nodes: list or iterable (optional)
224
- Compute numeric assortativity only for attributes of nodes in
225
- container. The default is all nodes.
226
-
227
- Returns
228
- -------
229
- r: float
230
- Assortativity of graph for given attribute
231
-
232
- Examples
233
- --------
234
- >>> G = nx.Graph()
235
- >>> G.add_nodes_from([0, 1], size=2)
236
- >>> G.add_nodes_from([2, 3], size=3)
237
- >>> G.add_edges_from([(0, 1), (2, 3)])
238
- >>> print(nx.numeric_assortativity_coefficient(G, "size"))
239
- 1.0
240
-
241
- Notes
242
- -----
243
- This computes Eq. (21) in Ref. [1]_ , which is the Pearson correlation
244
- coefficient of the specified (scalar valued) attribute across edges.
245
-
246
- References
247
- ----------
248
- .. [1] M. E. J. Newman, Mixing patterns in networks
249
- Physical Review E, 67 026126, 2003
250
- """
251
- if nodes is None:
252
- nodes = G.nodes
253
- vals = {G.nodes[n][attribute] for n in nodes}
254
- mapping = {d: i for i, d in enumerate(vals)}
255
- M = attribute_mixing_matrix(G, attribute, nodes, mapping)
256
- return _numeric_ac(M, mapping)
257
-
258
-
259
- def attribute_ac(M):
260
- """Compute assortativity for attribute matrix M.
261
-
262
- Parameters
263
- ----------
264
- M : numpy.ndarray
265
- 2D ndarray representing the attribute mixing matrix.
266
-
267
- Notes
268
- -----
269
- This computes Eq. (2) in Ref. [1]_ , (trace(e)-sum(e^2))/(1-sum(e^2)),
270
- where e is the joint probability distribution (mixing matrix)
271
- of the specified attribute.
272
-
273
- References
274
- ----------
275
- .. [1] M. E. J. Newman, Mixing patterns in networks,
276
- Physical Review E, 67 026126, 2003
277
- """
278
- if M.sum() != 1.0:
279
- M = M / M.sum()
280
- s = (M @ M).sum()
281
- t = M.trace()
282
- r = (t - s) / (1 - s)
283
- return float(r)
284
-
285
-
286
- def _numeric_ac(M, mapping):
287
- # M is a 2D numpy array
288
- # numeric assortativity coefficient, pearsonr
289
- import numpy as np
290
-
291
- if M.sum() != 1.0:
292
- M = M / M.sum()
293
- x = np.array(list(mapping.keys()))
294
- y = x # x and y have the same support
295
- idx = list(mapping.values())
296
- a = M.sum(axis=0)
297
- b = M.sum(axis=1)
298
- vara = (a[idx] * x**2).sum() - ((a[idx] * x).sum()) ** 2
299
- varb = (b[idx] * y**2).sum() - ((b[idx] * y).sum()) ** 2
300
- xy = np.outer(x, y)
301
- ab = np.outer(a[idx], b[idx])
302
- return float((xy * (M - ab)).sum() / np.sqrt(vara * varb))
@@ -1,255 +0,0 @@
1
- """
2
- Mixing matrices for node attributes and degree.
3
- """
4
-
5
- import networkx as nx
6
- from networkx.algorithms.assortativity.pairs import node_attribute_xy, node_degree_xy
7
- from networkx.utils import dict_to_numpy_array
8
-
9
- __all__ = [
10
- "attribute_mixing_matrix",
11
- "attribute_mixing_dict",
12
- "degree_mixing_matrix",
13
- "degree_mixing_dict",
14
- "mixing_dict",
15
- ]
16
-
17
-
18
- @nx._dispatchable(node_attrs="attribute")
19
- def attribute_mixing_dict(G, attribute, nodes=None, normalized=False):
20
- """Returns dictionary representation of mixing matrix for attribute.
21
-
22
- Parameters
23
- ----------
24
- G : graph
25
- NetworkX graph object.
26
-
27
- attribute : string
28
- Node attribute key.
29
-
30
- nodes: list or iterable (optional)
31
- Unse nodes in container to build the dict. The default is all nodes.
32
-
33
- normalized : bool (default=False)
34
- Return counts if False or probabilities if True.
35
-
36
- Examples
37
- --------
38
- >>> G = nx.Graph()
39
- >>> G.add_nodes_from([0, 1], color="red")
40
- >>> G.add_nodes_from([2, 3], color="blue")
41
- >>> G.add_edge(1, 3)
42
- >>> d = nx.attribute_mixing_dict(G, "color")
43
- >>> print(d["red"]["blue"])
44
- 1
45
- >>> print(d["blue"]["red"]) # d symmetric for undirected graphs
46
- 1
47
-
48
- Returns
49
- -------
50
- d : dictionary
51
- Counts or joint probability of occurrence of attribute pairs.
52
- """
53
- xy_iter = node_attribute_xy(G, attribute, nodes)
54
- return mixing_dict(xy_iter, normalized=normalized)
55
-
56
-
57
- @nx._dispatchable(node_attrs="attribute")
58
- def attribute_mixing_matrix(G, attribute, nodes=None, mapping=None, normalized=True):
59
- """Returns mixing matrix for attribute.
60
-
61
- Parameters
62
- ----------
63
- G : graph
64
- NetworkX graph object.
65
-
66
- attribute : string
67
- Node attribute key.
68
-
69
- nodes: list or iterable (optional)
70
- Use only nodes in container to build the matrix. The default is
71
- all nodes.
72
-
73
- mapping : dictionary, optional
74
- Mapping from node attribute to integer index in matrix.
75
- If not specified, an arbitrary ordering will be used.
76
-
77
- normalized : bool (default=True)
78
- Return counts if False or probabilities if True.
79
-
80
- Returns
81
- -------
82
- m: numpy array
83
- Counts or joint probability of occurrence of attribute pairs.
84
-
85
- Notes
86
- -----
87
- If each node has a unique attribute value, the unnormalized mixing matrix
88
- will be equal to the adjacency matrix. To get a denser mixing matrix,
89
- the rounding can be performed to form groups of nodes with equal values.
90
- For example, the exact height of persons in cm (180.79155222, 163.9080892,
91
- 163.30095355, 167.99016217, 168.21590163, ...) can be rounded to (180, 163,
92
- 163, 168, 168, ...).
93
-
94
- Definitions of attribute mixing matrix vary on whether the matrix
95
- should include rows for attribute values that don't arise. Here we
96
- do not include such empty-rows. But you can force them to appear
97
- by inputting a `mapping` that includes those values.
98
-
99
- Examples
100
- --------
101
- >>> G = nx.path_graph(3)
102
- >>> gender = {0: "male", 1: "female", 2: "female"}
103
- >>> nx.set_node_attributes(G, gender, "gender")
104
- >>> mapping = {"male": 0, "female": 1}
105
- >>> mix_mat = nx.attribute_mixing_matrix(G, "gender", mapping=mapping)
106
- >>> mix_mat
107
- array([[0. , 0.25],
108
- [0.25, 0.5 ]])
109
- """
110
- d = attribute_mixing_dict(G, attribute, nodes)
111
- a = dict_to_numpy_array(d, mapping=mapping)
112
- if normalized:
113
- a = a / a.sum()
114
- return a
115
-
116
-
117
- @nx._dispatchable(edge_attrs="weight")
118
- def degree_mixing_dict(G, x="out", y="in", weight=None, nodes=None, normalized=False):
119
- """Returns dictionary representation of mixing matrix for degree.
120
-
121
- Parameters
122
- ----------
123
- G : graph
124
- NetworkX graph object.
125
-
126
- x: string ('in','out')
127
- The degree type for source node (directed graphs only).
128
-
129
- y: string ('in','out')
130
- The degree type for target node (directed graphs only).
131
-
132
- weight: string or None, optional (default=None)
133
- The edge attribute that holds the numerical value used
134
- as a weight. If None, then each edge has weight 1.
135
- The degree is the sum of the edge weights adjacent to the node.
136
-
137
- normalized : bool (default=False)
138
- Return counts if False or probabilities if True.
139
-
140
- Returns
141
- -------
142
- d: dictionary
143
- Counts or joint probability of occurrence of degree pairs.
144
- """
145
- xy_iter = node_degree_xy(G, x=x, y=y, nodes=nodes, weight=weight)
146
- return mixing_dict(xy_iter, normalized=normalized)
147
-
148
-
149
- @nx._dispatchable(edge_attrs="weight")
150
- def degree_mixing_matrix(
151
- G, x="out", y="in", weight=None, nodes=None, normalized=True, mapping=None
152
- ):
153
- """Returns mixing matrix for attribute.
154
-
155
- Parameters
156
- ----------
157
- G : graph
158
- NetworkX graph object.
159
-
160
- x: string ('in','out')
161
- The degree type for source node (directed graphs only).
162
-
163
- y: string ('in','out')
164
- The degree type for target node (directed graphs only).
165
-
166
- nodes: list or iterable (optional)
167
- Build the matrix using only nodes in container.
168
- The default is all nodes.
169
-
170
- weight: string or None, optional (default=None)
171
- The edge attribute that holds the numerical value used
172
- as a weight. If None, then each edge has weight 1.
173
- The degree is the sum of the edge weights adjacent to the node.
174
-
175
- normalized : bool (default=True)
176
- Return counts if False or probabilities if True.
177
-
178
- mapping : dictionary, optional
179
- Mapping from node degree to integer index in matrix.
180
- If not specified, an arbitrary ordering will be used.
181
-
182
- Returns
183
- -------
184
- m: numpy array
185
- Counts, or joint probability, of occurrence of node degree.
186
-
187
- Notes
188
- -----
189
- Definitions of degree mixing matrix vary on whether the matrix
190
- should include rows for degree values that don't arise. Here we
191
- do not include such empty-rows. But you can force them to appear
192
- by inputting a `mapping` that includes those values. See examples.
193
-
194
- Examples
195
- --------
196
- >>> G = nx.star_graph(3)
197
- >>> mix_mat = nx.degree_mixing_matrix(G)
198
- >>> mix_mat
199
- array([[0. , 0.5],
200
- [0.5, 0. ]])
201
-
202
- If you want every possible degree to appear as a row, even if no nodes
203
- have that degree, use `mapping` as follows,
204
-
205
- >>> max_degree = max(deg for n, deg in G.degree)
206
- >>> mapping = {x: x for x in range(max_degree + 1)} # identity mapping
207
- >>> mix_mat = nx.degree_mixing_matrix(G, mapping=mapping)
208
- >>> mix_mat
209
- array([[0. , 0. , 0. , 0. ],
210
- [0. , 0. , 0. , 0.5],
211
- [0. , 0. , 0. , 0. ],
212
- [0. , 0.5, 0. , 0. ]])
213
- """
214
- d = degree_mixing_dict(G, x=x, y=y, nodes=nodes, weight=weight)
215
- a = dict_to_numpy_array(d, mapping=mapping)
216
- if normalized:
217
- a = a / a.sum()
218
- return a
219
-
220
-
221
- def mixing_dict(xy, normalized=False):
222
- """Returns a dictionary representation of mixing matrix.
223
-
224
- Parameters
225
- ----------
226
- xy : list or container of two-tuples
227
- Pairs of (x,y) items.
228
-
229
- attribute : string
230
- Node attribute key
231
-
232
- normalized : bool (default=False)
233
- Return counts if False or probabilities if True.
234
-
235
- Returns
236
- -------
237
- d: dictionary
238
- Counts or Joint probability of occurrence of values in xy.
239
- """
240
- d = {}
241
- psum = 0.0
242
- for x, y in xy:
243
- if x not in d:
244
- d[x] = {}
245
- if y not in d:
246
- d[y] = {}
247
- v = d[x].get(y, 0)
248
- d[x][y] = v + 1
249
- psum += 1
250
-
251
- if normalized:
252
- for _, jdict in d.items():
253
- for j in jdict:
254
- jdict[j] /= psum
255
- return d
@@ -1,160 +0,0 @@
1
- import networkx as nx
2
-
3
- __all__ = ["average_neighbor_degree"]
4
-
5
-
6
- @nx._dispatchable(edge_attrs="weight")
7
- def average_neighbor_degree(G, source="out", target="out", nodes=None, weight=None):
8
- r"""Returns the average degree of the neighborhood of each node.
9
-
10
- In an undirected graph, the neighborhood `N(i)` of node `i` contains the
11
- nodes that are connected to `i` by an edge.
12
-
13
- For directed graphs, `N(i)` is defined according to the parameter `source`:
14
-
15
- - if source is 'in', then `N(i)` consists of predecessors of node `i`.
16
- - if source is 'out', then `N(i)` consists of successors of node `i`.
17
- - if source is 'in+out', then `N(i)` is both predecessors and successors.
18
-
19
- The average neighborhood degree of a node `i` is
20
-
21
- .. math::
22
-
23
- k_{nn,i} = \frac{1}{|N(i)|} \sum_{j \in N(i)} k_j
24
-
25
- where `N(i)` are the neighbors of node `i` and `k_j` is
26
- the degree of node `j` which belongs to `N(i)`. For weighted
27
- graphs, an analogous measure can be defined [1]_,
28
-
29
- .. math::
30
-
31
- k_{nn,i}^{w} = \frac{1}{s_i} \sum_{j \in N(i)} w_{ij} k_j
32
-
33
- where `s_i` is the weighted degree of node `i`, `w_{ij}`
34
- is the weight of the edge that links `i` and `j` and
35
- `N(i)` are the neighbors of node `i`.
36
-
37
-
38
- Parameters
39
- ----------
40
- G : NetworkX graph
41
-
42
- source : string ("in"|"out"|"in+out"), optional (default="out")
43
- Directed graphs only.
44
- Use "in"- or "out"-neighbors of source node.
45
-
46
- target : string ("in"|"out"|"in+out"), optional (default="out")
47
- Directed graphs only.
48
- Use "in"- or "out"-degree for target node.
49
-
50
- nodes : list or iterable, optional (default=G.nodes)
51
- Compute neighbor degree only for specified nodes.
52
-
53
- weight : string or None, optional (default=None)
54
- The edge attribute that holds the numerical value used as a weight.
55
- If None, then each edge has weight 1.
56
-
57
- Returns
58
- -------
59
- d: dict
60
- A dictionary keyed by node to the average degree of its neighbors.
61
-
62
- Raises
63
- ------
64
- NetworkXError
65
- If either `source` or `target` are not one of 'in', 'out', or 'in+out'.
66
- If either `source` or `target` is passed for an undirected graph.
67
-
68
- Examples
69
- --------
70
- >>> G = nx.path_graph(4)
71
- >>> G.edges[0, 1]["weight"] = 5
72
- >>> G.edges[2, 3]["weight"] = 3
73
-
74
- >>> nx.average_neighbor_degree(G)
75
- {0: 2.0, 1: 1.5, 2: 1.5, 3: 2.0}
76
- >>> nx.average_neighbor_degree(G, weight="weight")
77
- {0: 2.0, 1: 1.1666666666666667, 2: 1.25, 3: 2.0}
78
-
79
- >>> G = nx.DiGraph()
80
- >>> nx.add_path(G, [0, 1, 2, 3])
81
- >>> nx.average_neighbor_degree(G, source="in", target="in")
82
- {0: 0.0, 1: 0.0, 2: 1.0, 3: 1.0}
83
-
84
- >>> nx.average_neighbor_degree(G, source="out", target="out")
85
- {0: 1.0, 1: 1.0, 2: 0.0, 3: 0.0}
86
-
87
- See Also
88
- --------
89
- average_degree_connectivity
90
-
91
- References
92
- ----------
93
- .. [1] A. Barrat, M. Barthélemy, R. Pastor-Satorras, and A. Vespignani,
94
- "The architecture of complex weighted networks".
95
- PNAS 101 (11): 3747–3752 (2004).
96
- """
97
- if G.is_directed():
98
- if source == "in":
99
- source_degree = G.in_degree
100
- elif source == "out":
101
- source_degree = G.out_degree
102
- elif source == "in+out":
103
- source_degree = G.degree
104
- else:
105
- raise nx.NetworkXError(
106
- f"source argument {source} must be 'in', 'out' or 'in+out'"
107
- )
108
-
109
- if target == "in":
110
- target_degree = G.in_degree
111
- elif target == "out":
112
- target_degree = G.out_degree
113
- elif target == "in+out":
114
- target_degree = G.degree
115
- else:
116
- raise nx.NetworkXError(
117
- f"target argument {target} must be 'in', 'out' or 'in+out'"
118
- )
119
- else:
120
- if source != "out" or target != "out":
121
- raise nx.NetworkXError(
122
- f"source and target arguments are only supported for directed graphs"
123
- )
124
- source_degree = target_degree = G.degree
125
-
126
- # precompute target degrees -- should *not* be weighted degree
127
- t_deg = dict(target_degree())
128
-
129
- # Set up both predecessor and successor neighbor dicts leaving empty if not needed
130
- G_P = G_S = {n: {} for n in G}
131
- if G.is_directed():
132
- # "in" or "in+out" cases: G_P contains predecessors
133
- if "in" in source:
134
- G_P = G.pred
135
- # "out" or "in+out" cases: G_S contains successors
136
- if "out" in source:
137
- G_S = G.succ
138
- else:
139
- # undirected leave G_P empty but G_S is the adjacency
140
- G_S = G.adj
141
-
142
- # Main loop: Compute average degree of neighbors
143
- avg = {}
144
- for n, deg in source_degree(nodes, weight=weight):
145
- # handle degree zero average
146
- if deg == 0:
147
- avg[n] = 0.0
148
- continue
149
-
150
- # we sum over both G_P and G_S, but one of the two is usually empty.
151
- if weight is None:
152
- avg[n] = (
153
- sum(t_deg[nbr] for nbr in G_S[n]) + sum(t_deg[nbr] for nbr in G_P[n])
154
- ) / deg
155
- else:
156
- avg[n] = (
157
- sum(dd.get(weight, 1) * t_deg[nbr] for nbr, dd in G_S[n].items())
158
- + sum(dd.get(weight, 1) * t_deg[nbr] for nbr, dd in G_P[n].items())
159
- ) / deg
160
- return avg