okstra 0.113.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/README.kr.md +2 -2
- package/README.md +2 -2
- package/docs/for-ai/README.md +2 -2
- package/docs/for-ai/skills/{okstra-brief.md → okstra-brief-gen.md} +3 -3
- package/docs/for-ai/skills/okstra-inspect.md +1 -1
- package/docs/kr/architecture.md +11 -11
- package/docs/kr/cli.md +1 -1
- package/docs/kr/follow-ups/2026-07-10-final-report-option-3.md +51 -0
- package/docs/project-structure-overview.md +2 -2
- 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/context-loader.md +2 -2
- package/runtime/prompts/lead/okstra-lead-contract.md +1 -1
- package/runtime/prompts/profiles/_common-contract.md +3 -3
- package/runtime/prompts/profiles/implementation-planning.md +1 -1
- package/runtime/prompts/profiles/requirements-discovery.md +2 -2
- package/runtime/python/okstra_ctl/fix_cycles.py +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/wizard.py +3 -3
- 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/skills/{okstra-brief → okstra-brief-gen}/SKILL.md +6 -6
- package/runtime/skills/{okstra-brief → okstra-brief-gen}/references/reporter-confirmations.md +1 -1
- package/runtime/skills/{okstra-brief → okstra-brief-gen}/references/tracker-recursion.md +1 -1
- package/runtime/skills/okstra-inspect/SKILL.md +2 -2
- package/runtime/templates/reports/brief.template.md +2 -2
- 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/validators/validate-brief.py +5 -5
- package/runtime/validators/validate-brief.sh +1 -1
- package/src/commands/lifecycle/uninstall.mjs +2 -1
- package/src/lib/skill-catalog.mjs +2 -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
|
Binary file
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
from itertools import combinations
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
import networkx as nx
|
|
6
|
-
from networkx.algorithms.flow import (
|
|
7
|
-
boykov_kolmogorov,
|
|
8
|
-
dinitz,
|
|
9
|
-
edmonds_karp,
|
|
10
|
-
preflow_push,
|
|
11
|
-
shortest_augmenting_path,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
flow_funcs = [
|
|
15
|
-
boykov_kolmogorov,
|
|
16
|
-
dinitz,
|
|
17
|
-
edmonds_karp,
|
|
18
|
-
preflow_push,
|
|
19
|
-
shortest_augmenting_path,
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class TestGomoryHuTree:
|
|
24
|
-
def minimum_edge_weight(self, T, u, v):
|
|
25
|
-
path = nx.shortest_path(T, u, v, weight="weight")
|
|
26
|
-
return min((T[u][v]["weight"], (u, v)) for (u, v) in zip(path, path[1:]))
|
|
27
|
-
|
|
28
|
-
def compute_cutset(self, G, T_orig, edge):
|
|
29
|
-
T = T_orig.copy()
|
|
30
|
-
T.remove_edge(*edge)
|
|
31
|
-
U, V = list(nx.connected_components(T))
|
|
32
|
-
cutset = set()
|
|
33
|
-
for x, nbrs in ((n, G[n]) for n in U):
|
|
34
|
-
cutset.update((x, y) for y in nbrs if y in V)
|
|
35
|
-
return cutset
|
|
36
|
-
|
|
37
|
-
def test_default_flow_function_karate_club_graph(self):
|
|
38
|
-
G = nx.karate_club_graph()
|
|
39
|
-
nx.set_edge_attributes(G, 1, "capacity")
|
|
40
|
-
T = nx.gomory_hu_tree(G)
|
|
41
|
-
assert nx.is_tree(T)
|
|
42
|
-
for u, v in combinations(G, 2):
|
|
43
|
-
cut_value, edge = self.minimum_edge_weight(T, u, v)
|
|
44
|
-
assert nx.minimum_cut_value(G, u, v) == cut_value
|
|
45
|
-
|
|
46
|
-
def test_karate_club_graph(self):
|
|
47
|
-
G = nx.karate_club_graph()
|
|
48
|
-
nx.set_edge_attributes(G, 1, "capacity")
|
|
49
|
-
for flow_func in flow_funcs:
|
|
50
|
-
T = nx.gomory_hu_tree(G, flow_func=flow_func)
|
|
51
|
-
assert nx.is_tree(T)
|
|
52
|
-
for u, v in combinations(G, 2):
|
|
53
|
-
cut_value, edge = self.minimum_edge_weight(T, u, v)
|
|
54
|
-
assert nx.minimum_cut_value(G, u, v) == cut_value
|
|
55
|
-
|
|
56
|
-
def test_davis_southern_women_graph(self):
|
|
57
|
-
G = nx.davis_southern_women_graph()
|
|
58
|
-
nx.set_edge_attributes(G, 1, "capacity")
|
|
59
|
-
for flow_func in flow_funcs:
|
|
60
|
-
T = nx.gomory_hu_tree(G, flow_func=flow_func)
|
|
61
|
-
assert nx.is_tree(T)
|
|
62
|
-
for u, v in combinations(G, 2):
|
|
63
|
-
cut_value, edge = self.minimum_edge_weight(T, u, v)
|
|
64
|
-
assert nx.minimum_cut_value(G, u, v) == cut_value
|
|
65
|
-
|
|
66
|
-
def test_florentine_families_graph(self):
|
|
67
|
-
G = nx.florentine_families_graph()
|
|
68
|
-
nx.set_edge_attributes(G, 1, "capacity")
|
|
69
|
-
for flow_func in flow_funcs:
|
|
70
|
-
T = nx.gomory_hu_tree(G, flow_func=flow_func)
|
|
71
|
-
assert nx.is_tree(T)
|
|
72
|
-
for u, v in combinations(G, 2):
|
|
73
|
-
cut_value, edge = self.minimum_edge_weight(T, u, v)
|
|
74
|
-
assert nx.minimum_cut_value(G, u, v) == cut_value
|
|
75
|
-
|
|
76
|
-
@pytest.mark.slow
|
|
77
|
-
def test_les_miserables_graph_cutset(self):
|
|
78
|
-
G = nx.les_miserables_graph()
|
|
79
|
-
nx.set_edge_attributes(G, 1, "capacity")
|
|
80
|
-
for flow_func in flow_funcs:
|
|
81
|
-
T = nx.gomory_hu_tree(G, flow_func=flow_func)
|
|
82
|
-
assert nx.is_tree(T)
|
|
83
|
-
for u, v in combinations(G, 2):
|
|
84
|
-
cut_value, edge = self.minimum_edge_weight(T, u, v)
|
|
85
|
-
assert nx.minimum_cut_value(G, u, v) == cut_value
|
|
86
|
-
|
|
87
|
-
def test_karate_club_graph_cutset(self):
|
|
88
|
-
G = nx.karate_club_graph()
|
|
89
|
-
nx.set_edge_attributes(G, 1, "capacity")
|
|
90
|
-
T = nx.gomory_hu_tree(G)
|
|
91
|
-
assert nx.is_tree(T)
|
|
92
|
-
u, v = 0, 33
|
|
93
|
-
cut_value, edge = self.minimum_edge_weight(T, u, v)
|
|
94
|
-
cutset = self.compute_cutset(G, T, edge)
|
|
95
|
-
assert cut_value == len(cutset)
|
|
96
|
-
|
|
97
|
-
def test_wikipedia_example(self):
|
|
98
|
-
# Example from https://en.wikipedia.org/wiki/Gomory%E2%80%93Hu_tree
|
|
99
|
-
G = nx.Graph()
|
|
100
|
-
G.add_weighted_edges_from(
|
|
101
|
-
(
|
|
102
|
-
(0, 1, 1),
|
|
103
|
-
(0, 2, 7),
|
|
104
|
-
(1, 2, 1),
|
|
105
|
-
(1, 3, 3),
|
|
106
|
-
(1, 4, 2),
|
|
107
|
-
(2, 4, 4),
|
|
108
|
-
(3, 4, 1),
|
|
109
|
-
(3, 5, 6),
|
|
110
|
-
(4, 5, 2),
|
|
111
|
-
)
|
|
112
|
-
)
|
|
113
|
-
for flow_func in flow_funcs:
|
|
114
|
-
T = nx.gomory_hu_tree(G, capacity="weight", flow_func=flow_func)
|
|
115
|
-
assert nx.is_tree(T)
|
|
116
|
-
for u, v in combinations(G, 2):
|
|
117
|
-
cut_value, edge = self.minimum_edge_weight(T, u, v)
|
|
118
|
-
assert nx.minimum_cut_value(G, u, v, capacity="weight") == cut_value
|
|
119
|
-
|
|
120
|
-
def test_directed_raises(self):
|
|
121
|
-
with pytest.raises(nx.NetworkXNotImplemented):
|
|
122
|
-
G = nx.DiGraph()
|
|
123
|
-
T = nx.gomory_hu_tree(G)
|
|
124
|
-
|
|
125
|
-
def test_empty_raises(self):
|
|
126
|
-
with pytest.raises(nx.NetworkXError):
|
|
127
|
-
G = nx.empty_graph()
|
|
128
|
-
T = nx.gomory_hu_tree(G)
|
|
@@ -1,573 +0,0 @@
|
|
|
1
|
-
"""Maximum flow algorithms test suite."""
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
import networkx as nx
|
|
6
|
-
from networkx.algorithms.flow import (
|
|
7
|
-
boykov_kolmogorov,
|
|
8
|
-
build_flow_dict,
|
|
9
|
-
build_residual_network,
|
|
10
|
-
dinitz,
|
|
11
|
-
edmonds_karp,
|
|
12
|
-
preflow_push,
|
|
13
|
-
shortest_augmenting_path,
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
flow_funcs = {
|
|
17
|
-
boykov_kolmogorov,
|
|
18
|
-
dinitz,
|
|
19
|
-
edmonds_karp,
|
|
20
|
-
preflow_push,
|
|
21
|
-
shortest_augmenting_path,
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
max_min_funcs = {nx.maximum_flow, nx.minimum_cut}
|
|
25
|
-
flow_value_funcs = {nx.maximum_flow_value, nx.minimum_cut_value}
|
|
26
|
-
interface_funcs = max_min_funcs | flow_value_funcs
|
|
27
|
-
all_funcs = flow_funcs | interface_funcs
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def compute_cutset(G, partition):
|
|
31
|
-
reachable, non_reachable = partition
|
|
32
|
-
cutset = set()
|
|
33
|
-
for u, nbrs in ((n, G[n]) for n in reachable):
|
|
34
|
-
cutset.update((u, v) for v in nbrs if v in non_reachable)
|
|
35
|
-
return cutset
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def validate_flows(G, s, t, flowDict, solnValue, capacity, flow_func):
|
|
39
|
-
errmsg = f"Assertion failed in function: {flow_func.__name__}"
|
|
40
|
-
assert set(G) == set(flowDict), errmsg
|
|
41
|
-
for u in G:
|
|
42
|
-
assert set(G[u]) == set(flowDict[u]), errmsg
|
|
43
|
-
excess = {u: 0 for u in flowDict}
|
|
44
|
-
for u in flowDict:
|
|
45
|
-
for v, flow in flowDict[u].items():
|
|
46
|
-
if capacity in G[u][v]:
|
|
47
|
-
assert flow <= G[u][v][capacity]
|
|
48
|
-
assert flow >= 0, errmsg
|
|
49
|
-
excess[u] -= flow
|
|
50
|
-
excess[v] += flow
|
|
51
|
-
for u, exc in excess.items():
|
|
52
|
-
if u == s:
|
|
53
|
-
assert exc == -solnValue, errmsg
|
|
54
|
-
elif u == t:
|
|
55
|
-
assert exc == solnValue, errmsg
|
|
56
|
-
else:
|
|
57
|
-
assert exc == 0, errmsg
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def validate_cuts(G, s, t, solnValue, partition, capacity, flow_func):
|
|
61
|
-
errmsg = f"Assertion failed in function: {flow_func.__name__}"
|
|
62
|
-
assert all(n in G for n in partition[0]), errmsg
|
|
63
|
-
assert all(n in G for n in partition[1]), errmsg
|
|
64
|
-
cutset = compute_cutset(G, partition)
|
|
65
|
-
assert all(G.has_edge(u, v) for (u, v) in cutset), errmsg
|
|
66
|
-
assert solnValue == sum(G[u][v][capacity] for (u, v) in cutset), errmsg
|
|
67
|
-
H = G.copy()
|
|
68
|
-
H.remove_edges_from(cutset)
|
|
69
|
-
if not G.is_directed():
|
|
70
|
-
assert not nx.is_connected(H), errmsg
|
|
71
|
-
else:
|
|
72
|
-
assert not nx.is_strongly_connected(H), errmsg
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def compare_flows_and_cuts(G, s, t, solnValue, capacity="capacity"):
|
|
76
|
-
for flow_func in flow_funcs:
|
|
77
|
-
errmsg = f"Assertion failed in function: {flow_func.__name__}"
|
|
78
|
-
R = flow_func(G, s, t, capacity)
|
|
79
|
-
# Test both legacy and new implementations.
|
|
80
|
-
flow_value = R.graph["flow_value"]
|
|
81
|
-
flow_dict = build_flow_dict(G, R)
|
|
82
|
-
assert flow_value == solnValue, errmsg
|
|
83
|
-
validate_flows(G, s, t, flow_dict, solnValue, capacity, flow_func)
|
|
84
|
-
# Minimum cut
|
|
85
|
-
cut_value, partition = nx.minimum_cut(
|
|
86
|
-
G, s, t, capacity=capacity, flow_func=flow_func
|
|
87
|
-
)
|
|
88
|
-
validate_cuts(G, s, t, solnValue, partition, capacity, flow_func)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
class TestMaxflowMinCutCommon:
|
|
92
|
-
def test_graph1(self):
|
|
93
|
-
# Trivial undirected graph
|
|
94
|
-
G = nx.Graph()
|
|
95
|
-
G.add_edge(1, 2, capacity=1.0)
|
|
96
|
-
|
|
97
|
-
# solution flows
|
|
98
|
-
# {1: {2: 1.0}, 2: {1: 1.0}}
|
|
99
|
-
|
|
100
|
-
compare_flows_and_cuts(G, 1, 2, 1.0)
|
|
101
|
-
|
|
102
|
-
def test_graph2(self):
|
|
103
|
-
# A more complex undirected graph
|
|
104
|
-
# adapted from https://web.archive.org/web/20220815055650/https://www.topcoder.com/thrive/articles/Maximum%20Flow:%20Part%20One
|
|
105
|
-
G = nx.Graph()
|
|
106
|
-
G.add_edge("x", "a", capacity=3.0)
|
|
107
|
-
G.add_edge("x", "b", capacity=1.0)
|
|
108
|
-
G.add_edge("a", "c", capacity=3.0)
|
|
109
|
-
G.add_edge("b", "c", capacity=5.0)
|
|
110
|
-
G.add_edge("b", "d", capacity=4.0)
|
|
111
|
-
G.add_edge("d", "e", capacity=2.0)
|
|
112
|
-
G.add_edge("c", "y", capacity=2.0)
|
|
113
|
-
G.add_edge("e", "y", capacity=3.0)
|
|
114
|
-
|
|
115
|
-
# H
|
|
116
|
-
# {
|
|
117
|
-
# "x": {"a": 3, "b": 1},
|
|
118
|
-
# "a": {"c": 3, "x": 3},
|
|
119
|
-
# "b": {"c": 1, "d": 2, "x": 1},
|
|
120
|
-
# "c": {"a": 3, "b": 1, "y": 2},
|
|
121
|
-
# "d": {"b": 2, "e": 2},
|
|
122
|
-
# "e": {"d": 2, "y": 2},
|
|
123
|
-
# "y": {"c": 2, "e": 2},
|
|
124
|
-
# }
|
|
125
|
-
|
|
126
|
-
compare_flows_and_cuts(G, "x", "y", 4.0)
|
|
127
|
-
|
|
128
|
-
def test_digraph1(self):
|
|
129
|
-
# The classic directed graph example
|
|
130
|
-
G = nx.DiGraph()
|
|
131
|
-
G.add_edge("a", "b", capacity=1000.0)
|
|
132
|
-
G.add_edge("a", "c", capacity=1000.0)
|
|
133
|
-
G.add_edge("b", "c", capacity=1.0)
|
|
134
|
-
G.add_edge("b", "d", capacity=1000.0)
|
|
135
|
-
G.add_edge("c", "d", capacity=1000.0)
|
|
136
|
-
|
|
137
|
-
# H
|
|
138
|
-
# {
|
|
139
|
-
# "a": {"b": 1000.0, "c": 1000.0},
|
|
140
|
-
# "b": {"c": 0, "d": 1000.0},
|
|
141
|
-
# "c": {"d": 1000.0},
|
|
142
|
-
# "d": {},
|
|
143
|
-
# }
|
|
144
|
-
|
|
145
|
-
compare_flows_and_cuts(G, "a", "d", 2000.0)
|
|
146
|
-
|
|
147
|
-
def test_digraph2(self):
|
|
148
|
-
# An example in which some edges end up with zero flow.
|
|
149
|
-
G = nx.DiGraph()
|
|
150
|
-
G.add_edge("s", "b", capacity=2)
|
|
151
|
-
G.add_edge("s", "c", capacity=1)
|
|
152
|
-
G.add_edge("c", "d", capacity=1)
|
|
153
|
-
G.add_edge("d", "a", capacity=1)
|
|
154
|
-
G.add_edge("b", "a", capacity=2)
|
|
155
|
-
G.add_edge("a", "t", capacity=2)
|
|
156
|
-
|
|
157
|
-
# H
|
|
158
|
-
# {
|
|
159
|
-
# "s": {"b": 2, "c": 0},
|
|
160
|
-
# "c": {"d": 0},
|
|
161
|
-
# "d": {"a": 0},
|
|
162
|
-
# "b": {"a": 2},
|
|
163
|
-
# "a": {"t": 2},
|
|
164
|
-
# "t": {},
|
|
165
|
-
# }
|
|
166
|
-
|
|
167
|
-
compare_flows_and_cuts(G, "s", "t", 2)
|
|
168
|
-
|
|
169
|
-
def test_digraph3(self):
|
|
170
|
-
# A directed graph example from Cormen et al.
|
|
171
|
-
G = nx.DiGraph()
|
|
172
|
-
G.add_edge("s", "v1", capacity=16.0)
|
|
173
|
-
G.add_edge("s", "v2", capacity=13.0)
|
|
174
|
-
G.add_edge("v1", "v2", capacity=10.0)
|
|
175
|
-
G.add_edge("v2", "v1", capacity=4.0)
|
|
176
|
-
G.add_edge("v1", "v3", capacity=12.0)
|
|
177
|
-
G.add_edge("v3", "v2", capacity=9.0)
|
|
178
|
-
G.add_edge("v2", "v4", capacity=14.0)
|
|
179
|
-
G.add_edge("v4", "v3", capacity=7.0)
|
|
180
|
-
G.add_edge("v3", "t", capacity=20.0)
|
|
181
|
-
G.add_edge("v4", "t", capacity=4.0)
|
|
182
|
-
|
|
183
|
-
# H
|
|
184
|
-
# {
|
|
185
|
-
# "s": {"v1": 12.0, "v2": 11.0},
|
|
186
|
-
# "v2": {"v1": 0, "v4": 11.0},
|
|
187
|
-
# "v1": {"v2": 0, "v3": 12.0},
|
|
188
|
-
# "v3": {"v2": 0, "t": 19.0},
|
|
189
|
-
# "v4": {"v3": 7.0, "t": 4.0},
|
|
190
|
-
# "t": {},
|
|
191
|
-
# }
|
|
192
|
-
|
|
193
|
-
compare_flows_and_cuts(G, "s", "t", 23.0)
|
|
194
|
-
|
|
195
|
-
def test_digraph4(self):
|
|
196
|
-
# A more complex directed graph
|
|
197
|
-
# from https://web.archive.org/web/20220815055650/https://www.topcoder.com/thrive/articles/Maximum%20Flow:%20Part%20One
|
|
198
|
-
G = nx.DiGraph()
|
|
199
|
-
G.add_edge("x", "a", capacity=3.0)
|
|
200
|
-
G.add_edge("x", "b", capacity=1.0)
|
|
201
|
-
G.add_edge("a", "c", capacity=3.0)
|
|
202
|
-
G.add_edge("b", "c", capacity=5.0)
|
|
203
|
-
G.add_edge("b", "d", capacity=4.0)
|
|
204
|
-
G.add_edge("d", "e", capacity=2.0)
|
|
205
|
-
G.add_edge("c", "y", capacity=2.0)
|
|
206
|
-
G.add_edge("e", "y", capacity=3.0)
|
|
207
|
-
|
|
208
|
-
# H
|
|
209
|
-
# {
|
|
210
|
-
# "x": {"a": 2.0, "b": 1.0},
|
|
211
|
-
# "a": {"c": 2.0},
|
|
212
|
-
# "b": {"c": 0, "d": 1.0},
|
|
213
|
-
# "c": {"y": 2.0},
|
|
214
|
-
# "d": {"e": 1.0},
|
|
215
|
-
# "e": {"y": 1.0},
|
|
216
|
-
# "y": {},
|
|
217
|
-
# }
|
|
218
|
-
|
|
219
|
-
compare_flows_and_cuts(G, "x", "y", 3.0)
|
|
220
|
-
|
|
221
|
-
def test_wikipedia_dinitz_example(self):
|
|
222
|
-
# Nice example from https://en.wikipedia.org/wiki/Dinic's_algorithm
|
|
223
|
-
G = nx.DiGraph()
|
|
224
|
-
G.add_edge("s", 1, capacity=10)
|
|
225
|
-
G.add_edge("s", 2, capacity=10)
|
|
226
|
-
G.add_edge(1, 3, capacity=4)
|
|
227
|
-
G.add_edge(1, 4, capacity=8)
|
|
228
|
-
G.add_edge(1, 2, capacity=2)
|
|
229
|
-
G.add_edge(2, 4, capacity=9)
|
|
230
|
-
G.add_edge(3, "t", capacity=10)
|
|
231
|
-
G.add_edge(4, 3, capacity=6)
|
|
232
|
-
G.add_edge(4, "t", capacity=10)
|
|
233
|
-
|
|
234
|
-
# solution flows
|
|
235
|
-
# {
|
|
236
|
-
# 1: {2: 0, 3: 4, 4: 6},
|
|
237
|
-
# 2: {4: 9},
|
|
238
|
-
# 3: {"t": 9},
|
|
239
|
-
# 4: {3: 5, "t": 10},
|
|
240
|
-
# "s": {1: 10, 2: 9},
|
|
241
|
-
# "t": {},
|
|
242
|
-
# }
|
|
243
|
-
|
|
244
|
-
compare_flows_and_cuts(G, "s", "t", 19)
|
|
245
|
-
|
|
246
|
-
def test_optional_capacity(self):
|
|
247
|
-
# Test optional capacity parameter.
|
|
248
|
-
G = nx.DiGraph()
|
|
249
|
-
G.add_edge("x", "a", spam=3.0)
|
|
250
|
-
G.add_edge("x", "b", spam=1.0)
|
|
251
|
-
G.add_edge("a", "c", spam=3.0)
|
|
252
|
-
G.add_edge("b", "c", spam=5.0)
|
|
253
|
-
G.add_edge("b", "d", spam=4.0)
|
|
254
|
-
G.add_edge("d", "e", spam=2.0)
|
|
255
|
-
G.add_edge("c", "y", spam=2.0)
|
|
256
|
-
G.add_edge("e", "y", spam=3.0)
|
|
257
|
-
|
|
258
|
-
# solution flows
|
|
259
|
-
# {
|
|
260
|
-
# "x": {"a": 2.0, "b": 1.0},
|
|
261
|
-
# "a": {"c": 2.0},
|
|
262
|
-
# "b": {"c": 0, "d": 1.0},
|
|
263
|
-
# "c": {"y": 2.0},
|
|
264
|
-
# "d": {"e": 1.0},
|
|
265
|
-
# "e": {"y": 1.0},
|
|
266
|
-
# "y": {},
|
|
267
|
-
# }
|
|
268
|
-
solnValue = 3.0
|
|
269
|
-
s = "x"
|
|
270
|
-
t = "y"
|
|
271
|
-
|
|
272
|
-
compare_flows_and_cuts(G, s, t, solnValue, capacity="spam")
|
|
273
|
-
|
|
274
|
-
def test_digraph_infcap_edges(self):
|
|
275
|
-
# DiGraph with infinite capacity edges
|
|
276
|
-
G = nx.DiGraph()
|
|
277
|
-
G.add_edge("s", "a")
|
|
278
|
-
G.add_edge("s", "b", capacity=30)
|
|
279
|
-
G.add_edge("a", "c", capacity=25)
|
|
280
|
-
G.add_edge("b", "c", capacity=12)
|
|
281
|
-
G.add_edge("a", "t", capacity=60)
|
|
282
|
-
G.add_edge("c", "t")
|
|
283
|
-
|
|
284
|
-
# H
|
|
285
|
-
# {
|
|
286
|
-
# "s": {"a": 85, "b": 12},
|
|
287
|
-
# "a": {"c": 25, "t": 60},
|
|
288
|
-
# "b": {"c": 12},
|
|
289
|
-
# "c": {"t": 37},
|
|
290
|
-
# "t": {},
|
|
291
|
-
# }
|
|
292
|
-
|
|
293
|
-
compare_flows_and_cuts(G, "s", "t", 97)
|
|
294
|
-
|
|
295
|
-
# DiGraph with infinite capacity digon
|
|
296
|
-
G = nx.DiGraph()
|
|
297
|
-
G.add_edge("s", "a", capacity=85)
|
|
298
|
-
G.add_edge("s", "b", capacity=30)
|
|
299
|
-
G.add_edge("a", "c")
|
|
300
|
-
G.add_edge("c", "a")
|
|
301
|
-
G.add_edge("b", "c", capacity=12)
|
|
302
|
-
G.add_edge("a", "t", capacity=60)
|
|
303
|
-
G.add_edge("c", "t", capacity=37)
|
|
304
|
-
|
|
305
|
-
# H
|
|
306
|
-
# {
|
|
307
|
-
# "s": {"a": 85, "b": 12},
|
|
308
|
-
# "a": {"c": 25, "t": 60},
|
|
309
|
-
# "c": {"a": 0, "t": 37},
|
|
310
|
-
# "b": {"c": 12},
|
|
311
|
-
# "t": {},
|
|
312
|
-
# }
|
|
313
|
-
|
|
314
|
-
compare_flows_and_cuts(G, "s", "t", 97)
|
|
315
|
-
|
|
316
|
-
def test_digraph_infcap_path(self):
|
|
317
|
-
# Graph with infinite capacity (s, t)-path
|
|
318
|
-
G = nx.DiGraph()
|
|
319
|
-
G.add_edge("s", "a")
|
|
320
|
-
G.add_edge("s", "b", capacity=30)
|
|
321
|
-
G.add_edge("a", "c")
|
|
322
|
-
G.add_edge("b", "c", capacity=12)
|
|
323
|
-
G.add_edge("a", "t", capacity=60)
|
|
324
|
-
G.add_edge("c", "t")
|
|
325
|
-
|
|
326
|
-
for flow_func in all_funcs:
|
|
327
|
-
pytest.raises(nx.NetworkXUnbounded, flow_func, G, "s", "t")
|
|
328
|
-
|
|
329
|
-
def test_graph_infcap_edges(self):
|
|
330
|
-
# Undirected graph with infinite capacity edges
|
|
331
|
-
G = nx.Graph()
|
|
332
|
-
G.add_edge("s", "a")
|
|
333
|
-
G.add_edge("s", "b", capacity=30)
|
|
334
|
-
G.add_edge("a", "c", capacity=25)
|
|
335
|
-
G.add_edge("b", "c", capacity=12)
|
|
336
|
-
G.add_edge("a", "t", capacity=60)
|
|
337
|
-
G.add_edge("c", "t")
|
|
338
|
-
|
|
339
|
-
# H
|
|
340
|
-
# {
|
|
341
|
-
# "s": {"a": 85, "b": 12},
|
|
342
|
-
# "a": {"c": 25, "s": 85, "t": 60},
|
|
343
|
-
# "b": {"c": 12, "s": 12},
|
|
344
|
-
# "c": {"a": 25, "b": 12, "t": 37},
|
|
345
|
-
# "t": {"a": 60, "c": 37},
|
|
346
|
-
# }
|
|
347
|
-
|
|
348
|
-
compare_flows_and_cuts(G, "s", "t", 97)
|
|
349
|
-
|
|
350
|
-
def test_digraph5(self):
|
|
351
|
-
# From ticket #429 by mfrasca.
|
|
352
|
-
G = nx.DiGraph()
|
|
353
|
-
G.add_edge("s", "a", capacity=2)
|
|
354
|
-
G.add_edge("s", "b", capacity=2)
|
|
355
|
-
G.add_edge("a", "b", capacity=5)
|
|
356
|
-
G.add_edge("a", "t", capacity=1)
|
|
357
|
-
G.add_edge("b", "a", capacity=1)
|
|
358
|
-
G.add_edge("b", "t", capacity=3)
|
|
359
|
-
# flow solution
|
|
360
|
-
# {
|
|
361
|
-
# "a": {"b": 1, "t": 1},
|
|
362
|
-
# "b": {"a": 0, "t": 3},
|
|
363
|
-
# "s": {"a": 2, "b": 2},
|
|
364
|
-
# "t": {},
|
|
365
|
-
# }
|
|
366
|
-
compare_flows_and_cuts(G, "s", "t", 4)
|
|
367
|
-
|
|
368
|
-
def test_disconnected(self):
|
|
369
|
-
G = nx.Graph()
|
|
370
|
-
G.add_weighted_edges_from([(0, 1, 1), (1, 2, 1), (2, 3, 1)], weight="capacity")
|
|
371
|
-
G.remove_node(1)
|
|
372
|
-
assert nx.maximum_flow_value(G, 0, 3) == 0
|
|
373
|
-
# flow solution
|
|
374
|
-
# {0: {}, 2: {3: 0}, 3: {2: 0}}
|
|
375
|
-
compare_flows_and_cuts(G, 0, 3, 0)
|
|
376
|
-
|
|
377
|
-
def test_source_target_not_in_graph(self):
|
|
378
|
-
G = nx.Graph()
|
|
379
|
-
G.add_weighted_edges_from([(0, 1, 1), (1, 2, 1), (2, 3, 1)], weight="capacity")
|
|
380
|
-
G.remove_node(0)
|
|
381
|
-
for flow_func in all_funcs:
|
|
382
|
-
pytest.raises(nx.NetworkXError, flow_func, G, 0, 3)
|
|
383
|
-
G.add_weighted_edges_from([(0, 1, 1), (1, 2, 1), (2, 3, 1)], weight="capacity")
|
|
384
|
-
G.remove_node(3)
|
|
385
|
-
for flow_func in all_funcs:
|
|
386
|
-
pytest.raises(nx.NetworkXError, flow_func, G, 0, 3)
|
|
387
|
-
|
|
388
|
-
def test_source_target_coincide(self):
|
|
389
|
-
G = nx.Graph()
|
|
390
|
-
G.add_node(0)
|
|
391
|
-
for flow_func in all_funcs:
|
|
392
|
-
pytest.raises(nx.NetworkXError, flow_func, G, 0, 0)
|
|
393
|
-
|
|
394
|
-
def test_multigraphs_raise(self):
|
|
395
|
-
G = nx.MultiGraph()
|
|
396
|
-
M = nx.MultiDiGraph()
|
|
397
|
-
G.add_edges_from([(0, 1), (1, 0)], capacity=True)
|
|
398
|
-
for flow_func in all_funcs:
|
|
399
|
-
pytest.raises(nx.NetworkXError, flow_func, G, 0, 0)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
class TestMaxFlowMinCutInterface:
|
|
403
|
-
def setup_method(self):
|
|
404
|
-
G = nx.DiGraph()
|
|
405
|
-
G.add_edge("x", "a", capacity=3.0)
|
|
406
|
-
G.add_edge("x", "b", capacity=1.0)
|
|
407
|
-
G.add_edge("a", "c", capacity=3.0)
|
|
408
|
-
G.add_edge("b", "c", capacity=5.0)
|
|
409
|
-
G.add_edge("b", "d", capacity=4.0)
|
|
410
|
-
G.add_edge("d", "e", capacity=2.0)
|
|
411
|
-
G.add_edge("c", "y", capacity=2.0)
|
|
412
|
-
G.add_edge("e", "y", capacity=3.0)
|
|
413
|
-
self.G = G
|
|
414
|
-
H = nx.DiGraph()
|
|
415
|
-
H.add_edge(0, 1, capacity=1.0)
|
|
416
|
-
H.add_edge(1, 2, capacity=1.0)
|
|
417
|
-
self.H = H
|
|
418
|
-
|
|
419
|
-
def test_flow_func_not_callable(self):
|
|
420
|
-
elements = ["this_should_be_callable", 10, {1, 2, 3}]
|
|
421
|
-
G = nx.Graph()
|
|
422
|
-
G.add_weighted_edges_from([(0, 1, 1), (1, 2, 1), (2, 3, 1)], weight="capacity")
|
|
423
|
-
for flow_func in interface_funcs:
|
|
424
|
-
for element in elements:
|
|
425
|
-
pytest.raises(nx.NetworkXError, flow_func, G, 0, 1, flow_func=element)
|
|
426
|
-
pytest.raises(nx.NetworkXError, flow_func, G, 0, 1, flow_func=element)
|
|
427
|
-
|
|
428
|
-
def test_flow_func_parameters(self):
|
|
429
|
-
G = self.G
|
|
430
|
-
fv = 3.0
|
|
431
|
-
for interface_func in interface_funcs:
|
|
432
|
-
for flow_func in flow_funcs:
|
|
433
|
-
errmsg = (
|
|
434
|
-
f"Assertion failed in function: {flow_func.__name__} "
|
|
435
|
-
f"in interface {interface_func.__name__}"
|
|
436
|
-
)
|
|
437
|
-
result = interface_func(G, "x", "y", flow_func=flow_func)
|
|
438
|
-
if interface_func in max_min_funcs:
|
|
439
|
-
result = result[0]
|
|
440
|
-
assert fv == result, errmsg
|
|
441
|
-
|
|
442
|
-
def test_minimum_cut_no_cutoff(self):
|
|
443
|
-
G = self.G
|
|
444
|
-
pytest.raises(
|
|
445
|
-
nx.NetworkXError,
|
|
446
|
-
nx.minimum_cut,
|
|
447
|
-
G,
|
|
448
|
-
"x",
|
|
449
|
-
"y",
|
|
450
|
-
flow_func=preflow_push,
|
|
451
|
-
cutoff=1.0,
|
|
452
|
-
)
|
|
453
|
-
pytest.raises(
|
|
454
|
-
nx.NetworkXError,
|
|
455
|
-
nx.minimum_cut_value,
|
|
456
|
-
G,
|
|
457
|
-
"x",
|
|
458
|
-
"y",
|
|
459
|
-
flow_func=preflow_push,
|
|
460
|
-
cutoff=1.0,
|
|
461
|
-
)
|
|
462
|
-
|
|
463
|
-
def test_kwargs(self):
|
|
464
|
-
G = self.H
|
|
465
|
-
fv = 1.0
|
|
466
|
-
to_test = (
|
|
467
|
-
(shortest_augmenting_path, {"two_phase": True}),
|
|
468
|
-
(preflow_push, {"global_relabel_freq": 5}),
|
|
469
|
-
)
|
|
470
|
-
for interface_func in interface_funcs:
|
|
471
|
-
for flow_func, kwargs in to_test:
|
|
472
|
-
errmsg = (
|
|
473
|
-
f"Assertion failed in function: {flow_func.__name__} "
|
|
474
|
-
f"in interface {interface_func.__name__}"
|
|
475
|
-
)
|
|
476
|
-
result = interface_func(G, 0, 2, flow_func=flow_func, **kwargs)
|
|
477
|
-
if interface_func in max_min_funcs:
|
|
478
|
-
result = result[0]
|
|
479
|
-
assert fv == result, errmsg
|
|
480
|
-
|
|
481
|
-
def test_kwargs_default_flow_func(self):
|
|
482
|
-
G = self.H
|
|
483
|
-
for interface_func in interface_funcs:
|
|
484
|
-
pytest.raises(
|
|
485
|
-
nx.NetworkXError, interface_func, G, 0, 1, global_relabel_freq=2
|
|
486
|
-
)
|
|
487
|
-
|
|
488
|
-
def test_reusing_residual(self):
|
|
489
|
-
G = self.G
|
|
490
|
-
fv = 3.0
|
|
491
|
-
s, t = "x", "y"
|
|
492
|
-
R = build_residual_network(G, "capacity")
|
|
493
|
-
for interface_func in interface_funcs:
|
|
494
|
-
for flow_func in flow_funcs:
|
|
495
|
-
errmsg = (
|
|
496
|
-
f"Assertion failed in function: {flow_func.__name__} "
|
|
497
|
-
f"in interface {interface_func.__name__}"
|
|
498
|
-
)
|
|
499
|
-
for i in range(3):
|
|
500
|
-
result = interface_func(
|
|
501
|
-
G, "x", "y", flow_func=flow_func, residual=R
|
|
502
|
-
)
|
|
503
|
-
if interface_func in max_min_funcs:
|
|
504
|
-
result = result[0]
|
|
505
|
-
assert fv == result, errmsg
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
# Tests specific to one algorithm
|
|
509
|
-
def test_preflow_push_global_relabel_freq():
|
|
510
|
-
G = nx.DiGraph()
|
|
511
|
-
G.add_edge(1, 2, capacity=1)
|
|
512
|
-
R = preflow_push(G, 1, 2, global_relabel_freq=None)
|
|
513
|
-
assert R.graph["flow_value"] == 1
|
|
514
|
-
pytest.raises(nx.NetworkXError, preflow_push, G, 1, 2, global_relabel_freq=-1)
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
def test_preflow_push_makes_enough_space():
|
|
518
|
-
# From ticket #1542
|
|
519
|
-
G = nx.DiGraph()
|
|
520
|
-
nx.add_path(G, [0, 1, 3], capacity=1)
|
|
521
|
-
nx.add_path(G, [1, 2, 3], capacity=1)
|
|
522
|
-
R = preflow_push(G, 0, 3, value_only=False)
|
|
523
|
-
assert R.graph["flow_value"] == 1
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
def test_shortest_augmenting_path_two_phase():
|
|
527
|
-
k = 5
|
|
528
|
-
p = 1000
|
|
529
|
-
G = nx.DiGraph()
|
|
530
|
-
for i in range(k):
|
|
531
|
-
G.add_edge("s", (i, 0), capacity=1)
|
|
532
|
-
nx.add_path(G, ((i, j) for j in range(p)), capacity=1)
|
|
533
|
-
G.add_edge((i, p - 1), "t", capacity=1)
|
|
534
|
-
R = shortest_augmenting_path(G, "s", "t", two_phase=True)
|
|
535
|
-
assert R.graph["flow_value"] == k
|
|
536
|
-
R = shortest_augmenting_path(G, "s", "t", two_phase=False)
|
|
537
|
-
assert R.graph["flow_value"] == k
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
class TestCutoff:
|
|
541
|
-
def test_cutoff(self):
|
|
542
|
-
k = 5
|
|
543
|
-
p = 1000
|
|
544
|
-
G = nx.DiGraph()
|
|
545
|
-
for i in range(k):
|
|
546
|
-
G.add_edge("s", (i, 0), capacity=2)
|
|
547
|
-
nx.add_path(G, ((i, j) for j in range(p)), capacity=2)
|
|
548
|
-
G.add_edge((i, p - 1), "t", capacity=2)
|
|
549
|
-
R = shortest_augmenting_path(G, "s", "t", two_phase=True, cutoff=k)
|
|
550
|
-
assert k <= R.graph["flow_value"] <= (2 * k)
|
|
551
|
-
R = shortest_augmenting_path(G, "s", "t", two_phase=False, cutoff=k)
|
|
552
|
-
assert k <= R.graph["flow_value"] <= (2 * k)
|
|
553
|
-
R = edmonds_karp(G, "s", "t", cutoff=k)
|
|
554
|
-
assert k <= R.graph["flow_value"] <= (2 * k)
|
|
555
|
-
R = dinitz(G, "s", "t", cutoff=k)
|
|
556
|
-
assert k <= R.graph["flow_value"] <= (2 * k)
|
|
557
|
-
R = boykov_kolmogorov(G, "s", "t", cutoff=k)
|
|
558
|
-
assert k <= R.graph["flow_value"] <= (2 * k)
|
|
559
|
-
|
|
560
|
-
def test_complete_graph_cutoff(self):
|
|
561
|
-
G = nx.complete_graph(5)
|
|
562
|
-
nx.set_edge_attributes(G, {(u, v): 1 for u, v in G.edges()}, "capacity")
|
|
563
|
-
for flow_func in [
|
|
564
|
-
shortest_augmenting_path,
|
|
565
|
-
edmonds_karp,
|
|
566
|
-
dinitz,
|
|
567
|
-
boykov_kolmogorov,
|
|
568
|
-
]:
|
|
569
|
-
for cutoff in [3, 2, 1]:
|
|
570
|
-
result = nx.maximum_flow_value(
|
|
571
|
-
G, 0, 4, flow_func=flow_func, cutoff=cutoff
|
|
572
|
-
)
|
|
573
|
-
assert cutoff == result, f"cutoff error in {flow_func.__name__}"
|