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,872 +0,0 @@
1
- import copy
2
-
3
- import pytest
4
-
5
- import networkx as nx
6
-
7
- # Unit tests relevant for both functions in this module.
8
-
9
-
10
- def test_positive_iters():
11
- G1 = nx.empty_graph()
12
- with pytest.raises(
13
- ValueError,
14
- match="The WL algorithm requires that `iterations` be positive",
15
- ):
16
- nx.weisfeiler_lehman_graph_hash(G1, iterations=-3)
17
- with pytest.raises(
18
- ValueError,
19
- match="The WL algorithm requires that `iterations` be positive",
20
- ):
21
- nx.weisfeiler_lehman_subgraph_hashes(G1, iterations=-3)
22
- with pytest.raises(
23
- ValueError,
24
- match="The WL algorithm requires that `iterations` be positive",
25
- ):
26
- nx.weisfeiler_lehman_graph_hash(G1, iterations=0)
27
- with pytest.raises(
28
- ValueError,
29
- match="The WL algorithm requires that `iterations` be positive",
30
- ):
31
- nx.weisfeiler_lehman_subgraph_hashes(G1, iterations=0)
32
-
33
-
34
- # Unit tests for the :func:`~networkx.weisfeiler_lehman_graph_hash` function
35
-
36
-
37
- def test_empty_graph_hash():
38
- """
39
- empty graphs should give hashes regardless of other params
40
- """
41
- G1 = nx.empty_graph()
42
- G2 = nx.empty_graph()
43
-
44
- h1 = nx.weisfeiler_lehman_graph_hash(G1)
45
- h2 = nx.weisfeiler_lehman_graph_hash(G2)
46
- h3 = nx.weisfeiler_lehman_graph_hash(G2, edge_attr="edge_attr1")
47
- h4 = nx.weisfeiler_lehman_graph_hash(G2, node_attr="node_attr1")
48
- h5 = nx.weisfeiler_lehman_graph_hash(
49
- G2, edge_attr="edge_attr1", node_attr="node_attr1"
50
- )
51
- h6 = nx.weisfeiler_lehman_graph_hash(G2, iterations=10)
52
-
53
- assert h1 == h2
54
- assert h1 == h3
55
- assert h1 == h4
56
- assert h1 == h5
57
- assert h1 == h6
58
-
59
-
60
- def test_directed():
61
- """
62
- A directed graph with no bi-directional edges should yield different a graph hash
63
- to the same graph taken as undirected if there are no hash collisions.
64
- """
65
- r = 10
66
- for i in range(r):
67
- G_directed = nx.gn_graph(10 + r, seed=100 + i)
68
- G_undirected = nx.to_undirected(G_directed)
69
-
70
- h_directed = nx.weisfeiler_lehman_graph_hash(G_directed)
71
- h_undirected = nx.weisfeiler_lehman_graph_hash(G_undirected)
72
-
73
- assert h_directed != h_undirected
74
-
75
-
76
- def test_reversed():
77
- """
78
- A directed graph with no bi-directional edges should yield different a graph hash
79
- to the same graph taken with edge directions reversed if there are no hash
80
- collisions. Here we test a cycle graph which is the minimal counterexample
81
- """
82
- G = nx.cycle_graph(5, create_using=nx.DiGraph)
83
- nx.set_node_attributes(G, {n: str(n) for n in G.nodes()}, name="label")
84
-
85
- G_reversed = G.reverse()
86
-
87
- h = nx.weisfeiler_lehman_graph_hash(G, node_attr="label")
88
- h_reversed = nx.weisfeiler_lehman_graph_hash(G_reversed, node_attr="label")
89
-
90
- assert h != h_reversed
91
-
92
-
93
- def test_isomorphic():
94
- """
95
- graph hashes should be invariant to node-relabeling (when the output is reindexed
96
- by the same mapping)
97
- """
98
- n, r = 100, 10
99
- p = 1.0 / r
100
- for i in range(1, r + 1):
101
- G1 = nx.erdos_renyi_graph(n, p * i, seed=200 + i)
102
- G2 = nx.relabel_nodes(G1, {u: -1 * u for u in G1.nodes()})
103
-
104
- g1_hash = nx.weisfeiler_lehman_graph_hash(G1)
105
- g2_hash = nx.weisfeiler_lehman_graph_hash(G2)
106
-
107
- assert g1_hash == g2_hash
108
-
109
-
110
- def test_isomorphic_edge_attr():
111
- """
112
- Isomorphic graphs with differing edge attributes should yield different graph
113
- hashes if the 'edge_attr' argument is supplied and populated in the graph,
114
- and there are no hash collisions.
115
- The output should still be invariant to node-relabeling
116
- """
117
- n, r = 100, 10
118
- p = 1.0 / r
119
- for i in range(1, r + 1):
120
- G1 = nx.erdos_renyi_graph(n, p * i, seed=300 + i)
121
-
122
- for a, b in G1.edges:
123
- G1[a][b]["edge_attr1"] = f"{a}-{b}-1"
124
- G1[a][b]["edge_attr2"] = f"{a}-{b}-2"
125
-
126
- g1_hash_with_edge_attr1 = nx.weisfeiler_lehman_graph_hash(
127
- G1, edge_attr="edge_attr1"
128
- )
129
- g1_hash_with_edge_attr2 = nx.weisfeiler_lehman_graph_hash(
130
- G1, edge_attr="edge_attr2"
131
- )
132
- g1_hash_no_edge_attr = nx.weisfeiler_lehman_graph_hash(G1, edge_attr=None)
133
-
134
- assert g1_hash_with_edge_attr1 != g1_hash_no_edge_attr
135
- assert g1_hash_with_edge_attr2 != g1_hash_no_edge_attr
136
- assert g1_hash_with_edge_attr1 != g1_hash_with_edge_attr2
137
-
138
- G2 = nx.relabel_nodes(G1, {u: -1 * u for u in G1.nodes()})
139
-
140
- g2_hash_with_edge_attr1 = nx.weisfeiler_lehman_graph_hash(
141
- G2, edge_attr="edge_attr1"
142
- )
143
- g2_hash_with_edge_attr2 = nx.weisfeiler_lehman_graph_hash(
144
- G2, edge_attr="edge_attr2"
145
- )
146
-
147
- assert g1_hash_with_edge_attr1 == g2_hash_with_edge_attr1
148
- assert g1_hash_with_edge_attr2 == g2_hash_with_edge_attr2
149
-
150
-
151
- def test_missing_edge_attr():
152
- """
153
- If the 'edge_attr' argument is supplied but is missing from an edge in the graph,
154
- we should raise a KeyError
155
- """
156
- G = nx.Graph()
157
- G.add_edges_from([(1, 2, {"edge_attr1": "a"}), (1, 3, {})])
158
- pytest.raises(KeyError, nx.weisfeiler_lehman_graph_hash, G, edge_attr="edge_attr1")
159
-
160
-
161
- def test_isomorphic_node_attr():
162
- """
163
- Isomorphic graphs with differing node attributes should yield different graph
164
- hashes if the 'node_attr' argument is supplied and populated in the graph, and
165
- there are no hash collisions.
166
- The output should still be invariant to node-relabeling
167
- """
168
- n, r = 100, 10
169
- p = 1.0 / r
170
- for i in range(1, r + 1):
171
- G1 = nx.erdos_renyi_graph(n, p * i, seed=400 + i)
172
-
173
- for u in G1.nodes():
174
- G1.nodes[u]["node_attr1"] = f"{u}-1"
175
- G1.nodes[u]["node_attr2"] = f"{u}-2"
176
-
177
- g1_hash_with_node_attr1 = nx.weisfeiler_lehman_graph_hash(
178
- G1, node_attr="node_attr1"
179
- )
180
- g1_hash_with_node_attr2 = nx.weisfeiler_lehman_graph_hash(
181
- G1, node_attr="node_attr2"
182
- )
183
- g1_hash_no_node_attr = nx.weisfeiler_lehman_graph_hash(G1, node_attr=None)
184
-
185
- assert g1_hash_with_node_attr1 != g1_hash_no_node_attr
186
- assert g1_hash_with_node_attr2 != g1_hash_no_node_attr
187
- assert g1_hash_with_node_attr1 != g1_hash_with_node_attr2
188
-
189
- G2 = nx.relabel_nodes(G1, {u: -1 * u for u in G1.nodes()})
190
-
191
- g2_hash_with_node_attr1 = nx.weisfeiler_lehman_graph_hash(
192
- G2, node_attr="node_attr1"
193
- )
194
- g2_hash_with_node_attr2 = nx.weisfeiler_lehman_graph_hash(
195
- G2, node_attr="node_attr2"
196
- )
197
-
198
- assert g1_hash_with_node_attr1 == g2_hash_with_node_attr1
199
- assert g1_hash_with_node_attr2 == g2_hash_with_node_attr2
200
-
201
-
202
- def test_missing_node_attr():
203
- """
204
- If the 'node_attr' argument is supplied but is missing from a node in the graph,
205
- we should raise a KeyError
206
- """
207
- G = nx.Graph()
208
- G.add_nodes_from([(1, {"node_attr1": "a"}), (2, {})])
209
- G.add_edges_from([(1, 2), (2, 3), (3, 1), (1, 4)])
210
- pytest.raises(KeyError, nx.weisfeiler_lehman_graph_hash, G, node_attr="node_attr1")
211
-
212
-
213
- def test_isomorphic_edge_attr_and_node_attr():
214
- """
215
- Isomorphic graphs with differing node attributes should yield different graph
216
- hashes if the 'node_attr' and 'edge_attr' argument is supplied and populated in
217
- the graph, and there are no hash collisions.
218
- The output should still be invariant to node-relabeling
219
- """
220
- n, r = 100, 10
221
- p = 1.0 / r
222
- for i in range(1, r + 1):
223
- G1 = nx.erdos_renyi_graph(n, p * i, seed=500 + i)
224
-
225
- for u in G1.nodes():
226
- G1.nodes[u]["node_attr1"] = f"{u}-1"
227
- G1.nodes[u]["node_attr2"] = f"{u}-2"
228
-
229
- for a, b in G1.edges:
230
- G1[a][b]["edge_attr1"] = f"{a}-{b}-1"
231
- G1[a][b]["edge_attr2"] = f"{a}-{b}-2"
232
-
233
- g1_hash_edge1_node1 = nx.weisfeiler_lehman_graph_hash(
234
- G1, edge_attr="edge_attr1", node_attr="node_attr1"
235
- )
236
- g1_hash_edge2_node2 = nx.weisfeiler_lehman_graph_hash(
237
- G1, edge_attr="edge_attr2", node_attr="node_attr2"
238
- )
239
- g1_hash_edge1_node2 = nx.weisfeiler_lehman_graph_hash(
240
- G1, edge_attr="edge_attr1", node_attr="node_attr2"
241
- )
242
- g1_hash_no_attr = nx.weisfeiler_lehman_graph_hash(G1)
243
-
244
- assert g1_hash_edge1_node1 != g1_hash_no_attr
245
- assert g1_hash_edge2_node2 != g1_hash_no_attr
246
- assert g1_hash_edge1_node1 != g1_hash_edge2_node2
247
- assert g1_hash_edge1_node2 != g1_hash_edge2_node2
248
- assert g1_hash_edge1_node2 != g1_hash_edge1_node1
249
-
250
- G2 = nx.relabel_nodes(G1, {u: -1 * u for u in G1.nodes()})
251
-
252
- g2_hash_edge1_node1 = nx.weisfeiler_lehman_graph_hash(
253
- G2, edge_attr="edge_attr1", node_attr="node_attr1"
254
- )
255
- g2_hash_edge2_node2 = nx.weisfeiler_lehman_graph_hash(
256
- G2, edge_attr="edge_attr2", node_attr="node_attr2"
257
- )
258
-
259
- assert g1_hash_edge1_node1 == g2_hash_edge1_node1
260
- assert g1_hash_edge2_node2 == g2_hash_edge2_node2
261
-
262
-
263
- def test_digest_size():
264
- """
265
- The hash string lengths should be as expected for a variety of graphs and
266
- digest sizes
267
- """
268
- n, r = 100, 10
269
- p = 1.0 / r
270
- for i in range(1, r + 1):
271
- G = nx.erdos_renyi_graph(n, p * i, seed=1000 + i)
272
-
273
- h16 = nx.weisfeiler_lehman_graph_hash(G)
274
- h32 = nx.weisfeiler_lehman_graph_hash(G, digest_size=32)
275
-
276
- assert h16 != h32
277
- assert len(h16) == 16 * 2
278
- assert len(h32) == 32 * 2
279
-
280
-
281
- def test_directed_bugs():
282
- """
283
- These were bugs for directed graphs as discussed in issue #7806
284
- """
285
- Ga = nx.DiGraph()
286
- Gb = nx.DiGraph()
287
- Ga.add_nodes_from([1, 2, 3, 4])
288
- Gb.add_nodes_from([1, 2, 3, 4])
289
- Ga.add_edges_from([(1, 2), (3, 2)])
290
- Gb.add_edges_from([(1, 2), (3, 4)])
291
- Ga_hash = nx.weisfeiler_lehman_graph_hash(Ga)
292
- Gb_hash = nx.weisfeiler_lehman_graph_hash(Gb)
293
- assert Ga_hash != Gb_hash
294
-
295
- Tree1 = nx.DiGraph()
296
- Tree1.add_edges_from([(0, 4), (1, 5), (2, 6), (3, 7)])
297
- Tree1.add_edges_from([(4, 8), (5, 8), (6, 9), (7, 9)])
298
- Tree1.add_edges_from([(8, 10), (9, 10)])
299
- nx.set_node_attributes(
300
- Tree1, {10: "s", 8: "a", 9: "a", 4: "b", 5: "b", 6: "b", 7: "b"}, "weight"
301
- )
302
- Tree2 = copy.deepcopy(Tree1)
303
- nx.set_node_attributes(Tree1, {0: "d", 1: "c", 2: "d", 3: "c"}, "weight")
304
- nx.set_node_attributes(Tree2, {0: "d", 1: "d", 2: "c", 3: "c"}, "weight")
305
- Tree1_hash_short = nx.weisfeiler_lehman_graph_hash(
306
- Tree1, iterations=1, node_attr="weight"
307
- )
308
- Tree2_hash_short = nx.weisfeiler_lehman_graph_hash(
309
- Tree2, iterations=1, node_attr="weight"
310
- )
311
- assert Tree1_hash_short == Tree2_hash_short
312
- Tree1_hash = nx.weisfeiler_lehman_graph_hash(
313
- Tree1, node_attr="weight"
314
- ) # Default is 3 iterations
315
- Tree2_hash = nx.weisfeiler_lehman_graph_hash(Tree2, node_attr="weight")
316
- assert Tree1_hash != Tree2_hash
317
-
318
-
319
- def test_trivial_labels_isomorphism():
320
- """
321
- Trivial labelling of the graph should not change isomorphism verdicts.
322
- """
323
- n, r = 100, 10
324
- p = 1.0 / r
325
- for i in range(1, r + 1):
326
- G1 = nx.erdos_renyi_graph(n, p * i, seed=500 + i)
327
- G2 = nx.erdos_renyi_graph(n, p * i, seed=42 + i)
328
- G1_hash = nx.weisfeiler_lehman_graph_hash(G1)
329
- G2_hash = nx.weisfeiler_lehman_graph_hash(G2)
330
- equal = G1_hash == G2_hash
331
-
332
- nx.set_node_attributes(G1, values=1, name="weight")
333
- nx.set_node_attributes(G2, values=1, name="weight")
334
- G1_hash_node = nx.weisfeiler_lehman_graph_hash(G1, node_attr="weight")
335
- G2_hash_node = nx.weisfeiler_lehman_graph_hash(G2, node_attr="weight")
336
- equal_node = G1_hash_node == G2_hash_node
337
-
338
- nx.set_edge_attributes(G1, values="a", name="e_weight")
339
- nx.set_edge_attributes(G2, values="a", name="e_weight")
340
- G1_hash_edge = nx.weisfeiler_lehman_graph_hash(G1, edge_attr="e_weight")
341
- G2_hash_edge = nx.weisfeiler_lehman_graph_hash(G2, edge_attr="e_weight")
342
- equal_edge = G1_hash_edge == G2_hash_edge
343
-
344
- G1_hash_both = nx.weisfeiler_lehman_graph_hash(
345
- G1, edge_attr="e_weight", node_attr="weight"
346
- )
347
- G2_hash_both = nx.weisfeiler_lehman_graph_hash(
348
- G2, edge_attr="e_weight", node_attr="weight"
349
- )
350
- equal_both = G1_hash_both == G2_hash_both
351
-
352
- assert equal == equal_node
353
- assert equal_node == equal_edge
354
- assert equal_edge == equal_both
355
-
356
-
357
- def test_trivial_labels_isomorphism_directed():
358
- """
359
- Trivial labelling of the graph should not change isomorphism verdicts on digraphs.
360
- """
361
- n, r = 100, 10
362
- p = 1.0 / r
363
- for i in range(1, r + 1):
364
- G1 = nx.erdos_renyi_graph(n, p * i, directed=True, seed=500 + i)
365
- G2 = nx.erdos_renyi_graph(n, p * i, directed=True, seed=42 + i)
366
- G1_hash = nx.weisfeiler_lehman_graph_hash(G1)
367
- G2_hash = nx.weisfeiler_lehman_graph_hash(G2)
368
- equal = G1_hash == G2_hash
369
-
370
- nx.set_node_attributes(G1, values=1, name="weight")
371
- nx.set_node_attributes(G2, values=1, name="weight")
372
- G1_hash_node = nx.weisfeiler_lehman_graph_hash(G1, node_attr="weight")
373
- G2_hash_node = nx.weisfeiler_lehman_graph_hash(G2, node_attr="weight")
374
- equal_node = G1_hash_node == G2_hash_node
375
-
376
- nx.set_edge_attributes(G1, values="a", name="e_weight")
377
- nx.set_edge_attributes(G2, values="a", name="e_weight")
378
- G1_hash_edge = nx.weisfeiler_lehman_graph_hash(G1, edge_attr="e_weight")
379
- G2_hash_edge = nx.weisfeiler_lehman_graph_hash(G2, edge_attr="e_weight")
380
- equal_edge = G1_hash_edge == G2_hash_edge
381
-
382
- G1_hash_both = nx.weisfeiler_lehman_graph_hash(
383
- G1, edge_attr="e_weight", node_attr="weight"
384
- )
385
- G2_hash_both = nx.weisfeiler_lehman_graph_hash(
386
- G2, edge_attr="e_weight", node_attr="weight"
387
- )
388
- equal_both = G1_hash_both == G2_hash_both
389
-
390
- assert equal == equal_node
391
- assert equal_node == equal_edge
392
- assert equal_edge == equal_both
393
-
394
- # Specific case that was found to be a bug in issue #7806
395
- # Without weights worked
396
- Ga = nx.DiGraph()
397
- Ga.add_nodes_from([1, 2, 3, 4])
398
- Gb = copy.deepcopy(Ga)
399
- Ga.add_edges_from([(1, 2), (3, 2)])
400
- Gb.add_edges_from([(1, 2), (3, 4)])
401
- Ga_hash = nx.weisfeiler_lehman_graph_hash(Ga)
402
- Gb_hash = nx.weisfeiler_lehman_graph_hash(Gb)
403
- assert Ga_hash != Gb_hash
404
-
405
- # Now with trivial weights
406
- nx.set_node_attributes(Ga, values=1, name="weight")
407
- nx.set_node_attributes(Gb, values=1, name="weight")
408
- Ga_hash = nx.weisfeiler_lehman_graph_hash(Ga, node_attr="weight")
409
- Gb_hash = nx.weisfeiler_lehman_graph_hash(Gb, node_attr="weight")
410
- assert Ga_hash != Gb_hash
411
-
412
-
413
- def test_trivial_labels_hashes():
414
- """
415
- Test that 'empty' labelling of nodes or edges shouldn't have a different impact
416
- on the calculated hash. Note that we cannot assume that trivial weights have no
417
- impact at all. Without (trivial) weights, a node will start with hashing its
418
- degree. This step is omitted when there are weights.
419
- """
420
- n, r = 100, 10
421
- p = 1.0 / r
422
- for i in range(1, r + 1):
423
- G1 = nx.erdos_renyi_graph(n, p * i, seed=500 + i)
424
- nx.set_node_attributes(G1, values="", name="weight")
425
- first = nx.weisfeiler_lehman_graph_hash(G1, node_attr="weight")
426
- nx.set_edge_attributes(G1, values="", name="e_weight")
427
- second = nx.weisfeiler_lehman_graph_hash(G1, edge_attr="e_weight")
428
- assert first == second
429
- third = nx.weisfeiler_lehman_graph_hash(
430
- G1, edge_attr="e_weight", node_attr="weight"
431
- )
432
- assert second == third
433
-
434
-
435
- # Unit tests for the :func:`~networkx.weisfeiler_lehman_subgraph_hashes` function
436
-
437
-
438
- def is_subiteration(a, b):
439
- """
440
- returns True if that each hash sequence in 'a' is a prefix for
441
- the corresponding sequence indexed by the same node in 'b'.
442
- """
443
- return all(b[node][: len(hashes)] == hashes for node, hashes in a.items())
444
-
445
-
446
- def hexdigest_sizes_correct(a, digest_size):
447
- """
448
- returns True if all hex digest sizes are the expected length in a
449
- node:subgraph-hashes dictionary. Hex digest string length == 2 * bytes digest
450
- length since each pair of hex digits encodes 1 byte
451
- (https://docs.python.org/3/library/hashlib.html)
452
- """
453
- hexdigest_size = digest_size * 2
454
-
455
- def list_digest_sizes_correct(l):
456
- return all(len(x) == hexdigest_size for x in l)
457
-
458
- return all(list_digest_sizes_correct(hashes) for hashes in a.values())
459
-
460
-
461
- def test_empty_graph_subgraph_hash():
462
- """ "
463
- empty graphs should give empty dict subgraph hashes regardless of other params
464
- """
465
- G = nx.empty_graph()
466
-
467
- subgraph_hashes1 = nx.weisfeiler_lehman_subgraph_hashes(G)
468
- subgraph_hashes2 = nx.weisfeiler_lehman_subgraph_hashes(G, edge_attr="edge_attr")
469
- subgraph_hashes3 = nx.weisfeiler_lehman_subgraph_hashes(G, node_attr="edge_attr")
470
- subgraph_hashes4 = nx.weisfeiler_lehman_subgraph_hashes(G, iterations=2)
471
- subgraph_hashes5 = nx.weisfeiler_lehman_subgraph_hashes(G, digest_size=64)
472
-
473
- assert subgraph_hashes1 == {}
474
- assert subgraph_hashes2 == {}
475
- assert subgraph_hashes3 == {}
476
- assert subgraph_hashes4 == {}
477
- assert subgraph_hashes5 == {}
478
-
479
-
480
- def test_directed_subgraph_hash():
481
- """
482
- A directed graph with no bi-directional edges should yield different subgraph
483
- hashes to the same graph taken as undirected, if all hashes don't collide.
484
- """
485
- r = 10
486
- for i in range(r):
487
- G_directed = nx.gn_graph(10 + r, seed=100 + i)
488
- G_undirected = nx.to_undirected(G_directed)
489
-
490
- directed_subgraph_hashes = nx.weisfeiler_lehman_subgraph_hashes(G_directed)
491
- undirected_subgraph_hashes = nx.weisfeiler_lehman_subgraph_hashes(G_undirected)
492
-
493
- assert directed_subgraph_hashes != undirected_subgraph_hashes
494
-
495
-
496
- def test_reversed_subgraph_hash():
497
- """
498
- A directed graph with no bi-directional edges should yield different subgraph
499
- hashes to the same graph taken with edge directions reversed if there are no
500
- hash collisions. Here we test a cycle graph which is the minimal counterexample
501
- """
502
- G = nx.cycle_graph(5, create_using=nx.DiGraph)
503
- nx.set_node_attributes(G, {n: str(n) for n in G.nodes()}, name="label")
504
-
505
- G_reversed = G.reverse()
506
-
507
- h = nx.weisfeiler_lehman_subgraph_hashes(G, node_attr="label")
508
- h_reversed = nx.weisfeiler_lehman_subgraph_hashes(G_reversed, node_attr="label")
509
-
510
- assert h != h_reversed
511
-
512
-
513
- def test_isomorphic_subgraph_hash():
514
- """
515
- the subgraph hashes should be invariant to node-relabeling when the output is
516
- reindexed by the same mapping and all hashes don't collide.
517
- """
518
- n, r = 100, 10
519
- p = 1.0 / r
520
- for i in range(1, r + 1):
521
- G1 = nx.erdos_renyi_graph(n, p * i, seed=200 + i)
522
- G2 = nx.relabel_nodes(G1, {u: -1 * u for u in G1.nodes()})
523
-
524
- g1_subgraph_hashes = nx.weisfeiler_lehman_subgraph_hashes(G1)
525
- g2_subgraph_hashes = nx.weisfeiler_lehman_subgraph_hashes(G2)
526
-
527
- assert g1_subgraph_hashes == {-1 * k: v for k, v in g2_subgraph_hashes.items()}
528
-
529
-
530
- def test_isomorphic_edge_attr_subgraph_hash():
531
- """
532
- Isomorphic graphs with differing edge attributes should yield different subgraph
533
- hashes if the 'edge_attr' argument is supplied and populated in the graph, and
534
- all hashes don't collide.
535
- The output should still be invariant to node-relabeling
536
- """
537
- n, r = 100, 10
538
- p = 1.0 / r
539
- for i in range(1, r + 1):
540
- G1 = nx.erdos_renyi_graph(n, p * i, seed=300 + i)
541
-
542
- for a, b in G1.edges:
543
- G1[a][b]["edge_attr1"] = f"{a}-{b}-1"
544
- G1[a][b]["edge_attr2"] = f"{a}-{b}-2"
545
-
546
- g1_hash_with_edge_attr1 = nx.weisfeiler_lehman_subgraph_hashes(
547
- G1, edge_attr="edge_attr1"
548
- )
549
- g1_hash_with_edge_attr2 = nx.weisfeiler_lehman_subgraph_hashes(
550
- G1, edge_attr="edge_attr2"
551
- )
552
- g1_hash_no_edge_attr = nx.weisfeiler_lehman_subgraph_hashes(G1, edge_attr=None)
553
-
554
- assert g1_hash_with_edge_attr1 != g1_hash_no_edge_attr
555
- assert g1_hash_with_edge_attr2 != g1_hash_no_edge_attr
556
- assert g1_hash_with_edge_attr1 != g1_hash_with_edge_attr2
557
-
558
- G2 = nx.relabel_nodes(G1, {u: -1 * u for u in G1.nodes()})
559
-
560
- g2_hash_with_edge_attr1 = nx.weisfeiler_lehman_subgraph_hashes(
561
- G2, edge_attr="edge_attr1"
562
- )
563
- g2_hash_with_edge_attr2 = nx.weisfeiler_lehman_subgraph_hashes(
564
- G2, edge_attr="edge_attr2"
565
- )
566
-
567
- assert g1_hash_with_edge_attr1 == {
568
- -1 * k: v for k, v in g2_hash_with_edge_attr1.items()
569
- }
570
- assert g1_hash_with_edge_attr2 == {
571
- -1 * k: v for k, v in g2_hash_with_edge_attr2.items()
572
- }
573
-
574
-
575
- def test_missing_edge_attr_subgraph_hash():
576
- """
577
- If the 'edge_attr' argument is supplied but is missing from an edge in the graph,
578
- we should raise a KeyError
579
- """
580
- G = nx.Graph()
581
- G.add_edges_from([(1, 2, {"edge_attr1": "a"}), (1, 3, {})])
582
- pytest.raises(
583
- KeyError, nx.weisfeiler_lehman_subgraph_hashes, G, edge_attr="edge_attr1"
584
- )
585
-
586
-
587
- def test_isomorphic_node_attr_subgraph_hash():
588
- """
589
- Isomorphic graphs with differing node attributes should yield different subgraph
590
- hashes if the 'node_attr' argument is supplied and populated in the graph, and
591
- all hashes don't collide.
592
- The output should still be invariant to node-relabeling
593
- """
594
- n, r = 100, 10
595
- p = 1.0 / r
596
- for i in range(1, r + 1):
597
- G1 = nx.erdos_renyi_graph(n, p * i, seed=400 + i)
598
-
599
- for u in G1.nodes():
600
- G1.nodes[u]["node_attr1"] = f"{u}-1"
601
- G1.nodes[u]["node_attr2"] = f"{u}-2"
602
-
603
- g1_hash_with_node_attr1 = nx.weisfeiler_lehman_subgraph_hashes(
604
- G1, node_attr="node_attr1"
605
- )
606
- g1_hash_with_node_attr2 = nx.weisfeiler_lehman_subgraph_hashes(
607
- G1, node_attr="node_attr2"
608
- )
609
- g1_hash_no_node_attr = nx.weisfeiler_lehman_subgraph_hashes(G1, node_attr=None)
610
-
611
- assert g1_hash_with_node_attr1 != g1_hash_no_node_attr
612
- assert g1_hash_with_node_attr2 != g1_hash_no_node_attr
613
- assert g1_hash_with_node_attr1 != g1_hash_with_node_attr2
614
-
615
- G2 = nx.relabel_nodes(G1, {u: -1 * u for u in G1.nodes()})
616
-
617
- g2_hash_with_node_attr1 = nx.weisfeiler_lehman_subgraph_hashes(
618
- G2, node_attr="node_attr1"
619
- )
620
- g2_hash_with_node_attr2 = nx.weisfeiler_lehman_subgraph_hashes(
621
- G2, node_attr="node_attr2"
622
- )
623
-
624
- assert g1_hash_with_node_attr1 == {
625
- -1 * k: v for k, v in g2_hash_with_node_attr1.items()
626
- }
627
- assert g1_hash_with_node_attr2 == {
628
- -1 * k: v for k, v in g2_hash_with_node_attr2.items()
629
- }
630
-
631
-
632
- def test_missing_node_attr_subgraph_hash():
633
- """
634
- If the 'node_attr' argument is supplied but is missing from a node in the graph,
635
- we should raise a KeyError
636
- """
637
- G = nx.Graph()
638
- G.add_nodes_from([(1, {"node_attr1": "a"}), (2, {})])
639
- G.add_edges_from([(1, 2), (2, 3), (3, 1), (1, 4)])
640
- pytest.raises(
641
- KeyError, nx.weisfeiler_lehman_subgraph_hashes, G, node_attr="node_attr1"
642
- )
643
-
644
-
645
- def test_isomorphic_edge_attr_and_node_attr_subgraph_hash():
646
- """
647
- Isomorphic graphs with differing node attributes should yield different subgraph
648
- hashes if the 'node_attr' and 'edge_attr' argument is supplied and populated in
649
- the graph, and all hashes don't collide
650
- The output should still be invariant to node-relabeling
651
- """
652
- n, r = 100, 10
653
- p = 1.0 / r
654
- for i in range(1, r + 1):
655
- G1 = nx.erdos_renyi_graph(n, p * i, seed=500 + i)
656
-
657
- for u in G1.nodes():
658
- G1.nodes[u]["node_attr1"] = f"{u}-1"
659
- G1.nodes[u]["node_attr2"] = f"{u}-2"
660
-
661
- for a, b in G1.edges:
662
- G1[a][b]["edge_attr1"] = f"{a}-{b}-1"
663
- G1[a][b]["edge_attr2"] = f"{a}-{b}-2"
664
-
665
- g1_hash_edge1_node1 = nx.weisfeiler_lehman_subgraph_hashes(
666
- G1, edge_attr="edge_attr1", node_attr="node_attr1"
667
- )
668
- g1_hash_edge2_node2 = nx.weisfeiler_lehman_subgraph_hashes(
669
- G1, edge_attr="edge_attr2", node_attr="node_attr2"
670
- )
671
- g1_hash_edge1_node2 = nx.weisfeiler_lehman_subgraph_hashes(
672
- G1, edge_attr="edge_attr1", node_attr="node_attr2"
673
- )
674
- g1_hash_no_attr = nx.weisfeiler_lehman_subgraph_hashes(G1)
675
-
676
- assert g1_hash_edge1_node1 != g1_hash_no_attr
677
- assert g1_hash_edge2_node2 != g1_hash_no_attr
678
- assert g1_hash_edge1_node1 != g1_hash_edge2_node2
679
- assert g1_hash_edge1_node2 != g1_hash_edge2_node2
680
- assert g1_hash_edge1_node2 != g1_hash_edge1_node1
681
-
682
- G2 = nx.relabel_nodes(G1, {u: -1 * u for u in G1.nodes()})
683
-
684
- g2_hash_edge1_node1 = nx.weisfeiler_lehman_subgraph_hashes(
685
- G2, edge_attr="edge_attr1", node_attr="node_attr1"
686
- )
687
- g2_hash_edge2_node2 = nx.weisfeiler_lehman_subgraph_hashes(
688
- G2, edge_attr="edge_attr2", node_attr="node_attr2"
689
- )
690
-
691
- assert g1_hash_edge1_node1 == {
692
- -1 * k: v for k, v in g2_hash_edge1_node1.items()
693
- }
694
- assert g1_hash_edge2_node2 == {
695
- -1 * k: v for k, v in g2_hash_edge2_node2.items()
696
- }
697
-
698
-
699
- def test_iteration_depth():
700
- """
701
- All nodes should have the correct number of subgraph hashes in the output when
702
- using degree as initial node labels.
703
- Subsequent iteration depths for the same graph should be additive for each node
704
- """
705
- n, r = 100, 10
706
- p = 1.0 / r
707
- for i in range(1, r + 1):
708
- G = nx.erdos_renyi_graph(n, p * i, seed=600 + i)
709
-
710
- depth3 = nx.weisfeiler_lehman_subgraph_hashes(G, iterations=3)
711
- depth4 = nx.weisfeiler_lehman_subgraph_hashes(G, iterations=4)
712
- depth5 = nx.weisfeiler_lehman_subgraph_hashes(G, iterations=5)
713
-
714
- assert all(len(hashes) == 3 for hashes in depth3.values())
715
- assert all(len(hashes) == 4 for hashes in depth4.values())
716
- assert all(len(hashes) == 5 for hashes in depth5.values())
717
-
718
- assert is_subiteration(depth3, depth4)
719
- assert is_subiteration(depth4, depth5)
720
- assert is_subiteration(depth3, depth5)
721
-
722
-
723
- def test_iteration_depth_edge_attr():
724
- """
725
- All nodes should have the correct number of subgraph hashes in the output when
726
- setting initial node labels empty and using an edge attribute when aggregating
727
- neighborhoods.
728
- Subsequent iteration depths for the same graph should be additive for each node
729
- """
730
- n, r = 100, 10
731
- p = 1.0 / r
732
- for i in range(1, r + 1):
733
- G = nx.erdos_renyi_graph(n, p * i, seed=700 + i)
734
-
735
- for a, b in G.edges:
736
- G[a][b]["edge_attr1"] = f"{a}-{b}-1"
737
-
738
- depth3 = nx.weisfeiler_lehman_subgraph_hashes(
739
- G, edge_attr="edge_attr1", iterations=3
740
- )
741
- depth4 = nx.weisfeiler_lehman_subgraph_hashes(
742
- G, edge_attr="edge_attr1", iterations=4
743
- )
744
- depth5 = nx.weisfeiler_lehman_subgraph_hashes(
745
- G, edge_attr="edge_attr1", iterations=5
746
- )
747
-
748
- assert all(len(hashes) == 3 for hashes in depth3.values())
749
- assert all(len(hashes) == 4 for hashes in depth4.values())
750
- assert all(len(hashes) == 5 for hashes in depth5.values())
751
-
752
- assert is_subiteration(depth3, depth4)
753
- assert is_subiteration(depth4, depth5)
754
- assert is_subiteration(depth3, depth5)
755
-
756
-
757
- def test_iteration_depth_node_attr():
758
- """
759
- All nodes should have the correct number of subgraph hashes in the output when
760
- setting initial node labels to an attribute.
761
- Subsequent iteration depths for the same graph should be additive for each node
762
- """
763
- n, r = 100, 10
764
- p = 1.0 / r
765
- for i in range(1, r + 1):
766
- G = nx.erdos_renyi_graph(n, p * i, seed=800 + i)
767
-
768
- for u in G.nodes():
769
- G.nodes[u]["node_attr1"] = f"{u}-1"
770
-
771
- depth3 = nx.weisfeiler_lehman_subgraph_hashes(
772
- G, node_attr="node_attr1", iterations=3
773
- )
774
- depth4 = nx.weisfeiler_lehman_subgraph_hashes(
775
- G, node_attr="node_attr1", iterations=4
776
- )
777
- depth5 = nx.weisfeiler_lehman_subgraph_hashes(
778
- G, node_attr="node_attr1", iterations=5
779
- )
780
-
781
- assert all(len(hashes) == 3 for hashes in depth3.values())
782
- assert all(len(hashes) == 4 for hashes in depth4.values())
783
- assert all(len(hashes) == 5 for hashes in depth5.values())
784
-
785
- assert is_subiteration(depth3, depth4)
786
- assert is_subiteration(depth4, depth5)
787
- assert is_subiteration(depth3, depth5)
788
-
789
-
790
- def test_iteration_depth_node_edge_attr():
791
- """
792
- All nodes should have the correct number of subgraph hashes in the output when
793
- setting initial node labels to an attribute and also using an edge attribute when
794
- aggregating neighborhoods.
795
- Subsequent iteration depths for the same graph should be additive for each node
796
- """
797
- n, r = 100, 10
798
- p = 1.0 / r
799
- for i in range(1, r + 1):
800
- G = nx.erdos_renyi_graph(n, p * i, seed=900 + i)
801
-
802
- for u in G.nodes():
803
- G.nodes[u]["node_attr1"] = f"{u}-1"
804
-
805
- for a, b in G.edges:
806
- G[a][b]["edge_attr1"] = f"{a}-{b}-1"
807
-
808
- depth3 = nx.weisfeiler_lehman_subgraph_hashes(
809
- G, edge_attr="edge_attr1", node_attr="node_attr1", iterations=3
810
- )
811
- depth4 = nx.weisfeiler_lehman_subgraph_hashes(
812
- G, edge_attr="edge_attr1", node_attr="node_attr1", iterations=4
813
- )
814
- depth5 = nx.weisfeiler_lehman_subgraph_hashes(
815
- G, edge_attr="edge_attr1", node_attr="node_attr1", iterations=5
816
- )
817
-
818
- assert all(len(hashes) == 3 for hashes in depth3.values())
819
- assert all(len(hashes) == 4 for hashes in depth4.values())
820
- assert all(len(hashes) == 5 for hashes in depth5.values())
821
-
822
- assert is_subiteration(depth3, depth4)
823
- assert is_subiteration(depth4, depth5)
824
- assert is_subiteration(depth3, depth5)
825
-
826
-
827
- def test_digest_size_subgraph_hash():
828
- """
829
- The hash string lengths should be as expected for a variety of graphs and
830
- digest sizes
831
- """
832
- n, r = 100, 10
833
- p = 1.0 / r
834
- for i in range(1, r + 1):
835
- G = nx.erdos_renyi_graph(n, p * i, seed=1000 + i)
836
-
837
- digest_size16_hashes = nx.weisfeiler_lehman_subgraph_hashes(G)
838
- digest_size32_hashes = nx.weisfeiler_lehman_subgraph_hashes(G, digest_size=32)
839
-
840
- assert digest_size16_hashes != digest_size32_hashes
841
-
842
- assert hexdigest_sizes_correct(digest_size16_hashes, 16)
843
- assert hexdigest_sizes_correct(digest_size32_hashes, 32)
844
-
845
-
846
- def test_initial_node_labels_subgraph_hash():
847
- """
848
- Including the hashed initial label prepends an extra hash to the lists
849
- """
850
- G = nx.path_graph(5)
851
- nx.set_node_attributes(G, {i: int(0 < i < 4) for i in G}, "label")
852
- # initial node labels:
853
- # 0--1--1--1--0
854
-
855
- without_initial_label = nx.weisfeiler_lehman_subgraph_hashes(G, node_attr="label")
856
- assert all(len(v) == 3 for v in without_initial_label.values())
857
- # 3 different 1 hop nhds
858
- assert len({v[0] for v in without_initial_label.values()}) == 3
859
-
860
- with_initial_label = nx.weisfeiler_lehman_subgraph_hashes(
861
- G, node_attr="label", include_initial_labels=True
862
- )
863
- assert all(len(v) == 4 for v in with_initial_label.values())
864
- # 2 different initial labels
865
- assert len({v[0] for v in with_initial_label.values()}) == 2
866
-
867
- # check hashes match otherwise
868
- for u in G:
869
- for a, b in zip(
870
- with_initial_label[u][1:], without_initial_label[u], strict=True
871
- ):
872
- assert a == b