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,526 +0,0 @@
1
- """One-mode (unipartite) projections of bipartite graphs."""
2
-
3
- import networkx as nx
4
- from networkx.exception import NetworkXAlgorithmError
5
- from networkx.utils import not_implemented_for
6
-
7
- __all__ = [
8
- "projected_graph",
9
- "weighted_projected_graph",
10
- "collaboration_weighted_projected_graph",
11
- "overlap_weighted_projected_graph",
12
- "generic_weighted_projected_graph",
13
- ]
14
-
15
-
16
- @nx._dispatchable(
17
- graphs="B", preserve_node_attrs=True, preserve_graph_attrs=True, returns_graph=True
18
- )
19
- def projected_graph(B, nodes, multigraph=False):
20
- r"""Returns the projection of B onto one of its node sets.
21
-
22
- Returns the graph G that is the projection of the bipartite graph B
23
- onto the specified nodes. They retain their attributes and are connected
24
- in G if they have a common neighbor in B.
25
-
26
- Parameters
27
- ----------
28
- B : NetworkX graph
29
- The input graph should be bipartite.
30
-
31
- nodes : list or iterable
32
- Nodes to project onto (the "bottom" nodes).
33
-
34
- multigraph: bool (default=False)
35
- If True return a multigraph where the multiple edges represent multiple
36
- shared neighbors. They edge key in the multigraph is assigned to the
37
- label of the neighbor.
38
-
39
- Returns
40
- -------
41
- Graph : NetworkX graph or multigraph
42
- A graph that is the projection onto the given nodes.
43
-
44
- Examples
45
- --------
46
- >>> from networkx.algorithms import bipartite
47
- >>> B = nx.path_graph(4)
48
- >>> G = bipartite.projected_graph(B, [1, 3])
49
- >>> list(G)
50
- [1, 3]
51
- >>> list(G.edges())
52
- [(1, 3)]
53
-
54
- If nodes `a`, and `b` are connected through both nodes 1 and 2 then
55
- building a multigraph results in two edges in the projection onto
56
- [`a`, `b`]:
57
-
58
- >>> B = nx.Graph()
59
- >>> B.add_edges_from([("a", 1), ("b", 1), ("a", 2), ("b", 2)])
60
- >>> G = bipartite.projected_graph(B, ["a", "b"], multigraph=True)
61
- >>> print([sorted((u, v)) for u, v in G.edges()])
62
- [['a', 'b'], ['a', 'b']]
63
-
64
- Notes
65
- -----
66
- No attempt is made to verify that the input graph B is bipartite.
67
- Returns a simple graph that is the projection of the bipartite graph B
68
- onto the set of nodes given in list nodes. If multigraph=True then
69
- a multigraph is returned with an edge for every shared neighbor.
70
-
71
- Directed graphs are allowed as input. The output will also then
72
- be a directed graph with edges if there is a directed path between
73
- the nodes.
74
-
75
- The graph and node properties are (shallow) copied to the projected graph.
76
-
77
- See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
78
- for further details on how bipartite graphs are handled in NetworkX.
79
-
80
- See Also
81
- --------
82
- is_bipartite,
83
- is_bipartite_node_set,
84
- sets,
85
- weighted_projected_graph,
86
- collaboration_weighted_projected_graph,
87
- overlap_weighted_projected_graph,
88
- generic_weighted_projected_graph
89
- """
90
- if B.is_multigraph():
91
- raise nx.NetworkXError("not defined for multigraphs")
92
- if B.is_directed():
93
- directed = True
94
- if multigraph:
95
- G = nx.MultiDiGraph()
96
- else:
97
- G = nx.DiGraph()
98
- else:
99
- directed = False
100
- if multigraph:
101
- G = nx.MultiGraph()
102
- else:
103
- G = nx.Graph()
104
- G.graph.update(B.graph)
105
- G.add_nodes_from((n, B.nodes[n]) for n in nodes)
106
- for u in nodes:
107
- nbrs2 = {v for nbr in B[u] for v in B[nbr] if v != u}
108
- if multigraph:
109
- for n in nbrs2:
110
- if directed:
111
- links = set(B[u]) & set(B.pred[n])
112
- else:
113
- links = set(B[u]) & set(B[n])
114
- for l in links:
115
- if not G.has_edge(u, n, l):
116
- G.add_edge(u, n, key=l)
117
- else:
118
- G.add_edges_from((u, n) for n in nbrs2)
119
- return G
120
-
121
-
122
- @not_implemented_for("multigraph")
123
- @nx._dispatchable(graphs="B", returns_graph=True)
124
- def weighted_projected_graph(B, nodes, ratio=False):
125
- r"""Returns a weighted projection of B onto one of its node sets.
126
-
127
- The weighted projected graph is the projection of the bipartite
128
- network B onto the specified nodes with weights representing the
129
- number of shared neighbors or the ratio between actual shared
130
- neighbors and possible shared neighbors if ``ratio is True`` [1]_.
131
- The nodes retain their attributes and are connected in the resulting
132
- graph if they have an edge to a common node in the original graph.
133
-
134
- Parameters
135
- ----------
136
- B : NetworkX graph
137
- The input graph should be bipartite.
138
-
139
- nodes : list or iterable
140
- Distinct nodes to project onto (the "bottom" nodes).
141
-
142
- ratio: Bool (default=False)
143
- If True, edge weight is the ratio between actual shared neighbors
144
- and maximum possible shared neighbors (i.e., the size of the other
145
- node set). If False, edges weight is the number of shared neighbors.
146
-
147
- Returns
148
- -------
149
- Graph : NetworkX graph
150
- A graph that is the projection onto the given nodes.
151
-
152
- Examples
153
- --------
154
- >>> from networkx.algorithms import bipartite
155
- >>> B = nx.path_graph(4)
156
- >>> G = bipartite.weighted_projected_graph(B, [1, 3])
157
- >>> list(G)
158
- [1, 3]
159
- >>> list(G.edges(data=True))
160
- [(1, 3, {'weight': 1})]
161
- >>> G = bipartite.weighted_projected_graph(B, [1, 3], ratio=True)
162
- >>> list(G.edges(data=True))
163
- [(1, 3, {'weight': 0.5})]
164
-
165
- Notes
166
- -----
167
- No attempt is made to verify that the input graph B is bipartite, or that
168
- the input nodes are distinct. However, if the length of the input nodes is
169
- greater than or equal to the nodes in the graph B, an exception is raised.
170
- If the nodes are not distinct but don't raise this error, the output weights
171
- will be incorrect.
172
- The graph and node properties are (shallow) copied to the projected graph.
173
-
174
- See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
175
- for further details on how bipartite graphs are handled in NetworkX.
176
-
177
- See Also
178
- --------
179
- is_bipartite,
180
- is_bipartite_node_set,
181
- sets,
182
- collaboration_weighted_projected_graph,
183
- overlap_weighted_projected_graph,
184
- generic_weighted_projected_graph
185
- projected_graph
186
-
187
- References
188
- ----------
189
- .. [1] Borgatti, S.P. and Halgin, D. In press. "Analyzing Affiliation
190
- Networks". In Carrington, P. and Scott, J. (eds) The Sage Handbook
191
- of Social Network Analysis. Sage Publications.
192
- """
193
- if B.is_directed():
194
- pred = B.pred
195
- G = nx.DiGraph()
196
- else:
197
- pred = B.adj
198
- G = nx.Graph()
199
- G.graph.update(B.graph)
200
- G.add_nodes_from((n, B.nodes[n]) for n in nodes)
201
- n_top = len(B) - len(nodes)
202
-
203
- if n_top < 1:
204
- raise NetworkXAlgorithmError(
205
- f"the size of the nodes to project onto ({len(nodes)}) is >= the graph size ({len(B)}).\n"
206
- "They are either not a valid bipartite partition or contain duplicates"
207
- )
208
-
209
- for u in nodes:
210
- unbrs = set(B[u])
211
- nbrs2 = {n for nbr in unbrs for n in B[nbr]} - {u}
212
- for v in nbrs2:
213
- vnbrs = set(pred[v])
214
- common = unbrs & vnbrs
215
- if not ratio:
216
- weight = len(common)
217
- else:
218
- weight = len(common) / n_top
219
- G.add_edge(u, v, weight=weight)
220
- return G
221
-
222
-
223
- @not_implemented_for("multigraph")
224
- @nx._dispatchable(graphs="B", returns_graph=True)
225
- def collaboration_weighted_projected_graph(B, nodes):
226
- r"""Newman's weighted projection of B onto one of its node sets.
227
-
228
- The collaboration weighted projection is the projection of the
229
- bipartite network B onto the specified nodes with weights assigned
230
- using Newman's collaboration model [1]_:
231
-
232
- .. math::
233
-
234
- w_{u, v} = \sum_k \frac{\delta_{u}^{k} \delta_{v}^{k}}{d_k - 1}
235
-
236
- where `u` and `v` are nodes from the bottom bipartite node set,
237
- and `k` is a node of the top node set.
238
- The value `d_k` is the degree of node `k` in the bipartite
239
- network and `\delta_{u}^{k}` is 1 if node `u` is
240
- linked to node `k` in the original bipartite graph or 0 otherwise.
241
-
242
- The nodes retain their attributes and are connected in the resulting
243
- graph if have an edge to a common node in the original bipartite
244
- graph.
245
-
246
- Parameters
247
- ----------
248
- B : NetworkX graph
249
- The input graph should be bipartite.
250
-
251
- nodes : list or iterable
252
- Nodes to project onto (the "bottom" nodes).
253
-
254
- Returns
255
- -------
256
- Graph : NetworkX graph
257
- A graph that is the projection onto the given nodes.
258
-
259
- Examples
260
- --------
261
- >>> from networkx.algorithms import bipartite
262
- >>> B = nx.path_graph(5)
263
- >>> B.add_edge(1, 5)
264
- >>> G = bipartite.collaboration_weighted_projected_graph(B, [0, 2, 4, 5])
265
- >>> list(G)
266
- [0, 2, 4, 5]
267
- >>> for edge in sorted(G.edges(data=True)):
268
- ... print(edge)
269
- (0, 2, {'weight': 0.5})
270
- (0, 5, {'weight': 0.5})
271
- (2, 4, {'weight': 1.0})
272
- (2, 5, {'weight': 0.5})
273
-
274
- Notes
275
- -----
276
- No attempt is made to verify that the input graph B is bipartite.
277
- The graph and node properties are (shallow) copied to the projected graph.
278
-
279
- See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
280
- for further details on how bipartite graphs are handled in NetworkX.
281
-
282
- See Also
283
- --------
284
- is_bipartite,
285
- is_bipartite_node_set,
286
- sets,
287
- weighted_projected_graph,
288
- overlap_weighted_projected_graph,
289
- generic_weighted_projected_graph,
290
- projected_graph
291
-
292
- References
293
- ----------
294
- .. [1] Scientific collaboration networks: II.
295
- Shortest paths, weighted networks, and centrality,
296
- M. E. J. Newman, Phys. Rev. E 64, 016132 (2001).
297
- """
298
- if B.is_directed():
299
- pred = B.pred
300
- G = nx.DiGraph()
301
- else:
302
- pred = B.adj
303
- G = nx.Graph()
304
- G.graph.update(B.graph)
305
- G.add_nodes_from((n, B.nodes[n]) for n in nodes)
306
- for u in nodes:
307
- unbrs = set(B[u])
308
- nbrs2 = {n for nbr in unbrs for n in B[nbr] if n != u}
309
- for v in nbrs2:
310
- vnbrs = set(pred[v])
311
- common_degree = (len(B[n]) for n in unbrs & vnbrs)
312
- weight = sum(1.0 / (deg - 1) for deg in common_degree if deg > 1)
313
- G.add_edge(u, v, weight=weight)
314
- return G
315
-
316
-
317
- @not_implemented_for("multigraph")
318
- @nx._dispatchable(graphs="B", returns_graph=True)
319
- def overlap_weighted_projected_graph(B, nodes, jaccard=True):
320
- r"""Overlap weighted projection of B onto one of its node sets.
321
-
322
- The overlap weighted projection is the projection of the bipartite
323
- network B onto the specified nodes with weights representing
324
- the Jaccard index between the neighborhoods of the two nodes in the
325
- original bipartite network [1]_:
326
-
327
- .. math::
328
-
329
- w_{v, u} = \frac{|N(u) \cap N(v)|}{|N(u) \cup N(v)|}
330
-
331
- or if the parameter 'jaccard' is False, the fraction of common
332
- neighbors by minimum of both nodes degree in the original
333
- bipartite graph [1]_:
334
-
335
- .. math::
336
-
337
- w_{v, u} = \frac{|N(u) \cap N(v)|}{min(|N(u)|, |N(v)|)}
338
-
339
- The nodes retain their attributes and are connected in the resulting
340
- graph if have an edge to a common node in the original bipartite graph.
341
-
342
- Parameters
343
- ----------
344
- B : NetworkX graph
345
- The input graph should be bipartite.
346
-
347
- nodes : list or iterable
348
- Nodes to project onto (the "bottom" nodes).
349
-
350
- jaccard: Bool (default=True)
351
-
352
- Returns
353
- -------
354
- Graph : NetworkX graph
355
- A graph that is the projection onto the given nodes.
356
-
357
- Examples
358
- --------
359
- >>> from networkx.algorithms import bipartite
360
- >>> B = nx.path_graph(5)
361
- >>> nodes = [0, 2, 4]
362
- >>> G = bipartite.overlap_weighted_projected_graph(B, nodes)
363
- >>> list(G)
364
- [0, 2, 4]
365
- >>> list(G.edges(data=True))
366
- [(0, 2, {'weight': 0.5}), (2, 4, {'weight': 0.5})]
367
- >>> G = bipartite.overlap_weighted_projected_graph(B, nodes, jaccard=False)
368
- >>> list(G.edges(data=True))
369
- [(0, 2, {'weight': 1.0}), (2, 4, {'weight': 1.0})]
370
-
371
- Notes
372
- -----
373
- No attempt is made to verify that the input graph B is bipartite.
374
- The graph and node properties are (shallow) copied to the projected graph.
375
-
376
- See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
377
- for further details on how bipartite graphs are handled in NetworkX.
378
-
379
- See Also
380
- --------
381
- is_bipartite,
382
- is_bipartite_node_set,
383
- sets,
384
- weighted_projected_graph,
385
- collaboration_weighted_projected_graph,
386
- generic_weighted_projected_graph,
387
- projected_graph
388
-
389
- References
390
- ----------
391
- .. [1] Borgatti, S.P. and Halgin, D. In press. Analyzing Affiliation
392
- Networks. In Carrington, P. and Scott, J. (eds) The Sage Handbook
393
- of Social Network Analysis. Sage Publications.
394
-
395
- """
396
- if B.is_directed():
397
- pred = B.pred
398
- G = nx.DiGraph()
399
- else:
400
- pred = B.adj
401
- G = nx.Graph()
402
- G.graph.update(B.graph)
403
- G.add_nodes_from((n, B.nodes[n]) for n in nodes)
404
- for u in nodes:
405
- unbrs = set(B[u])
406
- nbrs2 = {n for nbr in unbrs for n in B[nbr]} - {u}
407
- for v in nbrs2:
408
- vnbrs = set(pred[v])
409
- if jaccard:
410
- wt = len(unbrs & vnbrs) / len(unbrs | vnbrs)
411
- else:
412
- wt = len(unbrs & vnbrs) / min(len(unbrs), len(vnbrs))
413
- G.add_edge(u, v, weight=wt)
414
- return G
415
-
416
-
417
- @not_implemented_for("multigraph")
418
- @nx._dispatchable(graphs="B", preserve_all_attrs=True, returns_graph=True)
419
- def generic_weighted_projected_graph(B, nodes, weight_function=None):
420
- r"""Weighted projection of B with a user-specified weight function.
421
-
422
- The bipartite network B is projected on to the specified nodes
423
- with weights computed by a user-specified function. This function
424
- must accept as a parameter the neighborhood sets of two nodes and
425
- return an integer or a float.
426
-
427
- The nodes retain their attributes and are connected in the resulting graph
428
- if they have an edge to a common node in the original graph.
429
-
430
- Parameters
431
- ----------
432
- B : NetworkX graph
433
- The input graph should be bipartite.
434
-
435
- nodes : list or iterable
436
- Nodes to project onto (the "bottom" nodes).
437
-
438
- weight_function : function
439
- This function must accept as parameters the same input graph
440
- that this function, and two nodes; and return an integer or a float.
441
- The default function computes the number of shared neighbors.
442
-
443
- Returns
444
- -------
445
- Graph : NetworkX graph
446
- A graph that is the projection onto the given nodes.
447
-
448
- Examples
449
- --------
450
- >>> from networkx.algorithms import bipartite
451
- >>> # Define some custom weight functions
452
- >>> def jaccard(G, u, v):
453
- ... unbrs = set(G[u])
454
- ... vnbrs = set(G[v])
455
- ... return float(len(unbrs & vnbrs)) / len(unbrs | vnbrs)
456
- >>> def my_weight(G, u, v, weight="weight"):
457
- ... w = 0
458
- ... for nbr in set(G[u]) & set(G[v]):
459
- ... w += G[u][nbr].get(weight, 1) + G[v][nbr].get(weight, 1)
460
- ... return w
461
- >>> # A complete bipartite graph with 4 nodes and 4 edges
462
- >>> B = nx.complete_bipartite_graph(2, 2)
463
- >>> # Add some arbitrary weight to the edges
464
- >>> for i, (u, v) in enumerate(B.edges()):
465
- ... B.edges[u, v]["weight"] = i + 1
466
- >>> for edge in B.edges(data=True):
467
- ... print(edge)
468
- (0, 2, {'weight': 1})
469
- (0, 3, {'weight': 2})
470
- (1, 2, {'weight': 3})
471
- (1, 3, {'weight': 4})
472
- >>> # By default, the weight is the number of shared neighbors
473
- >>> G = bipartite.generic_weighted_projected_graph(B, [0, 1])
474
- >>> print(list(G.edges(data=True)))
475
- [(0, 1, {'weight': 2})]
476
- >>> # To specify a custom weight function use the weight_function parameter
477
- >>> G = bipartite.generic_weighted_projected_graph(
478
- ... B, [0, 1], weight_function=jaccard
479
- ... )
480
- >>> print(list(G.edges(data=True)))
481
- [(0, 1, {'weight': 1.0})]
482
- >>> G = bipartite.generic_weighted_projected_graph(
483
- ... B, [0, 1], weight_function=my_weight
484
- ... )
485
- >>> print(list(G.edges(data=True)))
486
- [(0, 1, {'weight': 10})]
487
-
488
- Notes
489
- -----
490
- No attempt is made to verify that the input graph B is bipartite.
491
- The graph and node properties are (shallow) copied to the projected graph.
492
-
493
- See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
494
- for further details on how bipartite graphs are handled in NetworkX.
495
-
496
- See Also
497
- --------
498
- is_bipartite,
499
- is_bipartite_node_set,
500
- sets,
501
- weighted_projected_graph,
502
- collaboration_weighted_projected_graph,
503
- overlap_weighted_projected_graph,
504
- projected_graph
505
-
506
- """
507
- if B.is_directed():
508
- pred = B.pred
509
- G = nx.DiGraph()
510
- else:
511
- pred = B.adj
512
- G = nx.Graph()
513
- if weight_function is None:
514
-
515
- def weight_function(G, u, v):
516
- # Notice that we use set(pred[v]) for handling the directed case.
517
- return len(set(G[u]) & set(pred[v]))
518
-
519
- G.graph.update(B.graph)
520
- G.add_nodes_from((n, B.nodes[n]) for n in nodes)
521
- for u in nodes:
522
- nbrs2 = {n for nbr in set(B[u]) for n in B[nbr]} - {u}
523
- for v in nbrs2:
524
- weight = weight_function(B, u, v)
525
- G.add_edge(u, v, weight=weight)
526
- return G
@@ -1,112 +0,0 @@
1
- """Node redundancy for bipartite graphs."""
2
-
3
- from itertools import combinations
4
-
5
- import networkx as nx
6
- from networkx import NetworkXError
7
-
8
- __all__ = ["node_redundancy"]
9
-
10
-
11
- @nx._dispatchable
12
- def node_redundancy(G, nodes=None):
13
- r"""Computes the node redundancy coefficients for the nodes in the bipartite
14
- graph `G`.
15
-
16
- The redundancy coefficient of a node `v` is the fraction of pairs of
17
- neighbors of `v` that are both linked to other nodes. In a one-mode
18
- projection these nodes would be linked together even if `v` were
19
- not there.
20
-
21
- More formally, for any vertex `v`, the *redundancy coefficient of `v`* is
22
- defined by
23
-
24
- .. math::
25
-
26
- rc(v) = \frac{|\{\{u, w\} \subseteq N(v),
27
- \: \exists v' \neq v,\: (v',u) \in E\:
28
- \mathrm{and}\: (v',w) \in E\}|}{ \frac{|N(v)|(|N(v)|-1)}{2}},
29
-
30
- where `N(v)` is the set of neighbors of `v` in `G` [1]_.
31
-
32
- Parameters
33
- ----------
34
- G : graph
35
- A bipartite graph
36
-
37
- nodes : list or iterable (optional)
38
- Compute redundancy for these nodes. The default is all nodes in G.
39
-
40
- Returns
41
- -------
42
- redundancy : dictionary
43
- A dictionary keyed by node with the node redundancy value.
44
-
45
- Examples
46
- --------
47
- Compute the redundancy coefficient of each node in a graph:
48
-
49
- >>> from networkx.algorithms import bipartite
50
- >>> G = nx.cycle_graph(4)
51
- >>> rc = bipartite.node_redundancy(G)
52
- >>> rc[0]
53
- 1.0
54
-
55
- Compute the average redundancy for the graph:
56
-
57
- >>> from networkx.algorithms import bipartite
58
- >>> G = nx.cycle_graph(4)
59
- >>> rc = bipartite.node_redundancy(G)
60
- >>> sum(rc.values()) / len(G)
61
- 1.0
62
-
63
- Compute the average redundancy for a set of nodes:
64
-
65
- >>> from networkx.algorithms import bipartite
66
- >>> G = nx.cycle_graph(4)
67
- >>> rc = bipartite.node_redundancy(G)
68
- >>> nodes = [0, 2]
69
- >>> sum(rc[n] for n in nodes) / len(nodes)
70
- 1.0
71
-
72
- Raises
73
- ------
74
- NetworkXError
75
- If any of the nodes in the graph (or in `nodes`, if specified) has
76
- (out-)degree less than two (which would result in division by zero,
77
- according to the definition of the redundancy coefficient).
78
-
79
- References
80
- ----------
81
- .. [1] Latapy, Matthieu, Clémence Magnien, and Nathalie Del Vecchio (2008).
82
- Basic notions for the analysis of large two-mode networks.
83
- Social Networks 30(1), 31--48.
84
-
85
- """
86
- if nodes is None:
87
- nodes = G
88
- if any(len(G[v]) < 2 for v in nodes):
89
- raise NetworkXError(
90
- "Cannot compute redundancy coefficient for a node"
91
- " that has fewer than two neighbors."
92
- )
93
- # TODO This can be trivially parallelized.
94
- return {v: _node_redundancy(G, v) for v in nodes}
95
-
96
-
97
- def _node_redundancy(G, v):
98
- """Returns the redundancy of the node `v` in the bipartite graph `G`.
99
-
100
- If `G` is a graph with `n` nodes, the redundancy of a node is the ratio
101
- of the "overlap" of `v` to the maximum possible overlap of `v`
102
- according to its degree. The overlap of `v` is the number of pairs of
103
- neighbors that have mutual neighbors themselves, other than `v`.
104
-
105
- `v` must have at least two neighbors in `G`.
106
-
107
- """
108
- n = len(G[v])
109
- overlap = sum(
110
- 1 for (u, w) in combinations(G[v], 2) if (set(G[u]) & set(G[w])) - {v}
111
- )
112
- return (2 * overlap) / (n * (n - 1))
@@ -1,69 +0,0 @@
1
- """
2
- Spectral bipartivity measure.
3
- """
4
-
5
- import networkx as nx
6
-
7
- __all__ = ["spectral_bipartivity"]
8
-
9
-
10
- @nx._dispatchable(edge_attrs="weight")
11
- def spectral_bipartivity(G, nodes=None, weight="weight"):
12
- """Returns the spectral bipartivity.
13
-
14
- Parameters
15
- ----------
16
- G : NetworkX graph
17
-
18
- nodes : list or container optional(default is all nodes)
19
- Nodes to return value of spectral bipartivity contribution.
20
-
21
- weight : string or None optional (default = 'weight')
22
- Edge data key to use for edge weights. If None, weights set to 1.
23
-
24
- Returns
25
- -------
26
- sb : float or dict
27
- A single number if the keyword nodes is not specified, or
28
- a dictionary keyed by node with the spectral bipartivity contribution
29
- of that node as the value.
30
-
31
- Examples
32
- --------
33
- >>> from networkx.algorithms import bipartite
34
- >>> G = nx.path_graph(4)
35
- >>> bipartite.spectral_bipartivity(G)
36
- 1.0
37
-
38
- Notes
39
- -----
40
- This implementation uses Numpy (dense) matrices which are not efficient
41
- for storing large sparse graphs.
42
-
43
- See Also
44
- --------
45
- color
46
-
47
- References
48
- ----------
49
- .. [1] E. Estrada and J. A. Rodríguez-Velázquez, "Spectral measures of
50
- bipartivity in complex networks", PhysRev E 72, 046105 (2005)
51
- """
52
- import scipy as sp
53
-
54
- nodelist = list(G) # ordering of nodes in matrix
55
- A = nx.to_numpy_array(G, nodelist, weight=weight)
56
- expA = sp.linalg.expm(A)
57
- expmA = sp.linalg.expm(-A)
58
- coshA = 0.5 * (expA + expmA)
59
- if nodes is None:
60
- # return single number for entire graph
61
- return float(coshA.diagonal().sum() / expA.diagonal().sum())
62
- else:
63
- # contribution for individual nodes
64
- index = dict(zip(nodelist, range(len(nodelist))))
65
- sb = {}
66
- for n in nodes:
67
- i = index[n]
68
- sb[n] = coshA.item(i, i) / expA.item(i, i)
69
- return sb