okstra 0.114.0 → 0.115.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 (326) hide show
  1. package/docs/kr/architecture.md +2 -2
  2. package/docs/kr/follow-ups/2026-07-10-final-report-option-3.md +51 -0
  3. package/package.json +1 -1
  4. package/runtime/BUILD.json +2 -2
  5. package/runtime/agents/workers/report-writer-worker.md +1 -0
  6. package/runtime/prompts/lead/okstra-lead-contract.md +1 -1
  7. package/runtime/python/okstra_ctl/implementation_stage.py +46 -39
  8. package/runtime/python/okstra_ctl/report_views.py +151 -12
  9. package/runtime/python/okstra_ctl/run.py +24 -24
  10. package/runtime/python/okstra_ctl/worktree.py +1 -1
  11. package/runtime/python/okstra_token_usage/claude.py +58 -19
  12. package/runtime/python/okstra_token_usage/collect.py +3 -1
  13. package/runtime/python/okstra_vendor/__init__.py +3 -0
  14. package/runtime/schemas/final-report-v1.0.schema.json +20 -0
  15. package/runtime/templates/reports/final-report.template.md +14 -0
  16. package/runtime/templates/reports/i18n/en.json +23 -12
  17. package/runtime/templates/reports/i18n/ko.json +23 -12
  18. package/runtime/templates/reports/report.css +55 -0
  19. package/runtime/templates/reports/report.js +53 -1
  20. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/__init__.py +0 -0
  21. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py +0 -41
  22. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_clique.py +0 -112
  23. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_connectivity.py +0 -199
  24. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_density.py +0 -146
  25. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_distance_measures.py +0 -59
  26. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_dominating_set.py +0 -78
  27. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_kcomponents.py +0 -303
  28. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_matching.py +0 -8
  29. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_maxcut.py +0 -94
  30. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_ramsey.py +0 -31
  31. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_steinertree.py +0 -306
  32. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_traveling_salesman.py +0 -1014
  33. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_treewidth.py +0 -274
  34. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_vertex_cover.py +0 -68
  35. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/__init__.py +0 -0
  36. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/base_test.py +0 -81
  37. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_connectivity.py +0 -143
  38. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_correlation.py +0 -122
  39. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_mixing.py +0 -174
  40. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_neighbor_degree.py +0 -107
  41. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_pairs.py +0 -87
  42. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/__init__.py +0 -0
  43. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_basic.py +0 -125
  44. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_centrality.py +0 -192
  45. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_cluster.py +0 -84
  46. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_covering.py +0 -33
  47. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_edgelist.py +0 -240
  48. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_extendability.py +0 -334
  49. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_generators.py +0 -407
  50. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_link_analysis.py +0 -218
  51. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matching.py +0 -327
  52. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matrix.py +0 -138
  53. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_project.py +0 -409
  54. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_redundancy.py +0 -35
  55. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py +0 -80
  56. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/__init__.py +0 -0
  57. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality.py +0 -923
  58. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py +0 -354
  59. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_closeness_centrality.py +0 -274
  60. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality.py +0 -259
  61. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality_subset.py +0 -147
  62. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_closeness.py +0 -43
  63. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_degree_centrality.py +0 -144
  64. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_dispersion.py +0 -73
  65. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py +0 -186
  66. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_group.py +0 -277
  67. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_harmonic_centrality.py +0 -122
  68. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_katz_centrality.py +0 -345
  69. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_laplacian_centrality.py +0 -220
  70. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_load_centrality.py +0 -344
  71. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_percolation_centrality.py +0 -87
  72. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_reaching.py +0 -140
  73. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_second_order_centrality.py +0 -82
  74. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_subgraph.py +0 -110
  75. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_trophic.py +0 -302
  76. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_voterank.py +0 -64
  77. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/__init__.py +0 -0
  78. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/test_coloring.py +0 -863
  79. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/__init__.py +0 -0
  80. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_asyn_fluid.py +0 -147
  81. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_bipartitions.py +0 -157
  82. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_centrality.py +0 -85
  83. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_divisive.py +0 -106
  84. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_kclique.py +0 -91
  85. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_label_propagation.py +0 -241
  86. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_leiden.py +0 -138
  87. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_local.py +0 -76
  88. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_louvain.py +0 -264
  89. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_lukes.py +0 -152
  90. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_modularity_max.py +0 -340
  91. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_quality.py +0 -139
  92. package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_utils.py +0 -26
  93. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/__init__.py +0 -0
  94. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_attracting.py +0 -70
  95. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_biconnected.py +0 -248
  96. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_connected.py +0 -138
  97. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_semiconnected.py +0 -55
  98. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_strongly_connected.py +0 -193
  99. package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_weakly_connected.py +0 -96
  100. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/__init__.py +0 -0
  101. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_connectivity.py +0 -421
  102. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_cuts.py +0 -309
  103. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_disjoint_paths.py +0 -249
  104. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_augmentation.py +0 -502
  105. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_kcomponents.py +0 -488
  106. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcomponents.py +0 -323
  107. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcutsets.py +0 -280
  108. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_stoer_wagner.py +0 -102
  109. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/__init__.py +0 -0
  110. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gl1.gpickle.bz2 +0 -0
  111. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gw1.gpickle.bz2 +0 -0
  112. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/netgen-2.gpickle.bz2 +0 -0
  113. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_gomory_hu.py +0 -128
  114. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow.py +0 -573
  115. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow_large_graph.py +0 -155
  116. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_mincost.py +0 -475
  117. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_networksimplex.py +0 -481
  118. package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/wlm3.gpickle.bz2 +0 -0
  119. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/__init__.py +0 -0
  120. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.A99 +0 -0
  121. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.B99 +0 -0
  122. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.A99 +0 -0
  123. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.B99 +0 -0
  124. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_ismags.py +0 -719
  125. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphism.py +0 -103
  126. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py +0 -490
  127. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_match_helpers.py +0 -64
  128. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_temporalisomorphvf2.py +0 -212
  129. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_tree_isomorphism.py +0 -202
  130. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp.py +0 -1655
  131. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp_helpers.py +0 -3118
  132. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py +0 -196
  133. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/__init__.py +0 -0
  134. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_hits.py +0 -77
  135. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_pagerank.py +0 -213
  136. package/runtime/python/okstra_vendor/networkx/algorithms/minors/tests/test_contraction.py +0 -544
  137. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/__init__.py +0 -0
  138. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_all.py +0 -328
  139. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_binary.py +0 -451
  140. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_product.py +0 -491
  141. package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_unary.py +0 -55
  142. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/__init__.py +0 -0
  143. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_astar.py +0 -254
  144. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense.py +0 -212
  145. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense_numpy.py +0 -88
  146. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_generic.py +0 -511
  147. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_unweighted.py +0 -149
  148. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_weighted.py +0 -983
  149. package/runtime/python/okstra_vendor/networkx/algorithms/tests/__init__.py +0 -0
  150. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_asteroidal.py +0 -23
  151. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_boundary.py +0 -154
  152. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_bridges.py +0 -144
  153. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_broadcasting.py +0 -109
  154. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chains.py +0 -136
  155. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chordal.py +0 -129
  156. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_clique.py +0 -300
  157. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cluster.py +0 -678
  158. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_communicability.py +0 -80
  159. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_core.py +0 -266
  160. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_covering.py +0 -85
  161. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cuts.py +0 -171
  162. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cycles.py +0 -984
  163. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_d_separation.py +0 -340
  164. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dag.py +0 -835
  165. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_measures.py +0 -831
  166. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_regular.py +0 -85
  167. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominance.py +0 -299
  168. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominating.py +0 -115
  169. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_efficiency.py +0 -58
  170. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_euler.py +0 -314
  171. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graph_hashing.py +0 -872
  172. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graphical.py +0 -163
  173. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hierarchy.py +0 -46
  174. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hybrid.py +0 -24
  175. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_isolate.py +0 -26
  176. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_link_prediction.py +0 -615
  177. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_lowest_common_ancestors.py +0 -459
  178. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_matching.py +0 -556
  179. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_max_weight_clique.py +0 -179
  180. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_mis.py +0 -62
  181. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_moral.py +0 -15
  182. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_node_classification.py +0 -140
  183. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_non_randomness.py +0 -60
  184. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_perfect_graph.py +0 -27
  185. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planar_drawing.py +0 -274
  186. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planarity.py +0 -556
  187. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_polynomials.py +0 -57
  188. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_reciprocity.py +0 -37
  189. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_regular.py +0 -88
  190. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_richclub.py +0 -149
  191. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_similarity.py +0 -1158
  192. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_simple_paths.py +0 -803
  193. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smallworld.py +0 -76
  194. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smetric.py +0 -8
  195. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_sparsifiers.py +0 -138
  196. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_structuralholes.py +0 -191
  197. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_summarization.py +0 -642
  198. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_swap.py +0 -179
  199. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_threshold.py +0 -270
  200. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_time_dependent.py +0 -431
  201. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_tournament.py +0 -161
  202. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_triads.py +0 -248
  203. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_vitality.py +0 -41
  204. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_voronoi.py +0 -103
  205. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_walks.py +0 -54
  206. package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_wiener.py +0 -157
  207. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/__init__.py +0 -0
  208. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_beamsearch.py +0 -25
  209. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_bfs.py +0 -203
  210. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_dfs.py +0 -307
  211. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgebfs.py +0 -147
  212. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgedfs.py +0 -131
  213. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/__init__.py +0 -0
  214. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_branchings.py +0 -624
  215. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_coding.py +0 -114
  216. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_decomposition.py +0 -79
  217. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_distance_measures.py +0 -99
  218. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_mst.py +0 -934
  219. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_operations.py +0 -53
  220. package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_recognition.py +0 -174
  221. package/runtime/python/okstra_vendor/networkx/classes/tests/__init__.py +0 -0
  222. package/runtime/python/okstra_vendor/networkx/classes/tests/dispatch_interface.py +0 -192
  223. package/runtime/python/okstra_vendor/networkx/classes/tests/historical_tests.py +0 -476
  224. package/runtime/python/okstra_vendor/networkx/classes/tests/test_coreviews.py +0 -362
  225. package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph.py +0 -331
  226. package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph_historical.py +0 -110
  227. package/runtime/python/okstra_vendor/networkx/classes/tests/test_filters.py +0 -177
  228. package/runtime/python/okstra_vendor/networkx/classes/tests/test_function.py +0 -1045
  229. package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph.py +0 -950
  230. package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph_historical.py +0 -12
  231. package/runtime/python/okstra_vendor/networkx/classes/tests/test_graphviews.py +0 -349
  232. package/runtime/python/okstra_vendor/networkx/classes/tests/test_multidigraph.py +0 -459
  233. package/runtime/python/okstra_vendor/networkx/classes/tests/test_multigraph.py +0 -528
  234. package/runtime/python/okstra_vendor/networkx/classes/tests/test_reportviews.py +0 -1421
  235. package/runtime/python/okstra_vendor/networkx/classes/tests/test_special.py +0 -131
  236. package/runtime/python/okstra_vendor/networkx/classes/tests/test_subgraphviews.py +0 -371
  237. package/runtime/python/okstra_vendor/networkx/conftest.py +0 -261
  238. package/runtime/python/okstra_vendor/networkx/drawing/tests/__init__.py +0 -0
  239. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_complex.png +0 -0
  240. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_empty_graph.png +0 -0
  241. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_house_with_colors.png +0 -0
  242. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_labels_and_colors.png +0 -0
  243. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_shortest_path.png +0 -0
  244. package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_house_with_colors.png +0 -0
  245. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_agraph.py +0 -237
  246. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_image_comparison_pylab_mpl.py +0 -229
  247. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_latex.py +0 -285
  248. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_layout.py +0 -631
  249. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pydot.py +0 -146
  250. package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pylab.py +0 -1582
  251. package/runtime/python/okstra_vendor/networkx/generators/tests/__init__.py +0 -0
  252. package/runtime/python/okstra_vendor/networkx/generators/tests/test_atlas.py +0 -75
  253. package/runtime/python/okstra_vendor/networkx/generators/tests/test_classic.py +0 -642
  254. package/runtime/python/okstra_vendor/networkx/generators/tests/test_cographs.py +0 -20
  255. package/runtime/python/okstra_vendor/networkx/generators/tests/test_community.py +0 -362
  256. package/runtime/python/okstra_vendor/networkx/generators/tests/test_degree_seq.py +0 -224
  257. package/runtime/python/okstra_vendor/networkx/generators/tests/test_directed.py +0 -189
  258. package/runtime/python/okstra_vendor/networkx/generators/tests/test_duplication.py +0 -103
  259. package/runtime/python/okstra_vendor/networkx/generators/tests/test_ego.py +0 -39
  260. package/runtime/python/okstra_vendor/networkx/generators/tests/test_expanders.py +0 -182
  261. package/runtime/python/okstra_vendor/networkx/generators/tests/test_geometric.py +0 -488
  262. package/runtime/python/okstra_vendor/networkx/generators/tests/test_harary_graph.py +0 -133
  263. package/runtime/python/okstra_vendor/networkx/generators/tests/test_internet_as_graphs.py +0 -221
  264. package/runtime/python/okstra_vendor/networkx/generators/tests/test_intersection.py +0 -28
  265. package/runtime/python/okstra_vendor/networkx/generators/tests/test_interval_graph.py +0 -144
  266. package/runtime/python/okstra_vendor/networkx/generators/tests/test_joint_degree_seq.py +0 -125
  267. package/runtime/python/okstra_vendor/networkx/generators/tests/test_lattice.py +0 -264
  268. package/runtime/python/okstra_vendor/networkx/generators/tests/test_line.py +0 -316
  269. package/runtime/python/okstra_vendor/networkx/generators/tests/test_mycielski.py +0 -30
  270. package/runtime/python/okstra_vendor/networkx/generators/tests/test_nonisomorphic_trees.py +0 -82
  271. package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_clustered.py +0 -33
  272. package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_graphs.py +0 -495
  273. package/runtime/python/okstra_vendor/networkx/generators/tests/test_small.py +0 -220
  274. package/runtime/python/okstra_vendor/networkx/generators/tests/test_spectral_graph_forge.py +0 -49
  275. package/runtime/python/okstra_vendor/networkx/generators/tests/test_stochastic.py +0 -72
  276. package/runtime/python/okstra_vendor/networkx/generators/tests/test_sudoku.py +0 -92
  277. package/runtime/python/okstra_vendor/networkx/generators/tests/test_time_series.py +0 -64
  278. package/runtime/python/okstra_vendor/networkx/generators/tests/test_trees.py +0 -195
  279. package/runtime/python/okstra_vendor/networkx/generators/tests/test_triads.py +0 -15
  280. package/runtime/python/okstra_vendor/networkx/linalg/tests/__init__.py +0 -0
  281. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_algebraic_connectivity.py +0 -400
  282. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_attrmatrix.py +0 -108
  283. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_bethehessian.py +0 -40
  284. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_graphmatrix.py +0 -275
  285. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_laplacian.py +0 -334
  286. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_modularity.py +0 -86
  287. package/runtime/python/okstra_vendor/networkx/linalg/tests/test_spectrum.py +0 -70
  288. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/__init__.py +0 -0
  289. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_adjacency.py +0 -78
  290. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_cytoscape.py +0 -78
  291. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_node_link.py +0 -109
  292. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_tree.py +0 -48
  293. package/runtime/python/okstra_vendor/networkx/readwrite/tests/__init__.py +0 -0
  294. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_adjlist.py +0 -354
  295. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_edgelist.py +0 -318
  296. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gexf.py +0 -612
  297. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gml.py +0 -744
  298. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graph6.py +0 -181
  299. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graphml.py +0 -1531
  300. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_leda.py +0 -30
  301. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_p2g.py +0 -63
  302. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_pajek.py +0 -128
  303. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_sparse6.py +0 -166
  304. package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_text.py +0 -1742
  305. package/runtime/python/okstra_vendor/networkx/tests/__init__.py +0 -0
  306. package/runtime/python/okstra_vendor/networkx/tests/test_all_random_functions.py +0 -248
  307. package/runtime/python/okstra_vendor/networkx/tests/test_convert.py +0 -321
  308. package/runtime/python/okstra_vendor/networkx/tests/test_convert_numpy.py +0 -531
  309. package/runtime/python/okstra_vendor/networkx/tests/test_convert_pandas.py +0 -349
  310. package/runtime/python/okstra_vendor/networkx/tests/test_convert_scipy.py +0 -281
  311. package/runtime/python/okstra_vendor/networkx/tests/test_exceptions.py +0 -40
  312. package/runtime/python/okstra_vendor/networkx/tests/test_import.py +0 -11
  313. package/runtime/python/okstra_vendor/networkx/tests/test_lazy_imports.py +0 -96
  314. package/runtime/python/okstra_vendor/networkx/tests/test_relabel.py +0 -349
  315. package/runtime/python/okstra_vendor/networkx/tests/test_removed_functions_exception_messages.py +0 -8
  316. package/runtime/python/okstra_vendor/networkx/utils/tests/__init__.py +0 -0
  317. package/runtime/python/okstra_vendor/networkx/utils/tests/test__init.py +0 -11
  318. package/runtime/python/okstra_vendor/networkx/utils/tests/test_backends.py +0 -225
  319. package/runtime/python/okstra_vendor/networkx/utils/tests/test_config.py +0 -263
  320. package/runtime/python/okstra_vendor/networkx/utils/tests/test_decorators.py +0 -510
  321. package/runtime/python/okstra_vendor/networkx/utils/tests/test_heaps.py +0 -131
  322. package/runtime/python/okstra_vendor/networkx/utils/tests/test_mapped_queue.py +0 -268
  323. package/runtime/python/okstra_vendor/networkx/utils/tests/test_misc.py +0 -393
  324. package/runtime/python/okstra_vendor/networkx/utils/tests/test_random_sequence.py +0 -53
  325. package/runtime/python/okstra_vendor/networkx/utils/tests/test_rcm.py +0 -63
  326. package/runtime/python/okstra_vendor/networkx/utils/tests/test_unionfind.py +0 -55
