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.
- package/docs/kr/architecture.md +2 -2
- package/docs/kr/follow-ups/2026-07-10-final-report-option-3.md +51 -0
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/agents/workers/report-writer-worker.md +1 -0
- package/runtime/prompts/lead/okstra-lead-contract.md +1 -1
- package/runtime/python/okstra_ctl/implementation_stage.py +46 -39
- package/runtime/python/okstra_ctl/report_views.py +151 -12
- package/runtime/python/okstra_ctl/run.py +24 -24
- package/runtime/python/okstra_ctl/worktree.py +1 -1
- package/runtime/python/okstra_token_usage/claude.py +58 -19
- package/runtime/python/okstra_token_usage/collect.py +3 -1
- package/runtime/python/okstra_vendor/__init__.py +3 -0
- package/runtime/schemas/final-report-v1.0.schema.json +20 -0
- package/runtime/templates/reports/final-report.template.md +14 -0
- package/runtime/templates/reports/i18n/en.json +23 -12
- package/runtime/templates/reports/i18n/ko.json +23 -12
- package/runtime/templates/reports/report.css +55 -0
- package/runtime/templates/reports/report.js +53 -1
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py +0 -41
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_clique.py +0 -112
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_connectivity.py +0 -199
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_density.py +0 -146
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_distance_measures.py +0 -59
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_dominating_set.py +0 -78
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_kcomponents.py +0 -303
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_matching.py +0 -8
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_maxcut.py +0 -94
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_ramsey.py +0 -31
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_steinertree.py +0 -306
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_traveling_salesman.py +0 -1014
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_treewidth.py +0 -274
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_vertex_cover.py +0 -68
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/base_test.py +0 -81
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_connectivity.py +0 -143
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_correlation.py +0 -122
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_mixing.py +0 -174
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_neighbor_degree.py +0 -107
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_pairs.py +0 -87
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_basic.py +0 -125
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_centrality.py +0 -192
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_cluster.py +0 -84
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_covering.py +0 -33
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_edgelist.py +0 -240
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_extendability.py +0 -334
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_generators.py +0 -407
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_link_analysis.py +0 -218
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matching.py +0 -327
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matrix.py +0 -138
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_project.py +0 -409
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_redundancy.py +0 -35
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py +0 -80
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality.py +0 -923
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py +0 -354
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_closeness_centrality.py +0 -274
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality.py +0 -259
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality_subset.py +0 -147
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_closeness.py +0 -43
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_degree_centrality.py +0 -144
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_dispersion.py +0 -73
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py +0 -186
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_group.py +0 -277
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_harmonic_centrality.py +0 -122
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_katz_centrality.py +0 -345
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_laplacian_centrality.py +0 -220
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_load_centrality.py +0 -344
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_percolation_centrality.py +0 -87
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_reaching.py +0 -140
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_second_order_centrality.py +0 -82
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_subgraph.py +0 -110
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_trophic.py +0 -302
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_voterank.py +0 -64
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/test_coloring.py +0 -863
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_asyn_fluid.py +0 -147
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_bipartitions.py +0 -157
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_centrality.py +0 -85
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_divisive.py +0 -106
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_kclique.py +0 -91
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_label_propagation.py +0 -241
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_leiden.py +0 -138
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_local.py +0 -76
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_louvain.py +0 -264
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_lukes.py +0 -152
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_modularity_max.py +0 -340
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_quality.py +0 -139
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_utils.py +0 -26
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_attracting.py +0 -70
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_biconnected.py +0 -248
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_connected.py +0 -138
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_semiconnected.py +0 -55
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_strongly_connected.py +0 -193
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_weakly_connected.py +0 -96
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_connectivity.py +0 -421
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_cuts.py +0 -309
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_disjoint_paths.py +0 -249
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_augmentation.py +0 -502
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_kcomponents.py +0 -488
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcomponents.py +0 -323
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcutsets.py +0 -280
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_stoer_wagner.py +0 -102
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gl1.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gw1.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/netgen-2.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_gomory_hu.py +0 -128
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow.py +0 -573
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow_large_graph.py +0 -155
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_mincost.py +0 -475
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_networksimplex.py +0 -481
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/wlm3.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.A99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.B99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.A99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.B99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_ismags.py +0 -719
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphism.py +0 -103
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py +0 -490
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_match_helpers.py +0 -64
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_temporalisomorphvf2.py +0 -212
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_tree_isomorphism.py +0 -202
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp.py +0 -1655
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp_helpers.py +0 -3118
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py +0 -196
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_hits.py +0 -77
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_pagerank.py +0 -213
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/tests/test_contraction.py +0 -544
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_all.py +0 -328
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_binary.py +0 -451
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_product.py +0 -491
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_unary.py +0 -55
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_astar.py +0 -254
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense.py +0 -212
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense_numpy.py +0 -88
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_generic.py +0 -511
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_unweighted.py +0 -149
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_weighted.py +0 -983
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_asteroidal.py +0 -23
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_boundary.py +0 -154
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_bridges.py +0 -144
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_broadcasting.py +0 -109
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chains.py +0 -136
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chordal.py +0 -129
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_clique.py +0 -300
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cluster.py +0 -678
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_communicability.py +0 -80
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_core.py +0 -266
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_covering.py +0 -85
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cuts.py +0 -171
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cycles.py +0 -984
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_d_separation.py +0 -340
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dag.py +0 -835
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_measures.py +0 -831
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_regular.py +0 -85
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominance.py +0 -299
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominating.py +0 -115
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_efficiency.py +0 -58
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_euler.py +0 -314
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graph_hashing.py +0 -872
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graphical.py +0 -163
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hierarchy.py +0 -46
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hybrid.py +0 -24
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_isolate.py +0 -26
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_link_prediction.py +0 -615
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_lowest_common_ancestors.py +0 -459
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_matching.py +0 -556
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_max_weight_clique.py +0 -179
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_mis.py +0 -62
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_moral.py +0 -15
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_node_classification.py +0 -140
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_non_randomness.py +0 -60
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_perfect_graph.py +0 -27
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planar_drawing.py +0 -274
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planarity.py +0 -556
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_polynomials.py +0 -57
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_reciprocity.py +0 -37
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_regular.py +0 -88
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_richclub.py +0 -149
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_similarity.py +0 -1158
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_simple_paths.py +0 -803
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smallworld.py +0 -76
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smetric.py +0 -8
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_sparsifiers.py +0 -138
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_structuralholes.py +0 -191
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_summarization.py +0 -642
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_swap.py +0 -179
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_threshold.py +0 -270
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_time_dependent.py +0 -431
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_tournament.py +0 -161
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_triads.py +0 -248
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_vitality.py +0 -41
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_voronoi.py +0 -103
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_walks.py +0 -54
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_wiener.py +0 -157
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_beamsearch.py +0 -25
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_bfs.py +0 -203
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_dfs.py +0 -307
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgebfs.py +0 -147
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgedfs.py +0 -131
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_branchings.py +0 -624
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_coding.py +0 -114
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_decomposition.py +0 -79
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_distance_measures.py +0 -99
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_mst.py +0 -934
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_operations.py +0 -53
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_recognition.py +0 -174
- package/runtime/python/okstra_vendor/networkx/classes/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/dispatch_interface.py +0 -192
- package/runtime/python/okstra_vendor/networkx/classes/tests/historical_tests.py +0 -476
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_coreviews.py +0 -362
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph.py +0 -331
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph_historical.py +0 -110
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_filters.py +0 -177
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_function.py +0 -1045
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph.py +0 -950
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph_historical.py +0 -12
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graphviews.py +0 -349
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_multidigraph.py +0 -459
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_multigraph.py +0 -528
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_reportviews.py +0 -1421
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_special.py +0 -131
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_subgraphviews.py +0 -371
- package/runtime/python/okstra_vendor/networkx/conftest.py +0 -261
- package/runtime/python/okstra_vendor/networkx/drawing/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_complex.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_empty_graph.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_house_with_colors.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_labels_and_colors.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_shortest_path.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_house_with_colors.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_agraph.py +0 -237
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_image_comparison_pylab_mpl.py +0 -229
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_latex.py +0 -285
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_layout.py +0 -631
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pydot.py +0 -146
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pylab.py +0 -1582
- package/runtime/python/okstra_vendor/networkx/generators/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_atlas.py +0 -75
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_classic.py +0 -642
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_cographs.py +0 -20
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_community.py +0 -362
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_degree_seq.py +0 -224
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_directed.py +0 -189
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_duplication.py +0 -103
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_ego.py +0 -39
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_expanders.py +0 -182
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_geometric.py +0 -488
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_harary_graph.py +0 -133
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_internet_as_graphs.py +0 -221
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_intersection.py +0 -28
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_interval_graph.py +0 -144
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_joint_degree_seq.py +0 -125
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_lattice.py +0 -264
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_line.py +0 -316
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_mycielski.py +0 -30
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_nonisomorphic_trees.py +0 -82
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_clustered.py +0 -33
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_graphs.py +0 -495
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_small.py +0 -220
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_spectral_graph_forge.py +0 -49
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_stochastic.py +0 -72
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_sudoku.py +0 -92
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_time_series.py +0 -64
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_trees.py +0 -195
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_triads.py +0 -15
- package/runtime/python/okstra_vendor/networkx/linalg/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_algebraic_connectivity.py +0 -400
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_attrmatrix.py +0 -108
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_bethehessian.py +0 -40
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_graphmatrix.py +0 -275
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_laplacian.py +0 -334
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_modularity.py +0 -86
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_spectrum.py +0 -70
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_adjacency.py +0 -78
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_cytoscape.py +0 -78
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_node_link.py +0 -109
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_tree.py +0 -48
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_adjlist.py +0 -354
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_edgelist.py +0 -318
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gexf.py +0 -612
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gml.py +0 -744
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graph6.py +0 -181
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graphml.py +0 -1531
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_leda.py +0 -30
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_p2g.py +0 -63
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_pajek.py +0 -128
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_sparse6.py +0 -166
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_text.py +0 -1742
- package/runtime/python/okstra_vendor/networkx/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_all_random_functions.py +0 -248
- package/runtime/python/okstra_vendor/networkx/tests/test_convert.py +0 -321
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_numpy.py +0 -531
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_pandas.py +0 -349
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_scipy.py +0 -281
- package/runtime/python/okstra_vendor/networkx/tests/test_exceptions.py +0 -40
- package/runtime/python/okstra_vendor/networkx/tests/test_import.py +0 -11
- package/runtime/python/okstra_vendor/networkx/tests/test_lazy_imports.py +0 -96
- package/runtime/python/okstra_vendor/networkx/tests/test_relabel.py +0 -349
- package/runtime/python/okstra_vendor/networkx/tests/test_removed_functions_exception_messages.py +0 -8
- package/runtime/python/okstra_vendor/networkx/utils/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test__init.py +0 -11
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_backends.py +0 -225
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_config.py +0 -263
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_decorators.py +0 -510
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_heaps.py +0 -131
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_mapped_queue.py +0 -268
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_misc.py +0 -393
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_random_sequence.py +0 -53
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_rcm.py +0 -63
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_unionfind.py +0 -55
|
@@ -1,719 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Tests for ISMAGS isomorphism algorithm.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
import random
|
|
6
|
-
|
|
7
|
-
import pytest
|
|
8
|
-
|
|
9
|
-
import networkx as nx
|
|
10
|
-
from networkx.algorithms import isomorphism as iso
|
|
11
|
-
|
|
12
|
-
graph_classes = [nx.Graph, nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def _matches_to_sets(matches):
|
|
16
|
-
"""
|
|
17
|
-
Helper function to facilitate comparing collections of dictionaries in
|
|
18
|
-
which order does not matter.
|
|
19
|
-
"""
|
|
20
|
-
return {frozenset(m.items()) for m in matches}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
graph_examples = [
|
|
24
|
-
# node_data, edge_data, [id used in name for the test]
|
|
25
|
-
pytest.param([0, 1, 2, 3], [(0, 0)], id="isolated-nodes-and-selfloops"),
|
|
26
|
-
pytest.param([], nx.star_graph(3).edges, id="3-star"),
|
|
27
|
-
pytest.param(
|
|
28
|
-
# 6-cycle with 2-paths stuck onto nodes 0, 2, 4 (stretched symmetry)
|
|
29
|
-
[],
|
|
30
|
-
[
|
|
31
|
-
(0, 1),
|
|
32
|
-
(1, 2),
|
|
33
|
-
(2, 3),
|
|
34
|
-
(3, 4),
|
|
35
|
-
(4, 5),
|
|
36
|
-
(5, 0),
|
|
37
|
-
(0, 6),
|
|
38
|
-
(6, 7),
|
|
39
|
-
(2, 8),
|
|
40
|
-
(8, 9),
|
|
41
|
-
(4, 10),
|
|
42
|
-
(10, 11),
|
|
43
|
-
],
|
|
44
|
-
id="sun:6-cycle-with-2-path-rays",
|
|
45
|
-
),
|
|
46
|
-
# 0-1-2-3-5
|
|
47
|
-
# / \
|
|
48
|
-
# 4 6
|
|
49
|
-
pytest.param([], [(0, 1), (1, 2), (1, 4), (2, 3), (3, 5), (3, 6)], id="tree"),
|
|
50
|
-
pytest.param([], nx.petersen_graph().edges, id="petersen_graph"),
|
|
51
|
-
# Example Fig 3 from Houbraken, et al (ISMAGS paper)
|
|
52
|
-
pytest.param(
|
|
53
|
-
[], nx.cycle_graph([1, 2, 4, 3]).edges, id="houbraken-ismags-paper-fig3"
|
|
54
|
-
),
|
|
55
|
-
pytest.param(
|
|
56
|
-
# path with node labels
|
|
57
|
-
[
|
|
58
|
-
(0, {"name": "a"}),
|
|
59
|
-
(1, {"name": "a"}),
|
|
60
|
-
(2, {"name": "b"}),
|
|
61
|
-
(3, {"name": "b"}),
|
|
62
|
-
(4, {"name": "a"}),
|
|
63
|
-
(5, {"name": "a"}),
|
|
64
|
-
],
|
|
65
|
-
[(0, 1), (1, 2), (2, 3), (3, 4), (4, 5)],
|
|
66
|
-
id="path-with-node-labels",
|
|
67
|
-
),
|
|
68
|
-
pytest.param(
|
|
69
|
-
# 5 - 4 \ / 12 - 13
|
|
70
|
-
# 0 - 3
|
|
71
|
-
# 9 - 8 / \ 16 - 17
|
|
72
|
-
# Assume 0 and 3 are coupled and no longer equivalent.
|
|
73
|
-
# Coupling node 4 to 8 means that 5 and 9
|
|
74
|
-
# are no longer equivalent, pushing them in their own partitions.
|
|
75
|
-
# So, [{5}, {9}] is no longer considered equivalent to {13, 17}.
|
|
76
|
-
# Minimal example with this trait. Adding all permutations of
|
|
77
|
-
# same-size parts at each step finds the symmetry.
|
|
78
|
-
[],
|
|
79
|
-
[
|
|
80
|
-
(0, 3),
|
|
81
|
-
(3, 0), # added to provide symmetry for DiGraphs
|
|
82
|
-
(0, 4),
|
|
83
|
-
(4, 5),
|
|
84
|
-
(0, 8),
|
|
85
|
-
(8, 9),
|
|
86
|
-
(3, 12),
|
|
87
|
-
(12, 13),
|
|
88
|
-
(3, 16),
|
|
89
|
-
(16, 17),
|
|
90
|
-
],
|
|
91
|
-
id="gh8055-tricky-case",
|
|
92
|
-
),
|
|
93
|
-
pytest.param(
|
|
94
|
-
[], nx.path_graph([1, 2, 3, "a", "b", "c"]).edges, id="unsortable-nodes"
|
|
95
|
-
),
|
|
96
|
-
# Example from Katebi, 2012, Fig 1-3.
|
|
97
|
-
# Node order specified to (almost) match their DFS order
|
|
98
|
-
pytest.param(
|
|
99
|
-
[3, 5, 6, 4, 2, 1, 0],
|
|
100
|
-
set(nx.cycle_graph(4).edges) | set(nx.cycle_graph(range(4, 7)).edges),
|
|
101
|
-
id="katebi-paper-fig2",
|
|
102
|
-
),
|
|
103
|
-
pytest.param(
|
|
104
|
-
[], [(0, 1), (1, 2), (2, 3), (3, 6), (2, 4), (4, 5)], id="len-2-rays-tri-star"
|
|
105
|
-
),
|
|
106
|
-
# Example of refining permutations with two different length parts at the same time.
|
|
107
|
-
# Underlying shape is a 4-cycle and 2-path. Multiedges make all nodes degree-3
|
|
108
|
-
# Full simple graph is then obtained by extending each edge as a path thru 1 node.
|
|
109
|
-
# 0
|
|
110
|
-
# Underlying // \ 4 When 0->0 coupling occurs,
|
|
111
|
-
# MultiGraph 1 3 \\\ refining {1, 2, 3, 4, 5}
|
|
112
|
-
# \ // 5 refined parts [{1}, {3}, {2, 4, 5}]
|
|
113
|
-
# 2 with different parts having different lengths.
|
|
114
|
-
# 0
|
|
115
|
-
# /|\ 4
|
|
116
|
-
# 6 7 8 /|\
|
|
117
|
-
# Full: |/ | / | \
|
|
118
|
-
# 1 3 12 13 14
|
|
119
|
-
# | / \ \ | /
|
|
120
|
-
# 9 10 11 \|/
|
|
121
|
-
# \ | / 5
|
|
122
|
-
# 2
|
|
123
|
-
# Nodes 0-5 are the degree-3 nodes.
|
|
124
|
-
# Nodes 6-14 are degree 2 nodes on paths between the degree-3 nodes.
|
|
125
|
-
pytest.param(
|
|
126
|
-
[],
|
|
127
|
-
[
|
|
128
|
-
(0, 6),
|
|
129
|
-
(0, 7),
|
|
130
|
-
(0, 8),
|
|
131
|
-
(1, 6),
|
|
132
|
-
(1, 7),
|
|
133
|
-
(1, 9),
|
|
134
|
-
(2, 9),
|
|
135
|
-
(2, 10),
|
|
136
|
-
(2, 11),
|
|
137
|
-
(3, 8),
|
|
138
|
-
(3, 10),
|
|
139
|
-
(3, 11),
|
|
140
|
-
(4, 12),
|
|
141
|
-
(4, 13),
|
|
142
|
-
(4, 14),
|
|
143
|
-
(5, 12),
|
|
144
|
-
(5, 13),
|
|
145
|
-
(5, 14),
|
|
146
|
-
],
|
|
147
|
-
id="refining-parts-finds-different-lengths",
|
|
148
|
-
),
|
|
149
|
-
# Underlying structure from previous example
|
|
150
|
-
pytest.param(
|
|
151
|
-
[],
|
|
152
|
-
[(0, 1), (0, 1), (1, 2), (2, 3), (2, 3), (3, 0), (4, 5), (4, 5), (4, 5)],
|
|
153
|
-
id="basic-structure-for-refining-parts-test",
|
|
154
|
-
),
|
|
155
|
-
]
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
@pytest.mark.parametrize("graph_constructor", graph_classes)
|
|
159
|
-
class TestSelfIsomorphism:
|
|
160
|
-
@pytest.mark.parametrize(["node_data", "edge_data"], graph_examples)
|
|
161
|
-
def test_self_isomorphism(self, graph_constructor, node_data, edge_data):
|
|
162
|
-
"""
|
|
163
|
-
For some small, symmetric graphs, make sure that 1) they are isomorphic
|
|
164
|
-
to themselves, and 2) that only the identity mapping is found.
|
|
165
|
-
"""
|
|
166
|
-
graph = graph_constructor()
|
|
167
|
-
graph.add_nodes_from(node_data)
|
|
168
|
-
graph.add_edges_from(edge_data)
|
|
169
|
-
|
|
170
|
-
ismags = iso.ISMAGS(
|
|
171
|
-
graph, graph, node_match=iso.categorical_node_match("name", None)
|
|
172
|
-
)
|
|
173
|
-
assert ismags.is_isomorphic()
|
|
174
|
-
assert ismags.is_isomorphic(symmetry=True)
|
|
175
|
-
assert ismags.subgraph_is_isomorphic()
|
|
176
|
-
ismags_answer = list(ismags.subgraph_isomorphisms_iter(symmetry=True))
|
|
177
|
-
assert ismags_answer == [{n: n for n in graph.nodes}]
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
class TestSubgraphIsomorphism:
|
|
181
|
-
def test_isomorphism_4_sun(self):
|
|
182
|
-
g1 = nx.cycle_graph(4)
|
|
183
|
-
g2 = nx.cycle_graph(4)
|
|
184
|
-
g2.add_edges_from(list(zip(g2, range(4, 8))))
|
|
185
|
-
ismags = iso.ISMAGS(g2, g1)
|
|
186
|
-
assert list(ismags.subgraph_isomorphisms_iter(symmetry=True)) == [
|
|
187
|
-
{n: n for n in g1.nodes}
|
|
188
|
-
]
|
|
189
|
-
assert sum(1 for _ in ismags.subgraph_isomorphisms_iter(symmetry=False)) == 8
|
|
190
|
-
|
|
191
|
-
def test_isomorphism_path_in_tristar(self):
|
|
192
|
-
g1 = nx.path_graph(3)
|
|
193
|
-
|
|
194
|
-
g2 = g1.copy()
|
|
195
|
-
g2.add_edge(1, 3)
|
|
196
|
-
|
|
197
|
-
ismags = iso.ISMAGS(g2, g1)
|
|
198
|
-
matches = ismags.subgraph_isomorphisms_iter(symmetry=True)
|
|
199
|
-
expected_symmetric = [
|
|
200
|
-
{0: 0, 1: 1, 2: 2},
|
|
201
|
-
{0: 0, 1: 1, 3: 2},
|
|
202
|
-
{2: 0, 1: 1, 3: 2},
|
|
203
|
-
]
|
|
204
|
-
assert _matches_to_sets(matches) == _matches_to_sets(expected_symmetric)
|
|
205
|
-
|
|
206
|
-
matches = ismags.subgraph_isomorphisms_iter(symmetry=False)
|
|
207
|
-
expected_asymmetric = [
|
|
208
|
-
{0: 2, 1: 1, 2: 0},
|
|
209
|
-
{0: 2, 1: 1, 3: 0},
|
|
210
|
-
{2: 2, 1: 1, 3: 0},
|
|
211
|
-
]
|
|
212
|
-
assert _matches_to_sets(matches) == _matches_to_sets(
|
|
213
|
-
expected_symmetric + expected_asymmetric
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
def test_labeled_nodes(self):
|
|
217
|
-
g1 = nx.cycle_graph(3)
|
|
218
|
-
g1.nodes[1]["attr"] = True
|
|
219
|
-
|
|
220
|
-
g2 = g1.copy()
|
|
221
|
-
g2.add_edge(1, 3)
|
|
222
|
-
ismags = iso.ISMAGS(g2, g1, node_match=lambda x, y: x == y)
|
|
223
|
-
matches = ismags.subgraph_isomorphisms_iter(symmetry=True)
|
|
224
|
-
expected_symmetric = [{0: 0, 1: 1, 2: 2}]
|
|
225
|
-
assert _matches_to_sets(matches) == _matches_to_sets(expected_symmetric)
|
|
226
|
-
|
|
227
|
-
matches = ismags.subgraph_isomorphisms_iter(symmetry=False)
|
|
228
|
-
expected_asymmetric = [{0: 2, 1: 1, 2: 0}]
|
|
229
|
-
assert _matches_to_sets(matches) == _matches_to_sets(
|
|
230
|
-
expected_symmetric + expected_asymmetric
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
def test_labeled_edges(self):
|
|
234
|
-
g1 = nx.Graph()
|
|
235
|
-
nx.add_cycle(g1, range(3))
|
|
236
|
-
g1.edges[1, 2]["attr"] = True
|
|
237
|
-
|
|
238
|
-
g2 = g1.copy()
|
|
239
|
-
g2.add_edge(1, 3)
|
|
240
|
-
ismags = iso.ISMAGS(g2, g1, edge_match=lambda x, y: x == y)
|
|
241
|
-
matches = ismags.subgraph_isomorphisms_iter(symmetry=True)
|
|
242
|
-
expected_symmetric = [{0: 0, 1: 1, 2: 2}]
|
|
243
|
-
assert _matches_to_sets(matches) == _matches_to_sets(expected_symmetric)
|
|
244
|
-
|
|
245
|
-
matches = ismags.subgraph_isomorphisms_iter(symmetry=False)
|
|
246
|
-
expected_asymmetric = [{1: 2, 0: 0, 2: 1}]
|
|
247
|
-
assert _matches_to_sets(matches) == _matches_to_sets(
|
|
248
|
-
expected_symmetric + expected_asymmetric
|
|
249
|
-
)
|
|
250
|
-
|
|
251
|
-
def test_exceptions_for_bad_match_functions(self):
|
|
252
|
-
def non_transitive_match(attrs1, attrs2):
|
|
253
|
-
return abs(attrs1["freq"] - attrs2["freq"]) <= 1
|
|
254
|
-
|
|
255
|
-
def simple_non_commutative_match(attrs1, attrs2):
|
|
256
|
-
return attrs1["freq"] == 1 + attrs2["freq"]
|
|
257
|
-
|
|
258
|
-
def non_commutative_match(attrs1, attrs2):
|
|
259
|
-
# red matches red and green
|
|
260
|
-
# green and blue only match themselves
|
|
261
|
-
if attrs2["color"] == "red":
|
|
262
|
-
return attrs2["color"] in {"red", "green"}
|
|
263
|
-
else:
|
|
264
|
-
return attrs1["color"] == attrs2["color"]
|
|
265
|
-
|
|
266
|
-
G1 = nx.Graph()
|
|
267
|
-
G1.add_node(0, color="red", freq=0)
|
|
268
|
-
G1.add_node(1, color="red", freq=1)
|
|
269
|
-
G1.add_node(2, color="blue", freq=2)
|
|
270
|
-
|
|
271
|
-
G2 = nx.Graph()
|
|
272
|
-
G2.add_node("A", color="red", freq=0)
|
|
273
|
-
G2.add_node("B", color="green", freq=1)
|
|
274
|
-
G2.add_node("C", color="blue", freq=2)
|
|
275
|
-
|
|
276
|
-
with pytest.raises(nx.NetworkXError, match="\nInvalid partition"):
|
|
277
|
-
iso.ISMAGS(G1, G2, node_match=non_transitive_match)
|
|
278
|
-
|
|
279
|
-
with pytest.raises(nx.NetworkXError, match="\nInvalid partition"):
|
|
280
|
-
iso.ISMAGS(G1, G2, node_match=simple_non_commutative_match)
|
|
281
|
-
|
|
282
|
-
with pytest.raises(nx.NetworkXError, match="\nInvalid partition"):
|
|
283
|
-
iso.ISMAGS(G1, G2, node_match=non_commutative_match)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
def test_noncomparable_nodes():
|
|
287
|
-
node1 = object()
|
|
288
|
-
node2 = object()
|
|
289
|
-
node3 = object()
|
|
290
|
-
|
|
291
|
-
# Graph
|
|
292
|
-
G = nx.path_graph([node1, node2, node3])
|
|
293
|
-
gm = iso.ISMAGS(G, G)
|
|
294
|
-
assert gm.is_isomorphic()
|
|
295
|
-
assert gm.subgraph_is_isomorphic()
|
|
296
|
-
|
|
297
|
-
# DiGraph
|
|
298
|
-
G = nx.path_graph([node1, node2, node3], create_using=nx.DiGraph)
|
|
299
|
-
H = nx.path_graph([node3, node2, node1], create_using=nx.DiGraph)
|
|
300
|
-
dgm = iso.ISMAGS(G, H)
|
|
301
|
-
assert dgm.is_isomorphic()
|
|
302
|
-
assert dgm.is_isomorphic(symmetry=True)
|
|
303
|
-
assert dgm.subgraph_is_isomorphic()
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
@pytest.mark.parametrize("graph_constructor", graph_classes)
|
|
307
|
-
def test_selfloop(graph_constructor):
|
|
308
|
-
# Simple test for graphs with selfloops
|
|
309
|
-
g1 = graph_constructor([(0, 1), (0, 2), (1, 2), (1, 3), (2, 2), (2, 4)])
|
|
310
|
-
nodes = range(5)
|
|
311
|
-
rng = random.Random(42)
|
|
312
|
-
|
|
313
|
-
for _ in range(3):
|
|
314
|
-
new_nodes = list(nodes)
|
|
315
|
-
rng.shuffle(new_nodes)
|
|
316
|
-
d = dict(zip(nodes, new_nodes))
|
|
317
|
-
g2 = nx.relabel_nodes(g1, d)
|
|
318
|
-
assert iso.ISMAGS(g1, g2).is_isomorphic()
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
class TestWikipediaExample:
|
|
322
|
-
# example in wikipedia is g1a and g2b
|
|
323
|
-
# 1 have letter nodes, 2 have number nodes
|
|
324
|
-
# b have some edges reversed vs a (undirected still isomorphic)
|
|
325
|
-
# reversed edges marked with comment `#`
|
|
326
|
-
# isomorphism = {'a': 1, 'g': 2, 'b': 3, 'c': 6, 'h': 4, 'i': 5, 'j': 7, 'd': 8}
|
|
327
|
-
|
|
328
|
-
# Nodes 'a', 'b', 'c' and 'd' form a column.
|
|
329
|
-
# Nodes 'g', 'h', 'i' and 'j' form a column.
|
|
330
|
-
g1a_edges = [
|
|
331
|
-
["a", "g"],
|
|
332
|
-
["a", "h"], # edge direction swapped from g1b
|
|
333
|
-
["a", "i"],
|
|
334
|
-
["b", "g"], # edge direction swapped from g1b
|
|
335
|
-
["b", "h"],
|
|
336
|
-
["b", "j"],
|
|
337
|
-
["c", "g"], # edge direction swapped from g1b
|
|
338
|
-
["c", "i"], # edge direction swapped from g1b
|
|
339
|
-
["c", "j"],
|
|
340
|
-
["d", "h"], # edge direction swapped from g1b
|
|
341
|
-
["d", "i"],
|
|
342
|
-
["d", "j"], # edge direction swapped from g1b
|
|
343
|
-
]
|
|
344
|
-
|
|
345
|
-
g1b_edges = [
|
|
346
|
-
["a", "g"],
|
|
347
|
-
["h", "a"], # edge direction swapped from g1a
|
|
348
|
-
["a", "i"],
|
|
349
|
-
["g", "b"], # edge direction swapped from g1a
|
|
350
|
-
["b", "h"],
|
|
351
|
-
["b", "j"],
|
|
352
|
-
["g", "c"], # edge direction swapped from g1a
|
|
353
|
-
["i", "c"], # edge direction swapped from g1a
|
|
354
|
-
["c", "j"],
|
|
355
|
-
["h", "d"], # edge direction swapped from g1a
|
|
356
|
-
["d", "i"],
|
|
357
|
-
["j", "d"], # edge direction swapped from g1a
|
|
358
|
-
]
|
|
359
|
-
|
|
360
|
-
g2b_edges = [
|
|
361
|
-
[1, 2],
|
|
362
|
-
[1, 4], # edge direction swapped from g2a
|
|
363
|
-
[1, 5],
|
|
364
|
-
[3, 2], # edge direction swapped from g2a
|
|
365
|
-
[3, 4],
|
|
366
|
-
[3, 7],
|
|
367
|
-
[6, 2], # edge direction swapped from g2a
|
|
368
|
-
[6, 5], # edge direction swapped from g2a
|
|
369
|
-
[6, 7],
|
|
370
|
-
[8, 4], # edge direction swapped from g2a
|
|
371
|
-
[8, 5],
|
|
372
|
-
[8, 7], # edge direction swapped from g2a
|
|
373
|
-
]
|
|
374
|
-
|
|
375
|
-
# Nodes 1,2,3,4 form the clockwise corners of a large square.
|
|
376
|
-
# Nodes 5,6,7,8 form the clockwise corners of a small square
|
|
377
|
-
g2a_edges = [
|
|
378
|
-
[1, 2],
|
|
379
|
-
[4, 1], # edge direction swapped from g2b
|
|
380
|
-
[1, 5],
|
|
381
|
-
[2, 3], # edge direction swapped from g2b
|
|
382
|
-
[3, 4],
|
|
383
|
-
[3, 7],
|
|
384
|
-
[2, 6], # edge direction swapped from g2b
|
|
385
|
-
[5, 6], # edge direction swapped from g2b
|
|
386
|
-
[6, 7],
|
|
387
|
-
[4, 8], # edge direction swapped from g2b
|
|
388
|
-
[8, 5],
|
|
389
|
-
[7, 8], # edge direction swapped from g2b
|
|
390
|
-
]
|
|
391
|
-
|
|
392
|
-
@pytest.mark.parametrize("graph_constructor", [nx.Graph, nx.MultiGraph])
|
|
393
|
-
def test_graph(self, graph_constructor):
|
|
394
|
-
g1a = graph_constructor(self.g1a_edges)
|
|
395
|
-
g1b = graph_constructor(self.g1b_edges)
|
|
396
|
-
g2a = graph_constructor(self.g2a_edges)
|
|
397
|
-
g2b = graph_constructor(self.g2b_edges)
|
|
398
|
-
assert iso.ISMAGS(g1a, g1b).is_isomorphic()
|
|
399
|
-
assert iso.ISMAGS(g1a, g2a).is_isomorphic()
|
|
400
|
-
assert iso.ISMAGS(g1a, g2b).is_isomorphic()
|
|
401
|
-
|
|
402
|
-
assert iso.ISMAGS(g1a, nx.path_graph(range(5))).subgraph_is_isomorphic()
|
|
403
|
-
assert not iso.ISMAGS(g1a, nx.path_graph(range(6))).subgraph_is_isomorphic()
|
|
404
|
-
|
|
405
|
-
@pytest.mark.parametrize("graph_constructor", [nx.DiGraph, nx.MultiDiGraph])
|
|
406
|
-
def test_digraph(self, graph_constructor):
|
|
407
|
-
g1a = graph_constructor(self.g1a_edges)
|
|
408
|
-
g1b = graph_constructor(self.g1b_edges)
|
|
409
|
-
g2a = graph_constructor(self.g2a_edges)
|
|
410
|
-
g2b = graph_constructor(self.g2b_edges)
|
|
411
|
-
assert iso.ISMAGS(g1a, g2b).is_isomorphic()
|
|
412
|
-
assert iso.ISMAGS(g1b, g2a).is_isomorphic()
|
|
413
|
-
assert not iso.ISMAGS(g1a, g1b).is_isomorphic()
|
|
414
|
-
assert not iso.ISMAGS(g2a, g2b).is_isomorphic()
|
|
415
|
-
assert not iso.ISMAGS(g1a, g2a).is_isomorphic()
|
|
416
|
-
assert not iso.ISMAGS(g1b, g2b).is_isomorphic()
|
|
417
|
-
|
|
418
|
-
P2 = nx.path_graph(range(2), create_using=graph_constructor)
|
|
419
|
-
assert iso.ISMAGS(g1a, P2).subgraph_is_isomorphic()
|
|
420
|
-
P3 = nx.path_graph(range(3), create_using=graph_constructor)
|
|
421
|
-
assert not iso.ISMAGS(g1a, P3).subgraph_is_isomorphic()
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
class TestLargestCommonSubgraph:
|
|
425
|
-
def test_mcis(self):
|
|
426
|
-
# Example graphs from DOI: 10.1002/spe.588
|
|
427
|
-
graph1 = nx.Graph()
|
|
428
|
-
graph1.add_edges_from([(1, 2), (2, 3), (2, 4), (3, 4), (4, 5)])
|
|
429
|
-
graph1.nodes[1]["color"] = 0
|
|
430
|
-
|
|
431
|
-
graph2 = nx.Graph()
|
|
432
|
-
graph2.add_edges_from(
|
|
433
|
-
[(1, 2), (2, 3), (2, 4), (3, 4), (3, 5), (5, 6), (5, 7), (6, 7)]
|
|
434
|
-
)
|
|
435
|
-
graph2.nodes[1]["color"] = 1
|
|
436
|
-
graph2.nodes[6]["color"] = 2
|
|
437
|
-
graph2.nodes[7]["color"] = 2
|
|
438
|
-
|
|
439
|
-
ismags = iso.ISMAGS(
|
|
440
|
-
graph1, graph2, node_match=iso.categorical_node_match("color", None)
|
|
441
|
-
)
|
|
442
|
-
assert list(ismags.subgraph_isomorphisms_iter(symmetry=True)) == []
|
|
443
|
-
assert list(ismags.subgraph_isomorphisms_iter(symmetry=False)) == []
|
|
444
|
-
found_mcis = _matches_to_sets(ismags.largest_common_subgraph())
|
|
445
|
-
expected = _matches_to_sets(
|
|
446
|
-
[{2: 2, 3: 4, 4: 3, 5: 5}, {2: 4, 3: 2, 4: 3, 5: 5}]
|
|
447
|
-
)
|
|
448
|
-
assert expected == found_mcis
|
|
449
|
-
|
|
450
|
-
ismags = iso.ISMAGS(
|
|
451
|
-
graph2, graph1, node_match=iso.categorical_node_match("color", None)
|
|
452
|
-
)
|
|
453
|
-
assert list(ismags.subgraph_isomorphisms_iter(symmetry=True)) == []
|
|
454
|
-
assert list(ismags.subgraph_isomorphisms_iter(symmetry=False)) == []
|
|
455
|
-
found_mcis = _matches_to_sets(ismags.largest_common_subgraph())
|
|
456
|
-
# Same answer, but reversed.
|
|
457
|
-
expected = _matches_to_sets(
|
|
458
|
-
[{2: 2, 3: 4, 4: 3, 5: 5}, {4: 2, 2: 3, 3: 4, 5: 5}]
|
|
459
|
-
)
|
|
460
|
-
assert expected == found_mcis
|
|
461
|
-
|
|
462
|
-
def test_symmetry_mcis(self):
|
|
463
|
-
graph1 = nx.Graph()
|
|
464
|
-
nx.add_path(graph1, range(4))
|
|
465
|
-
|
|
466
|
-
graph2 = nx.Graph()
|
|
467
|
-
nx.add_path(graph2, range(3))
|
|
468
|
-
graph2.add_edge(1, 3)
|
|
469
|
-
|
|
470
|
-
# Only the symmetry of graph2 is taken into account here.
|
|
471
|
-
ismags1 = iso.ISMAGS(
|
|
472
|
-
graph1, graph2, node_match=iso.categorical_node_match("color", None)
|
|
473
|
-
)
|
|
474
|
-
assert list(ismags1.subgraph_isomorphisms_iter(symmetry=True)) == []
|
|
475
|
-
found_mcis = _matches_to_sets(ismags1.largest_common_subgraph())
|
|
476
|
-
expected = _matches_to_sets([{0: 0, 1: 1, 2: 2}, {1: 0, 3: 2, 2: 1}])
|
|
477
|
-
assert expected == found_mcis
|
|
478
|
-
|
|
479
|
-
# Only the symmetry of graph1 is taken into account here.
|
|
480
|
-
ismags2 = iso.ISMAGS(
|
|
481
|
-
graph2, graph1, node_match=iso.categorical_node_match("color", None)
|
|
482
|
-
)
|
|
483
|
-
assert list(ismags2.subgraph_isomorphisms_iter(symmetry=True)) == []
|
|
484
|
-
found_mcis = _matches_to_sets(ismags2.largest_common_subgraph())
|
|
485
|
-
expected = _matches_to_sets(
|
|
486
|
-
[
|
|
487
|
-
{3: 2, 0: 0, 1: 1},
|
|
488
|
-
{2: 0, 0: 2, 1: 1},
|
|
489
|
-
{3: 0, 0: 2, 1: 1},
|
|
490
|
-
{3: 0, 1: 1, 2: 2},
|
|
491
|
-
{0: 0, 1: 1, 2: 2},
|
|
492
|
-
{2: 0, 3: 2, 1: 1},
|
|
493
|
-
]
|
|
494
|
-
)
|
|
495
|
-
|
|
496
|
-
assert expected == found_mcis
|
|
497
|
-
|
|
498
|
-
found_mcis1 = _matches_to_sets(ismags1.largest_common_subgraph(symmetry=False))
|
|
499
|
-
found_mcis2 = ismags2.largest_common_subgraph(symmetry=False)
|
|
500
|
-
found_mcis2 = [{v: k for k, v in d.items()} for d in found_mcis2]
|
|
501
|
-
found_mcis2 = _matches_to_sets(found_mcis2)
|
|
502
|
-
|
|
503
|
-
expected = _matches_to_sets(
|
|
504
|
-
[
|
|
505
|
-
{3: 2, 1: 3, 2: 1},
|
|
506
|
-
{2: 0, 0: 2, 1: 1},
|
|
507
|
-
{1: 2, 3: 3, 2: 1},
|
|
508
|
-
{3: 0, 1: 3, 2: 1},
|
|
509
|
-
{0: 2, 2: 3, 1: 1},
|
|
510
|
-
{3: 0, 1: 2, 2: 1},
|
|
511
|
-
{2: 0, 0: 3, 1: 1},
|
|
512
|
-
{0: 0, 2: 3, 1: 1},
|
|
513
|
-
{1: 0, 3: 3, 2: 1},
|
|
514
|
-
{1: 0, 3: 2, 2: 1},
|
|
515
|
-
{0: 3, 1: 1, 2: 2},
|
|
516
|
-
{0: 0, 1: 1, 2: 2},
|
|
517
|
-
]
|
|
518
|
-
)
|
|
519
|
-
assert expected == found_mcis1
|
|
520
|
-
assert expected == found_mcis2
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
def is_isomorphic(G, SG, edge_match=None, node_match=None):
|
|
524
|
-
return iso.ISMAGS(G, SG, node_match, edge_match).is_isomorphic()
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
class TestDiGraphISO:
|
|
528
|
-
def test_wikipedia_graph(self):
|
|
529
|
-
edges1 = [
|
|
530
|
-
(1, 5),
|
|
531
|
-
(1, 2),
|
|
532
|
-
(1, 4),
|
|
533
|
-
(3, 2),
|
|
534
|
-
(6, 2),
|
|
535
|
-
(3, 4),
|
|
536
|
-
(7, 3),
|
|
537
|
-
(4, 8),
|
|
538
|
-
(5, 8),
|
|
539
|
-
(6, 5),
|
|
540
|
-
(6, 7),
|
|
541
|
-
(7, 8),
|
|
542
|
-
]
|
|
543
|
-
mapped = {1: "a", 2: "h", 3: "d", 4: "i", 5: "g", 6: "b", 7: "j", 8: "c"}
|
|
544
|
-
|
|
545
|
-
G1 = nx.DiGraph(edges1)
|
|
546
|
-
G2 = nx.relabel_nodes(G1, mapped)
|
|
547
|
-
|
|
548
|
-
result = next(nx.isomorphism.ISMAGS(G1, G2).find_isomorphisms())
|
|
549
|
-
assert result == mapped
|
|
550
|
-
|
|
551
|
-
# Change the direction of an edge
|
|
552
|
-
G1.remove_edge(1, 5)
|
|
553
|
-
G1.add_edge(5, 1)
|
|
554
|
-
result = list(nx.isomorphism.ISMAGS(G1, G2).find_isomorphisms())
|
|
555
|
-
assert result == []
|
|
556
|
-
|
|
557
|
-
def test_non_isomorphic_same_degree_sequence(self):
|
|
558
|
-
r"""
|
|
559
|
-
G1 G2
|
|
560
|
-
1-------------2 1-------------2
|
|
561
|
-
| \ | | \ |
|
|
562
|
-
| 5-------6 | | 5-------6 |
|
|
563
|
-
| | | | | | | |
|
|
564
|
-
| 8-------7 | | 8-------7 |
|
|
565
|
-
| / | | \ |
|
|
566
|
-
4-------------3 4-------------3
|
|
567
|
-
"""
|
|
568
|
-
edges1 = [
|
|
569
|
-
(1, 5),
|
|
570
|
-
(1, 2),
|
|
571
|
-
(4, 1),
|
|
572
|
-
(3, 2),
|
|
573
|
-
(3, 4),
|
|
574
|
-
(5, 8),
|
|
575
|
-
(6, 5),
|
|
576
|
-
(6, 7),
|
|
577
|
-
(7, 8),
|
|
578
|
-
(4, 8),
|
|
579
|
-
]
|
|
580
|
-
edges2 = [
|
|
581
|
-
(1, 5),
|
|
582
|
-
(1, 2),
|
|
583
|
-
(4, 1),
|
|
584
|
-
(3, 2),
|
|
585
|
-
(3, 4),
|
|
586
|
-
(5, 8),
|
|
587
|
-
(6, 5),
|
|
588
|
-
(6, 7),
|
|
589
|
-
(8, 7),
|
|
590
|
-
(3, 7),
|
|
591
|
-
]
|
|
592
|
-
|
|
593
|
-
G1 = nx.DiGraph(edges1)
|
|
594
|
-
G2 = nx.DiGraph(edges2)
|
|
595
|
-
assert not is_isomorphic(G1, G2)
|
|
596
|
-
|
|
597
|
-
def test_is_isomorphic(self):
|
|
598
|
-
G1 = nx.Graph([[1, 2], [1, 3], [1, 5], [2, 3]])
|
|
599
|
-
G2 = nx.Graph([[10, 20], [20, 30], [10, 30], [10, 50]])
|
|
600
|
-
G4 = nx.Graph([[1, 2], [1, 3], [1, 5], [2, 4]])
|
|
601
|
-
assert is_isomorphic(G1, G2)
|
|
602
|
-
assert not is_isomorphic(G1, G4)
|
|
603
|
-
assert is_isomorphic(G1.to_directed(), G2.to_directed())
|
|
604
|
-
assert not is_isomorphic(G1.to_directed(), G4.to_directed())
|
|
605
|
-
with pytest.raises(
|
|
606
|
-
ValueError, match="Directed and undirected graphs cannot be compared."
|
|
607
|
-
):
|
|
608
|
-
is_isomorphic(G1.to_directed(), G1)
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
@pytest.mark.parametrize("graph_class", graph_classes)
|
|
612
|
-
def test_simple_node_match(graph_class):
|
|
613
|
-
g1 = graph_class([(0, 0), (0, 1), (1, 0)])
|
|
614
|
-
g2 = g1.copy()
|
|
615
|
-
nm = iso.numerical_node_match("size", 1)
|
|
616
|
-
assert is_isomorphic(g1, g2, node_match=nm)
|
|
617
|
-
|
|
618
|
-
g2.nodes[0]["size"] = 3
|
|
619
|
-
assert not is_isomorphic(g1, g2, node_match=nm)
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
@pytest.mark.parametrize("graph_class", graph_classes)
|
|
623
|
-
def test_simple_node_and_edge_match(graph_class):
|
|
624
|
-
g1 = graph_class()
|
|
625
|
-
g1.add_weighted_edges_from([(0, 0, 1.2), (0, 1, 1.4), (1, 0, 1.6)])
|
|
626
|
-
g2 = g1.copy()
|
|
627
|
-
nm = iso.numerical_node_match("size", 1)
|
|
628
|
-
if g1.is_multigraph():
|
|
629
|
-
em = iso.numerical_multiedge_match("weight", 1)
|
|
630
|
-
else:
|
|
631
|
-
em = iso.numerical_edge_match("weight", 1)
|
|
632
|
-
assert is_isomorphic(g1, g2, node_match=nm, edge_match=em)
|
|
633
|
-
|
|
634
|
-
g2.nodes[0]["size"] = 3
|
|
635
|
-
assert not is_isomorphic(g1, g2, node_match=nm, edge_match=em)
|
|
636
|
-
|
|
637
|
-
g2 = g1.copy()
|
|
638
|
-
if g1.is_multigraph():
|
|
639
|
-
g2.edges[0, 1, 0]["weight"] = 2.1
|
|
640
|
-
else:
|
|
641
|
-
g2.edges[0, 1]["weight"] = 2.1
|
|
642
|
-
assert not is_isomorphic(g1, g2, node_match=nm, edge_match=em)
|
|
643
|
-
|
|
644
|
-
g2 = g1.copy()
|
|
645
|
-
g2.nodes[0]["size"] = 3
|
|
646
|
-
if g1.is_multigraph():
|
|
647
|
-
g2.edges[0, 1, 0]["weight"] = 2.1
|
|
648
|
-
else:
|
|
649
|
-
g2.edges[0, 1]["weight"] = 2.1
|
|
650
|
-
assert not is_isomorphic(g1, g2, node_match=nm, edge_match=em)
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
@pytest.mark.parametrize("graph_class", graph_classes)
|
|
654
|
-
def test_simple_edge_match(graph_class):
|
|
655
|
-
# 16 simple tests
|
|
656
|
-
w = "weight"
|
|
657
|
-
edges = [(0, 0, 1), (0, 0, 1.5), (0, 1, 2), (1, 0, 3)]
|
|
658
|
-
g1 = graph_class()
|
|
659
|
-
g1.add_weighted_edges_from(edges)
|
|
660
|
-
g2 = g1.copy()
|
|
661
|
-
if g1.is_multigraph():
|
|
662
|
-
em = iso.numerical_multiedge_match("weight", 1)
|
|
663
|
-
else:
|
|
664
|
-
em = iso.numerical_edge_match("weight", 1)
|
|
665
|
-
assert is_isomorphic(g1, g2, edge_match=em)
|
|
666
|
-
|
|
667
|
-
for mod1, mod2 in [(False, True), (True, False), (True, True)]:
|
|
668
|
-
# mod1 tests a regular edge weight difference
|
|
669
|
-
# mod2 tests a selfloop weight difference
|
|
670
|
-
if g1.is_multigraph():
|
|
671
|
-
if mod1:
|
|
672
|
-
data1 = {0: {"weight": 10}}
|
|
673
|
-
if mod2:
|
|
674
|
-
data2 = {0: {"weight": 1}, 1: {"weight": 2.5}}
|
|
675
|
-
else:
|
|
676
|
-
if mod1:
|
|
677
|
-
data1 = {"weight": 10}
|
|
678
|
-
if mod2:
|
|
679
|
-
data2 = {"weight": 2.5}
|
|
680
|
-
|
|
681
|
-
g2 = g1.copy()
|
|
682
|
-
if mod1:
|
|
683
|
-
if not g1.is_directed():
|
|
684
|
-
g2._adj[1][0] = data1
|
|
685
|
-
g2._adj[0][1] = data1
|
|
686
|
-
else:
|
|
687
|
-
g2._succ[1][0] = data1
|
|
688
|
-
g2._pred[0][1] = data1
|
|
689
|
-
if mod2:
|
|
690
|
-
if not g1.is_directed():
|
|
691
|
-
g2._adj[0][0] = data2
|
|
692
|
-
else:
|
|
693
|
-
g2._succ[0][0] = data2
|
|
694
|
-
g2._pred[0][0] = data2
|
|
695
|
-
|
|
696
|
-
assert not is_isomorphic(g1, g2, edge_match=em)
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
@pytest.mark.parametrize("graph_class", graph_classes)
|
|
700
|
-
def test_weightkey(graph_class):
|
|
701
|
-
g1 = graph_class()
|
|
702
|
-
g2 = graph_class()
|
|
703
|
-
if g1.is_multigraph():
|
|
704
|
-
edge_match = iso.numerical_multiedge_match
|
|
705
|
-
else:
|
|
706
|
-
edge_match = iso.numerical_edge_match
|
|
707
|
-
|
|
708
|
-
g1.add_edge("A", "B", weight=1)
|
|
709
|
-
g2.add_edge("C", "D", weight=0)
|
|
710
|
-
|
|
711
|
-
assert nx.is_isomorphic(g1, g2)
|
|
712
|
-
em = edge_match("nonexistent attribute", 1)
|
|
713
|
-
assert nx.is_isomorphic(g1, g2, edge_match=em)
|
|
714
|
-
em = edge_match("weight", 1)
|
|
715
|
-
assert not nx.is_isomorphic(g1, g2, edge_match=em)
|
|
716
|
-
|
|
717
|
-
g2 = graph_class()
|
|
718
|
-
g2.add_edge("C", "D")
|
|
719
|
-
assert nx.is_isomorphic(g1, g2, edge_match=em)
|