@@ -1,544 +0,0 @@
1
- """Unit tests for the :mod:`networkx.algorithms.minors.contraction` module."""
2
-
3
- import pytest
4
-
5
- import networkx as nx
6
- from networkx.utils import arbitrary_element, edges_equal, nodes_equal
7
-
8
-
9
- def test_quotient_graph_complete_multipartite():
10
- """Tests that the quotient graph of the complete *n*-partite graph
11
- under the "same neighbors" node relation is the complete graph on *n*
12
- nodes.
13
-
14
- """
15
- G = nx.complete_multipartite_graph(2, 3, 4)
16
- # Two nodes are equivalent if they are not adjacent but have the same
17
- # neighbor set.
18
-
19
- def same_neighbors(u, v):
20
- return u not in G[v] and v not in G[u] and G[u] == G[v]
21
-
22
- expected = nx.complete_graph(3)
23
- actual = nx.quotient_graph(G, same_neighbors)
24
- # It won't take too long to run a graph isomorphism algorithm on such
25
- # small graphs.
26
- assert nx.is_isomorphic(expected, actual)
27
-
28
-
29
- def test_quotient_graph_complete_bipartite():
30
- """Tests that the quotient graph of the complete bipartite graph under
31
- the "same neighbors" node relation is `K_2`.
32
-
33
- """
34
- G = nx.complete_bipartite_graph(2, 3)
35
- # Two nodes are equivalent if they are not adjacent but have the same
36
- # neighbor set.
37
-
38
- def same_neighbors(u, v):
39
- return u not in G[v] and v not in G[u] and G[u] == G[v]
40
-
41
- expected = nx.complete_graph(2)
42
- actual = nx.quotient_graph(G, same_neighbors)
43
- # It won't take too long to run a graph isomorphism algorithm on such
44
- # small graphs.
45
- assert nx.is_isomorphic(expected, actual)
46
-
47
-
48
- def test_quotient_graph_edge_relation():
49
- """Tests for specifying an alternate edge relation for the quotient
50
- graph.
51
-
52
- """
53
- G = nx.path_graph(5)
54
-
55
- def identity(u, v):
56
- return u == v
57
-
58
- def same_parity(b, c):
59
- return arbitrary_element(b) % 2 == arbitrary_element(c) % 2
60
-
61
- actual = nx.quotient_graph(G, identity, same_parity)
62
- expected = nx.Graph()
63
- expected.add_edges_from([(0, 2), (0, 4), (2, 4)])
64
- expected.add_edge(1, 3)
65
- assert nx.is_isomorphic(actual, expected)
66
-
67
-
68
- def test_condensation_as_quotient():
69
- """This tests that the condensation of a graph can be viewed as the
70
- quotient graph under the "in the same connected component" equivalence
71
- relation.
72
-
73
- """
74
- # This example graph comes from the file `test_strongly_connected.py`.
75
- G = nx.DiGraph()
76
- G.add_edges_from(
77
- [
78
- (1, 2),
79
- (2, 3),
80
- (2, 11),
81
- (2, 12),
82
- (3, 4),
83
- (4, 3),
84
- (4, 5),
85
- (5, 6),
86
- (6, 5),
87
- (6, 7),
88
- (7, 8),
89
- (7, 9),
90
- (7, 10),
91
- (8, 9),
92
- (9, 7),
93
- (10, 6),
94
- (11, 2),
95
- (11, 4),
96
- (11, 6),
97
- (12, 6),
98
- (12, 11),
99
- ]
100
- )
101
- scc = list(nx.strongly_connected_components(G))
102
- C = nx.condensation(G, scc)
103
- component_of = C.graph["mapping"]
104
- # Two nodes are equivalent if they are in the same connected component.
105
-
106
- def same_component(u, v):
107
- return component_of[u] == component_of[v]
108
-
109
- Q = nx.quotient_graph(G, same_component)
110
- assert nx.is_isomorphic(C, Q)
111
-
112
-
113
- def test_path():
114
- G = nx.path_graph(6)
115
- partition = [{0, 1}, {2, 3}, {4, 5}]
116
- M = nx.quotient_graph(G, partition, relabel=True)
117
- assert nodes_equal(M, [0, 1, 2])
118
- assert edges_equal(M.edges(), [(0, 1), (1, 2)])
119
- for n in M:
120
- assert M.nodes[n]["nedges"] == 1
121
- assert M.nodes[n]["nnodes"] == 2
122
- assert M.nodes[n]["density"] == 1
123
-
124
-
125
- def test_path__partition_provided_as_dict_of_lists():
126
- G = nx.path_graph(6)
127
- partition = {0: [0, 1], 2: [2, 3], 4: [4, 5]}
128
- M = nx.quotient_graph(G, partition, relabel=True)
129
- assert nodes_equal(M, [0, 1, 2])
130
- assert edges_equal(M.edges(), [(0, 1), (1, 2)])
131
- for n in M:
132
- assert M.nodes[n]["nedges"] == 1
133
- assert M.nodes[n]["nnodes"] == 2
134
- assert M.nodes[n]["density"] == 1
135
-
136
-
137
- def test_path__partition_provided_as_dict_of_tuples():
138
- G = nx.path_graph(6)
139
- partition = {0: (0, 1), 2: (2, 3), 4: (4, 5)}
140
- M = nx.quotient_graph(G, partition, relabel=True)
141
- assert nodes_equal(M, [0, 1, 2])
142
- assert edges_equal(M.edges(), [(0, 1), (1, 2)])
143
- for n in M:
144
- assert M.nodes[n]["nedges"] == 1
145
- assert M.nodes[n]["nnodes"] == 2
146
- assert M.nodes[n]["density"] == 1
147
-
148
-
149
- def test_path__partition_provided_as_dict_of_sets():
150
- G = nx.path_graph(6)
151
- partition = {0: {0, 1}, 2: {2, 3}, 4: {4, 5}}
152
- M = nx.quotient_graph(G, partition, relabel=True)
153
- assert nodes_equal(M, [0, 1, 2])
154
- assert edges_equal(M.edges(), [(0, 1), (1, 2)])
155
- for n in M:
156
- assert M.nodes[n]["nedges"] == 1
157
- assert M.nodes[n]["nnodes"] == 2
158
- assert M.nodes[n]["density"] == 1
159
-
160
-
161
- def test_multigraph_path():
162
- G = nx.MultiGraph(nx.path_graph(6))
163
- partition = [{0, 1}, {2, 3}, {4, 5}]
164
- M = nx.quotient_graph(G, partition, relabel=True)
165
- assert nodes_equal(M, [0, 1, 2])
166
- assert edges_equal(M.edges(), [(0, 1), (1, 2)])
167
- for n in M:
168
- assert M.nodes[n]["nedges"] == 1
169
- assert M.nodes[n]["nnodes"] == 2
170
- assert M.nodes[n]["density"] == 1
171
-
172
-
173
- def test_directed_path():
174
- G = nx.DiGraph()
175
- nx.add_path(G, range(6))
176
- partition = [{0, 1}, {2, 3}, {4, 5}]
177
- M = nx.quotient_graph(G, partition, relabel=True)
178
- assert nodes_equal(M, [0, 1, 2])
179
- assert edges_equal(M.edges(), [(0, 1), (1, 2)], directed=True)
180
- for n in M:
181
- assert M.nodes[n]["nedges"] == 1
182
- assert M.nodes[n]["nnodes"] == 2
183
- assert M.nodes[n]["density"] == 0.5
184
-
185
-
186
- def test_directed_multigraph_path():
187
- G = nx.MultiDiGraph()
188
- nx.add_path(G, range(6))
189
- partition = [{0, 1}, {2, 3}, {4, 5}]
190
- M = nx.quotient_graph(G, partition, relabel=True)
191
- assert nodes_equal(M, [0, 1, 2])
192
- assert edges_equal(M.edges(), [(0, 1), (1, 2)], directed=True)
193
- for n in M:
194
- assert M.nodes[n]["nedges"] == 1
195
- assert M.nodes[n]["nnodes"] == 2
196
- assert M.nodes[n]["density"] == 0.5
197
-
198
-
199
- def test_overlapping_blocks():
200
- with pytest.raises(nx.NetworkXException):
201
- G = nx.path_graph(6)
202
- partition = [{0, 1, 2}, {2, 3}, {4, 5}]
203
- nx.quotient_graph(G, partition)
204
-
205
-
206
- def test_weighted_path():
207
- G = nx.path_graph(6)
208
- for i in range(5):
209
- G[i][i + 1]["w"] = i + 1
210
- partition = [{0, 1}, {2, 3}, {4, 5}]
211
- M = nx.quotient_graph(G, partition, weight="w", relabel=True)
212
- assert nodes_equal(M, [0, 1, 2])
213
- assert edges_equal(M.edges(), [(0, 1), (1, 2)])
214
- assert M[0][1]["weight"] == 2
215
- assert M[1][2]["weight"] == 4
216
- for n in M:
217
- assert M.nodes[n]["nedges"] == 1
218
- assert M.nodes[n]["nnodes"] == 2
219
- assert M.nodes[n]["density"] == 1
220
-
221
-
222
- def test_barbell():
223
- G = nx.barbell_graph(3, 0)
224
- partition = [{0, 1, 2}, {3, 4, 5}]
225
- M = nx.quotient_graph(G, partition, relabel=True)
226
- assert nodes_equal(M, [0, 1])
227
- assert edges_equal(M.edges(), [(0, 1)])
228
- for n in M:
229
- assert M.nodes[n]["nedges"] == 3
230
- assert M.nodes[n]["nnodes"] == 3
231
- assert M.nodes[n]["density"] == 1
232
-
233
-
234
- def test_barbell_plus():
235
- G = nx.barbell_graph(3, 0)
236
- # Add an extra edge joining the bells.
237
- G.add_edge(0, 5)
238
- partition = [{0, 1, 2}, {3, 4, 5}]
239
- M = nx.quotient_graph(G, partition, relabel=True)
240
- assert nodes_equal(M, [0, 1])
241
- assert edges_equal(M.edges(), [(0, 1)])
242
- assert M[0][1]["weight"] == 2
243
- for n in M:
244
- assert M.nodes[n]["nedges"] == 3
245
- assert M.nodes[n]["nnodes"] == 3
246
- assert M.nodes[n]["density"] == 1
247
-
248
-
249
- def test_blockmodel():
250
- G = nx.path_graph(6)
251
- partition = [[0, 1], [2, 3], [4, 5]]
252
- M = nx.quotient_graph(G, partition, relabel=True)
253
- assert nodes_equal(M.nodes(), [0, 1, 2])
254
- assert edges_equal(M.edges(), [(0, 1), (1, 2)])
255
- for n in M.nodes():
256
- assert M.nodes[n]["nedges"] == 1
257
- assert M.nodes[n]["nnodes"] == 2
258
- assert M.nodes[n]["density"] == 1.0
259
-
260
-
261
- def test_multigraph_blockmodel():
262
- G = nx.MultiGraph(nx.path_graph(6))
263
- partition = [[0, 1], [2, 3], [4, 5]]
264
- M = nx.quotient_graph(G, partition, create_using=nx.MultiGraph(), relabel=True)
265
- assert nodes_equal(M.nodes(), [0, 1, 2])
266
- assert edges_equal(M.edges(), [(0, 1), (1, 2)])
267
- for n in M.nodes():
268
- assert M.nodes[n]["nedges"] == 1
269
- assert M.nodes[n]["nnodes"] == 2
270
- assert M.nodes[n]["density"] == 1.0
271
-
272
-
273
- def test_quotient_graph_incomplete_partition():
274
- G = nx.path_graph(6)
275
- partition = []
276
- H = nx.quotient_graph(G, partition, relabel=True)
277
- assert nodes_equal(H.nodes(), [])
278
- assert edges_equal(H.edges(), [])
279
-
280
- partition = [[0, 1], [2, 3], [5]]
281
- H = nx.quotient_graph(G, partition, relabel=True)
282
- assert nodes_equal(H.nodes(), [0, 1, 2])
283
- assert edges_equal(H.edges(), [(0, 1)])
284
-
285
-
286
- @pytest.mark.parametrize("store_contraction_as", ("contraction", "c", None))
287
- @pytest.mark.parametrize("copy", (True, False))
288
- @pytest.mark.parametrize("selfloops", (True, False))
289
- def test_undirected_node_contraction(store_contraction_as, copy, selfloops):
290
- """Tests for node contraction in an undirected graph."""
291
- G = nx.cycle_graph(4)
292
- actual = nx.contracted_nodes(
293
- G,
294
- 0,
295
- 1,
296
- copy=copy,
297
- self_loops=selfloops,
298
- store_contraction_as=store_contraction_as,
299
- )
300
-
301
- expected = nx.cycle_graph(3)
302
- if selfloops:
303
- expected.add_edge(0, 0)
304
-
305
- assert nx.is_isomorphic(actual, expected)
306
-
307
- if not copy:
308
- assert actual is G
309
-
310
- # Test contracted node attributes
311
- if store_contraction_as is not None:
312
- assert actual.nodes[0][store_contraction_as] == {1: {}}
313
- else:
314
- assert actual.nodes[0] == {}
315
- # There should be no contracted edges for this case
316
- assert all(d == {} for _, _, d in actual.edges(data=True))
317
-
318
-
319
- @pytest.mark.parametrize("store_contraction_as", ("contraction", "c", None))
320
- @pytest.mark.parametrize("copy", (True, False))
321
- @pytest.mark.parametrize("selfloops", (True, False))
322
- def test_directed_node_contraction(store_contraction_as, copy, selfloops):
323
- """Tests for node contraction in a directed graph."""
324
- G = nx.DiGraph(nx.cycle_graph(4))
325
- actual = nx.contracted_nodes(
326
- G,
327
- 0,
328
- 1,
329
- copy=copy,
330
- self_loops=selfloops,
331
- store_contraction_as=store_contraction_as,
332
- )
333
-
334
- expected = nx.DiGraph(nx.cycle_graph(3))
335
- if selfloops:
336
- expected.add_edge(0, 0)
337
-
338
- assert nx.is_isomorphic(actual, expected)
339
-
340
- if not copy:
341
- assert actual is G
342
- # Test contracted node attributes
343
- if store_contraction_as is not None:
344
- assert actual.nodes[0][store_contraction_as] == {1: {}}
345
- else:
346
- assert actual.nodes[0] == {}
347
- # Test contracted edge attributes (only relevant if self loops is enabled)
348
- if selfloops and store_contraction_as:
349
- assert actual.edges[(0, 0)][store_contraction_as] == {(1, 0): {}}
350
- else:
351
- assert all(d == {} for _, _, d in actual.edges(data=True))
352
-
353
-
354
- @pytest.mark.parametrize("store_contraction_as", ("contraction", "c", None))
355
- @pytest.mark.parametrize("copy", (True, False))
356
- @pytest.mark.parametrize("selfloops", (True, False))
357
- def test_contracted_nodes_multigraph(store_contraction_as, copy, selfloops):
358
- """Tests that using a MultiGraph creates multiple edges. `store_contraction_as`
359
- has no effect for multigraphs."""
360
- G = nx.path_graph(3, create_using=nx.MultiGraph)
361
- G.add_edges_from([(0, 1), (0, 0), (0, 2)])
362
- actual = nx.contracted_nodes(
363
- G,
364
- 0,
365
- 2,
366
- copy=copy,
367
- self_loops=selfloops,
368
- store_contraction_as=store_contraction_as,
369
- )
370
- # Two (0, 1) edges from G, another from the contraction of edge (1, 2)
371
- expected = nx.MultiGraph([(0, 1), (0, 1), (0, 1), (0, 0)])
372
- # One (0, 0) edge from G, another from the contraction of edge (0, 2), but
373
- # only if `selfloops` is True
374
- if selfloops:
375
- expected.add_edge(0, 0)
376
-
377
- assert edges_equal(actual.edges, expected.edges)
378
- if not copy:
379
- assert actual is G
380
-
381
-
382
- def test_multigraph_keys():
383
- """Tests that multiedge keys are reset in new graph."""
384
- G = nx.path_graph(3, create_using=nx.MultiGraph())
385
- G.add_edge(0, 1, 5)
386
- G.add_edge(0, 0, 0)
387
- G.add_edge(0, 2, 5)
388
- actual = nx.contracted_nodes(G, 0, 2)
389
- expected = nx.MultiGraph()
390
- expected.add_edge(0, 1, 0)
391
- expected.add_edge(0, 1, 5)
392
- expected.add_edge(0, 1, 2) # keyed as 2 b/c 2 edges already in G
393
- expected.add_edge(0, 0, 0)
394
- expected.add_edge(0, 0, 1) # this comes from (0, 2, 5)
395
- assert edges_equal(actual.edges, expected.edges)
396
-
397
-
398
- @pytest.mark.parametrize("store_contraction_as", ("contraction", "c", None))
399
- @pytest.mark.parametrize("copy", (True, False))
400
- @pytest.mark.parametrize("selfloops", (True, False))
401
- def test_node_attributes(store_contraction_as, copy, selfloops):
402
- """Tests that node contraction preserves node attributes."""
403
- G = nx.cycle_graph(4)
404
- # Add some data to the two nodes being contracted.
405
- G.nodes[0]["foo"] = "bar"
406
- G.nodes[1]["baz"] = "xyzzy"
407
- actual = nx.contracted_nodes(
408
- G,
409
- 0,
410
- 1,
411
- copy=copy,
412
- self_loops=selfloops,
413
- store_contraction_as=store_contraction_as,
414
- )
415
- # We expect that contracting the nodes 0 and 1 in C_4 yields K_3, but
416
- # with nodes labeled 0, 2, and 3.
417
- expected = nx.complete_graph(3)
418
- expected = nx.relabel_nodes(expected, {1: 2, 2: 3})
419
- expected.nodes[0]["foo"] = "bar"
420
- # ... and a self-loop (0, 0), if self_loops=True
421
- if selfloops:
422
- expected.add_edge(0, 0)
423
-
424
- if store_contraction_as:
425
- cdict = {1: {"baz": "xyzzy"}}
426
- expected.nodes[0].update({"foo": "bar", store_contraction_as: cdict})
427
-
428
- assert nx.is_isomorphic(actual, expected)
429
- assert actual.nodes(data=True) == expected.nodes(data=True)
430
- if not copy:
431
- assert actual is G
432
-
433
-
434
- @pytest.mark.parametrize("store_contraction_as", ("contraction", "c", None))
435
- def test_edge_attributes(store_contraction_as):
436
- """Tests that node contraction preserves edge attributes."""
437
- # Shape: src1 --> dest <-- src2
438
- G = nx.DiGraph([("src1", "dest"), ("src2", "dest")])
439
- G["src1"]["dest"]["value"] = "src1-->dest"
440
- G["src2"]["dest"]["value"] = "src2-->dest"
441
-
442
- # New Shape: src1 --> dest
443
- H = nx.contracted_nodes(
444
- G, "src1", "src2", store_contraction_as=store_contraction_as
445
- )
446
- assert H.edges[("src1", "dest")]["value"] == "src1-->dest" # Should be unchanged
447
- if store_contraction_as:
448
- assert (
449
- H.edges[("src1", "dest")][store_contraction_as][("src2", "dest")]["value"]
450
- == "src2-->dest"
451
- )
452
- else:
453
- assert store_contraction_as not in H.edges[("src1", "dest")]
454
-
455
- G = nx.MultiDiGraph(G)
456
- # New Shape: src1 -(x2)-> dest
457
- H = nx.contracted_nodes(
458
- G, "src1", "src2", store_contraction_as=store_contraction_as
459
- )
460
- # store_contraction should not affect multigraphs
461
- assert len(H.edges(("src1", "dest"))) == 2
462
- assert H.edges[("src1", "dest", 0)]["value"] == "src1-->dest"
463
- assert H.edges[("src1", "dest", 1)]["value"] == "src2-->dest"
464
-
465
-
466
- def test_contract_loop_graph():
467
- """Tests for node contraction when nodes have loops."""
468
- G = nx.cycle_graph(4)
469
- G.add_edge(0, 0)
470
- actual = nx.contracted_nodes(G, 0, 1)
471
- expected = nx.complete_graph([0, 2, 3])
472
- expected.add_edge(0, 0)
473
- assert edges_equal(actual.edges, expected.edges)
474
- actual = nx.contracted_nodes(G, 1, 0)
475
- expected = nx.complete_graph([1, 2, 3])
476
- expected.add_edge(1, 1)
477
- assert edges_equal(actual.edges, expected.edges)
478
-
479
-
480
- @pytest.mark.parametrize("store_contraction_as", ("contraction", "c", None))
481
- @pytest.mark.parametrize("copy", (True, False))
482
- @pytest.mark.parametrize("selfloops", (True, False))
483
- def test_undirected_edge_contraction(store_contraction_as, copy, selfloops):
484
- """Tests for node contraction in an undirected graph."""
485
- G = nx.cycle_graph(4)
486
- actual = nx.contracted_edge(
487
- G,
488
- (0, 1),
489
- copy=copy,
490
- self_loops=selfloops,
491
- store_contraction_as=store_contraction_as,
492
- )
493
-
494
- expected = nx.cycle_graph(3)
495
- if selfloops:
496
- expected.add_edge(0, 0)
497
-
498
- assert nx.is_isomorphic(actual, expected)
499
-
500
- if not copy:
501
- assert actual is G
502
-
503
- # Test contracted node attributes
504
- if store_contraction_as is not None:
505
- assert actual.nodes[0][store_contraction_as] == {1: {}}
506
- else:
507
- assert actual.nodes[0] == {}
508
- # There should be no contracted edges for this case
509
- assert all(d == {} for _, _, d in actual.edges(data=True))
510
-
511
-
512
- @pytest.mark.parametrize("edge", [(0, 1), (0, 1, 0)])
513
- @pytest.mark.parametrize("store_contraction_as", ("contraction", "c", None))
514
- @pytest.mark.parametrize("copy", [True, False])
515
- @pytest.mark.parametrize("selfloops", [True, False])
516
- def test_multigraph_edge_contraction(edge, store_contraction_as, copy, selfloops):
517
- """Tests for edge contraction in a multigraph"""
518
- G = nx.cycle_graph(4, create_using=nx.MultiGraph)
519
- actual = nx.contracted_edge(
520
- G,
521
- edge,
522
- copy=copy,
523
- self_loops=selfloops,
524
- store_contraction_as=store_contraction_as,
525
- )
526
- expected = nx.relabel_nodes(
527
- nx.complete_graph(3, create_using=nx.MultiGraph), {0: 0, 1: 2, 2: 3}
528
- )
529
- if selfloops:
530
- expected.add_edge(0, 0)
531
-
532
- assert edges_equal(actual.edges, expected.edges)
533
- if not copy:
534
- assert actual is G
535
-
536
-
537
- def test_nonexistent_edge():
538
- """Tests that attempting to contract a nonexistent edge raises an
539
- exception.
540
-
541
- """
542
- G = nx.cycle_graph(4)
543
- with pytest.raises(ValueError):
544
- nx.contracted_edge(G, (0, 2))