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
|
@@ -1,835 +0,0 @@
|
|
|
1
|
-
from collections import deque
|
|
2
|
-
from itertools import combinations, permutations
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
|
|
6
|
-
import networkx as nx
|
|
7
|
-
from networkx.utils import edges_equal, pairwise
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Recipe from the itertools documentation.
|
|
11
|
-
def _consume(iterator):
|
|
12
|
-
"Consume the iterator entirely."
|
|
13
|
-
# Feed the entire iterator into a zero-length deque.
|
|
14
|
-
deque(iterator, maxlen=0)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TestDagLongestPath:
|
|
18
|
-
"""Unit tests computing the longest path in a directed acyclic graph."""
|
|
19
|
-
|
|
20
|
-
def test_empty(self):
|
|
21
|
-
G = nx.DiGraph()
|
|
22
|
-
assert nx.dag_longest_path(G) == []
|
|
23
|
-
|
|
24
|
-
def test_unweighted1(self):
|
|
25
|
-
edges = [(1, 2), (2, 3), (2, 4), (3, 5), (5, 6), (3, 7)]
|
|
26
|
-
G = nx.DiGraph(edges)
|
|
27
|
-
assert nx.dag_longest_path(G) == [1, 2, 3, 5, 6]
|
|
28
|
-
|
|
29
|
-
def test_unweighted2(self):
|
|
30
|
-
edges = [(1, 2), (2, 3), (3, 4), (4, 5), (1, 3), (1, 5), (3, 5)]
|
|
31
|
-
G = nx.DiGraph(edges)
|
|
32
|
-
assert nx.dag_longest_path(G) == [1, 2, 3, 4, 5]
|
|
33
|
-
|
|
34
|
-
def test_weighted(self):
|
|
35
|
-
G = nx.DiGraph()
|
|
36
|
-
edges = [(1, 2, -5), (2, 3, 1), (3, 4, 1), (4, 5, 0), (3, 5, 4), (1, 6, 2)]
|
|
37
|
-
G.add_weighted_edges_from(edges)
|
|
38
|
-
assert nx.dag_longest_path(G) == [2, 3, 5]
|
|
39
|
-
|
|
40
|
-
def test_undirected_not_implemented(self):
|
|
41
|
-
G = nx.Graph()
|
|
42
|
-
pytest.raises(nx.NetworkXNotImplemented, nx.dag_longest_path, G)
|
|
43
|
-
|
|
44
|
-
def test_unorderable_nodes(self):
|
|
45
|
-
"""Tests that computing the longest path does not depend on
|
|
46
|
-
nodes being orderable.
|
|
47
|
-
|
|
48
|
-
For more information, see issue #1989.
|
|
49
|
-
|
|
50
|
-
"""
|
|
51
|
-
# Create the directed path graph on four nodes in a diamond shape,
|
|
52
|
-
# with nodes represented as (unorderable) Python objects.
|
|
53
|
-
nodes = [object() for n in range(4)]
|
|
54
|
-
G = nx.DiGraph()
|
|
55
|
-
G.add_edge(nodes[0], nodes[1])
|
|
56
|
-
G.add_edge(nodes[0], nodes[2])
|
|
57
|
-
G.add_edge(nodes[2], nodes[3])
|
|
58
|
-
G.add_edge(nodes[1], nodes[3])
|
|
59
|
-
|
|
60
|
-
# this will raise NotImplementedError when nodes need to be ordered
|
|
61
|
-
nx.dag_longest_path(G)
|
|
62
|
-
|
|
63
|
-
def test_multigraph_unweighted(self):
|
|
64
|
-
edges = [(1, 2), (2, 3), (2, 3), (3, 4), (4, 5), (1, 3), (1, 5), (3, 5)]
|
|
65
|
-
G = nx.MultiDiGraph(edges)
|
|
66
|
-
assert nx.dag_longest_path(G) == [1, 2, 3, 4, 5]
|
|
67
|
-
|
|
68
|
-
def test_multigraph_weighted(self):
|
|
69
|
-
G = nx.MultiDiGraph()
|
|
70
|
-
edges = [
|
|
71
|
-
(1, 2, 2),
|
|
72
|
-
(2, 3, 2),
|
|
73
|
-
(1, 3, 1),
|
|
74
|
-
(1, 3, 5),
|
|
75
|
-
(1, 3, 2),
|
|
76
|
-
]
|
|
77
|
-
G.add_weighted_edges_from(edges)
|
|
78
|
-
assert nx.dag_longest_path(G) == [1, 3]
|
|
79
|
-
|
|
80
|
-
def test_multigraph_weighted_default_weight(self):
|
|
81
|
-
G = nx.MultiDiGraph([(1, 2), (2, 3)]) # Unweighted edges
|
|
82
|
-
G.add_weighted_edges_from([(1, 3, 1), (1, 3, 5), (1, 3, 2)])
|
|
83
|
-
|
|
84
|
-
# Default value for default weight is 1
|
|
85
|
-
assert nx.dag_longest_path(G) == [1, 3]
|
|
86
|
-
assert nx.dag_longest_path(G, default_weight=3) == [1, 2, 3]
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
class TestDagLongestPathLength:
|
|
90
|
-
"""Unit tests for computing the length of a longest path in a
|
|
91
|
-
directed acyclic graph.
|
|
92
|
-
|
|
93
|
-
"""
|
|
94
|
-
|
|
95
|
-
def test_unweighted(self):
|
|
96
|
-
edges = [(1, 2), (2, 3), (2, 4), (3, 5), (5, 6), (5, 7)]
|
|
97
|
-
G = nx.DiGraph(edges)
|
|
98
|
-
assert nx.dag_longest_path_length(G) == 4
|
|
99
|
-
|
|
100
|
-
edges = [(1, 2), (2, 3), (3, 4), (4, 5), (1, 3), (1, 5), (3, 5)]
|
|
101
|
-
G = nx.DiGraph(edges)
|
|
102
|
-
assert nx.dag_longest_path_length(G) == 4
|
|
103
|
-
|
|
104
|
-
# test degenerate graphs
|
|
105
|
-
G = nx.DiGraph()
|
|
106
|
-
G.add_node(1)
|
|
107
|
-
assert nx.dag_longest_path_length(G) == 0
|
|
108
|
-
|
|
109
|
-
def test_undirected_not_implemented(self):
|
|
110
|
-
G = nx.Graph()
|
|
111
|
-
pytest.raises(nx.NetworkXNotImplemented, nx.dag_longest_path_length, G)
|
|
112
|
-
|
|
113
|
-
def test_weighted(self):
|
|
114
|
-
edges = [(1, 2, -5), (2, 3, 1), (3, 4, 1), (4, 5, 0), (3, 5, 4), (1, 6, 2)]
|
|
115
|
-
G = nx.DiGraph()
|
|
116
|
-
G.add_weighted_edges_from(edges)
|
|
117
|
-
assert nx.dag_longest_path_length(G) == 5
|
|
118
|
-
|
|
119
|
-
def test_multigraph_unweighted(self):
|
|
120
|
-
edges = [(1, 2), (2, 3), (2, 3), (3, 4), (4, 5), (1, 3), (1, 5), (3, 5)]
|
|
121
|
-
G = nx.MultiDiGraph(edges)
|
|
122
|
-
assert nx.dag_longest_path_length(G) == 4
|
|
123
|
-
|
|
124
|
-
def test_multigraph_weighted(self):
|
|
125
|
-
G = nx.MultiDiGraph()
|
|
126
|
-
edges = [
|
|
127
|
-
(1, 2, 2),
|
|
128
|
-
(2, 3, 2),
|
|
129
|
-
(1, 3, 1),
|
|
130
|
-
(1, 3, 5),
|
|
131
|
-
(1, 3, 2),
|
|
132
|
-
]
|
|
133
|
-
G.add_weighted_edges_from(edges)
|
|
134
|
-
assert nx.dag_longest_path_length(G) == 5
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
class TestDAG:
|
|
138
|
-
@classmethod
|
|
139
|
-
def setup_class(cls):
|
|
140
|
-
pass
|
|
141
|
-
|
|
142
|
-
def test_topological_sort1(self):
|
|
143
|
-
DG = nx.DiGraph([(1, 2), (1, 3), (2, 3)])
|
|
144
|
-
|
|
145
|
-
for algorithm in [nx.topological_sort, nx.lexicographical_topological_sort]:
|
|
146
|
-
assert tuple(algorithm(DG)) == (1, 2, 3)
|
|
147
|
-
|
|
148
|
-
DG.add_edge(3, 2)
|
|
149
|
-
|
|
150
|
-
for algorithm in [nx.topological_sort, nx.lexicographical_topological_sort]:
|
|
151
|
-
pytest.raises(nx.NetworkXUnfeasible, _consume, algorithm(DG))
|
|
152
|
-
|
|
153
|
-
DG.remove_edge(2, 3)
|
|
154
|
-
|
|
155
|
-
for algorithm in [nx.topological_sort, nx.lexicographical_topological_sort]:
|
|
156
|
-
assert tuple(algorithm(DG)) == (1, 3, 2)
|
|
157
|
-
|
|
158
|
-
DG.remove_edge(3, 2)
|
|
159
|
-
|
|
160
|
-
assert tuple(nx.topological_sort(DG)) in {(1, 2, 3), (1, 3, 2)}
|
|
161
|
-
assert tuple(nx.lexicographical_topological_sort(DG)) == (1, 2, 3)
|
|
162
|
-
|
|
163
|
-
def test_is_directed_acyclic_graph(self):
|
|
164
|
-
G = nx.generators.complete_graph(2)
|
|
165
|
-
assert not nx.is_directed_acyclic_graph(G)
|
|
166
|
-
assert not nx.is_directed_acyclic_graph(G.to_directed())
|
|
167
|
-
assert not nx.is_directed_acyclic_graph(nx.Graph([(3, 4), (4, 5)]))
|
|
168
|
-
assert nx.is_directed_acyclic_graph(nx.DiGraph([(3, 4), (4, 5)]))
|
|
169
|
-
|
|
170
|
-
def test_topological_sort2(self):
|
|
171
|
-
DG = nx.DiGraph(
|
|
172
|
-
{
|
|
173
|
-
1: [2],
|
|
174
|
-
2: [3],
|
|
175
|
-
3: [4],
|
|
176
|
-
4: [5],
|
|
177
|
-
5: [1],
|
|
178
|
-
11: [12],
|
|
179
|
-
12: [13],
|
|
180
|
-
13: [14],
|
|
181
|
-
14: [15],
|
|
182
|
-
}
|
|
183
|
-
)
|
|
184
|
-
pytest.raises(nx.NetworkXUnfeasible, _consume, nx.topological_sort(DG))
|
|
185
|
-
|
|
186
|
-
assert not nx.is_directed_acyclic_graph(DG)
|
|
187
|
-
|
|
188
|
-
DG.remove_edge(1, 2)
|
|
189
|
-
_consume(nx.topological_sort(DG))
|
|
190
|
-
assert nx.is_directed_acyclic_graph(DG)
|
|
191
|
-
|
|
192
|
-
def test_topological_sort3(self):
|
|
193
|
-
DG = nx.DiGraph()
|
|
194
|
-
DG.add_edges_from([(1, i) for i in range(2, 5)])
|
|
195
|
-
DG.add_edges_from([(2, i) for i in range(5, 9)])
|
|
196
|
-
DG.add_edges_from([(6, i) for i in range(9, 12)])
|
|
197
|
-
DG.add_edges_from([(4, i) for i in range(12, 15)])
|
|
198
|
-
|
|
199
|
-
def validate(order):
|
|
200
|
-
assert isinstance(order, list)
|
|
201
|
-
assert set(order) == set(DG)
|
|
202
|
-
for u, v in combinations(order, 2):
|
|
203
|
-
assert not nx.has_path(DG, v, u)
|
|
204
|
-
|
|
205
|
-
validate(list(nx.topological_sort(DG)))
|
|
206
|
-
|
|
207
|
-
DG.add_edge(14, 1)
|
|
208
|
-
pytest.raises(nx.NetworkXUnfeasible, _consume, nx.topological_sort(DG))
|
|
209
|
-
|
|
210
|
-
def test_topological_sort4(self):
|
|
211
|
-
G = nx.Graph()
|
|
212
|
-
G.add_edge(1, 2)
|
|
213
|
-
# Only directed graphs can be topologically sorted.
|
|
214
|
-
pytest.raises(nx.NetworkXError, _consume, nx.topological_sort(G))
|
|
215
|
-
|
|
216
|
-
def test_topological_sort5(self):
|
|
217
|
-
G = nx.DiGraph()
|
|
218
|
-
G.add_edge(0, 1)
|
|
219
|
-
assert list(nx.topological_sort(G)) == [0, 1]
|
|
220
|
-
|
|
221
|
-
def test_topological_sort6(self):
|
|
222
|
-
for algorithm in [nx.topological_sort, nx.lexicographical_topological_sort]:
|
|
223
|
-
|
|
224
|
-
def runtime_error():
|
|
225
|
-
DG = nx.DiGraph([(1, 2), (2, 3), (3, 4)])
|
|
226
|
-
first = True
|
|
227
|
-
for x in algorithm(DG):
|
|
228
|
-
if first:
|
|
229
|
-
first = False
|
|
230
|
-
DG.add_edge(5 - x, 5)
|
|
231
|
-
|
|
232
|
-
def unfeasible_error():
|
|
233
|
-
DG = nx.DiGraph([(1, 2), (2, 3), (3, 4)])
|
|
234
|
-
first = True
|
|
235
|
-
for x in algorithm(DG):
|
|
236
|
-
if first:
|
|
237
|
-
first = False
|
|
238
|
-
DG.remove_node(4)
|
|
239
|
-
|
|
240
|
-
def runtime_error2():
|
|
241
|
-
DG = nx.DiGraph([(1, 2), (2, 3), (3, 4)])
|
|
242
|
-
first = True
|
|
243
|
-
for x in algorithm(DG):
|
|
244
|
-
if first:
|
|
245
|
-
first = False
|
|
246
|
-
DG.remove_node(2)
|
|
247
|
-
|
|
248
|
-
pytest.raises(RuntimeError, runtime_error)
|
|
249
|
-
pytest.raises(RuntimeError, runtime_error2)
|
|
250
|
-
pytest.raises(nx.NetworkXUnfeasible, unfeasible_error)
|
|
251
|
-
|
|
252
|
-
def test_all_topological_sorts_1(self):
|
|
253
|
-
DG = nx.DiGraph([(1, 2), (2, 3), (3, 4), (4, 5)])
|
|
254
|
-
assert list(nx.all_topological_sorts(DG)) == [[1, 2, 3, 4, 5]]
|
|
255
|
-
|
|
256
|
-
def test_all_topological_sorts_2(self):
|
|
257
|
-
DG = nx.DiGraph([(1, 3), (2, 1), (2, 4), (4, 3), (4, 5)])
|
|
258
|
-
assert sorted(nx.all_topological_sorts(DG)) == [
|
|
259
|
-
[2, 1, 4, 3, 5],
|
|
260
|
-
[2, 1, 4, 5, 3],
|
|
261
|
-
[2, 4, 1, 3, 5],
|
|
262
|
-
[2, 4, 1, 5, 3],
|
|
263
|
-
[2, 4, 5, 1, 3],
|
|
264
|
-
]
|
|
265
|
-
|
|
266
|
-
def test_all_topological_sorts_3(self):
|
|
267
|
-
def unfeasible():
|
|
268
|
-
DG = nx.DiGraph([(1, 2), (2, 3), (3, 4), (4, 2), (4, 5)])
|
|
269
|
-
# convert to list to execute generator
|
|
270
|
-
list(nx.all_topological_sorts(DG))
|
|
271
|
-
|
|
272
|
-
def not_implemented():
|
|
273
|
-
G = nx.Graph([(1, 2), (2, 3)])
|
|
274
|
-
# convert to list to execute generator
|
|
275
|
-
list(nx.all_topological_sorts(G))
|
|
276
|
-
|
|
277
|
-
def not_implemented_2():
|
|
278
|
-
G = nx.MultiGraph([(1, 2), (1, 2), (2, 3)])
|
|
279
|
-
list(nx.all_topological_sorts(G))
|
|
280
|
-
|
|
281
|
-
pytest.raises(nx.NetworkXUnfeasible, unfeasible)
|
|
282
|
-
pytest.raises(nx.NetworkXNotImplemented, not_implemented)
|
|
283
|
-
pytest.raises(nx.NetworkXNotImplemented, not_implemented_2)
|
|
284
|
-
|
|
285
|
-
def test_all_topological_sorts_4(self):
|
|
286
|
-
DG = nx.DiGraph()
|
|
287
|
-
for i in range(7):
|
|
288
|
-
DG.add_node(i)
|
|
289
|
-
assert sorted(map(list, permutations(DG.nodes))) == sorted(
|
|
290
|
-
nx.all_topological_sorts(DG)
|
|
291
|
-
)
|
|
292
|
-
|
|
293
|
-
def test_all_topological_sorts_multigraph_1(self):
|
|
294
|
-
DG = nx.MultiDiGraph([(1, 2), (1, 2), (2, 3), (3, 4), (3, 5), (3, 5), (3, 5)])
|
|
295
|
-
assert sorted(nx.all_topological_sorts(DG)) == sorted(
|
|
296
|
-
[[1, 2, 3, 4, 5], [1, 2, 3, 5, 4]]
|
|
297
|
-
)
|
|
298
|
-
|
|
299
|
-
def test_all_topological_sorts_multigraph_2(self):
|
|
300
|
-
N = 9
|
|
301
|
-
edges = []
|
|
302
|
-
for i in range(1, N):
|
|
303
|
-
edges.extend([(i, i + 1)] * i)
|
|
304
|
-
DG = nx.MultiDiGraph(edges)
|
|
305
|
-
assert list(nx.all_topological_sorts(DG)) == [list(range(1, N + 1))]
|
|
306
|
-
|
|
307
|
-
def test_ancestors(self):
|
|
308
|
-
G = nx.DiGraph()
|
|
309
|
-
ancestors = nx.algorithms.dag.ancestors
|
|
310
|
-
G.add_edges_from([(1, 2), (1, 3), (4, 2), (4, 3), (4, 5), (2, 6), (5, 6)])
|
|
311
|
-
assert ancestors(G, 6) == {1, 2, 4, 5}
|
|
312
|
-
assert ancestors(G, 3) == {1, 4}
|
|
313
|
-
assert ancestors(G, 1) == set()
|
|
314
|
-
pytest.raises(nx.NetworkXError, ancestors, G, 8)
|
|
315
|
-
|
|
316
|
-
def test_descendants(self):
|
|
317
|
-
G = nx.DiGraph()
|
|
318
|
-
descendants = nx.algorithms.dag.descendants
|
|
319
|
-
G.add_edges_from([(1, 2), (1, 3), (4, 2), (4, 3), (4, 5), (2, 6), (5, 6)])
|
|
320
|
-
assert descendants(G, 1) == {2, 3, 6}
|
|
321
|
-
assert descendants(G, 4) == {2, 3, 5, 6}
|
|
322
|
-
assert descendants(G, 3) == set()
|
|
323
|
-
pytest.raises(nx.NetworkXError, descendants, G, 8)
|
|
324
|
-
|
|
325
|
-
def test_transitive_closure(self):
|
|
326
|
-
G = nx.DiGraph([(1, 2), (2, 3), (3, 4)])
|
|
327
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
|
328
|
-
assert edges_equal(nx.transitive_closure(G).edges(), solution, directed=True)
|
|
329
|
-
G = nx.DiGraph([(1, 2), (2, 3), (2, 4)])
|
|
330
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4)]
|
|
331
|
-
assert edges_equal(nx.transitive_closure(G).edges(), solution, directed=True)
|
|
332
|
-
G = nx.DiGraph([(1, 2), (2, 3), (3, 1)])
|
|
333
|
-
solution = [(1, 2), (2, 1), (2, 3), (3, 2), (1, 3), (3, 1)]
|
|
334
|
-
soln = sorted(solution + [(n, n) for n in G])
|
|
335
|
-
assert edges_equal(
|
|
336
|
-
sorted(nx.transitive_closure(G).edges()), soln, directed=True
|
|
337
|
-
)
|
|
338
|
-
|
|
339
|
-
G = nx.Graph([(1, 2), (2, 3), (3, 4)])
|
|
340
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
|
341
|
-
assert edges_equal(sorted(nx.transitive_closure(G).edges()), solution)
|
|
342
|
-
|
|
343
|
-
G = nx.MultiGraph([(1, 2), (2, 3), (3, 4)])
|
|
344
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
|
345
|
-
assert edges_equal(sorted(nx.transitive_closure(G).edges()), solution)
|
|
346
|
-
|
|
347
|
-
G = nx.MultiDiGraph([(1, 2), (2, 3), (3, 4)])
|
|
348
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
|
349
|
-
assert edges_equal(
|
|
350
|
-
sorted(nx.transitive_closure(G).edges()), solution, directed=True
|
|
351
|
-
)
|
|
352
|
-
|
|
353
|
-
# test if edge data is copied
|
|
354
|
-
G = nx.DiGraph([(1, 2, {"a": 3}), (2, 3, {"b": 0}), (3, 4)])
|
|
355
|
-
H = nx.transitive_closure(G)
|
|
356
|
-
for u, v in G.edges():
|
|
357
|
-
assert G.get_edge_data(u, v) == H.get_edge_data(u, v)
|
|
358
|
-
|
|
359
|
-
k = 10
|
|
360
|
-
G = nx.DiGraph((i, i + 1, {"f": "b", "weight": i}) for i in range(k))
|
|
361
|
-
H = nx.transitive_closure(G)
|
|
362
|
-
for u, v in G.edges():
|
|
363
|
-
assert G.get_edge_data(u, v) == H.get_edge_data(u, v)
|
|
364
|
-
|
|
365
|
-
G = nx.Graph()
|
|
366
|
-
with pytest.raises(nx.NetworkXError):
|
|
367
|
-
nx.transitive_closure(G, reflexive="wrong input")
|
|
368
|
-
|
|
369
|
-
def test_reflexive_transitive_closure(self):
|
|
370
|
-
G = nx.DiGraph([(1, 2), (2, 3), (3, 4)])
|
|
371
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
|
372
|
-
soln = sorted(solution + [(n, n) for n in G])
|
|
373
|
-
assert edges_equal(nx.transitive_closure(G).edges(), solution, directed=True)
|
|
374
|
-
assert edges_equal(
|
|
375
|
-
nx.transitive_closure(G, False).edges(), solution, directed=True
|
|
376
|
-
)
|
|
377
|
-
assert edges_equal(nx.transitive_closure(G, True).edges(), soln, directed=True)
|
|
378
|
-
assert edges_equal(
|
|
379
|
-
nx.transitive_closure(G, None).edges(), solution, directed=True
|
|
380
|
-
)
|
|
381
|
-
|
|
382
|
-
G = nx.DiGraph([(1, 2), (2, 3), (2, 4)])
|
|
383
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4)]
|
|
384
|
-
soln = sorted(solution + [(n, n) for n in G])
|
|
385
|
-
assert edges_equal(nx.transitive_closure(G).edges(), solution, directed=True)
|
|
386
|
-
assert edges_equal(
|
|
387
|
-
nx.transitive_closure(G, False).edges(), solution, directed=True
|
|
388
|
-
)
|
|
389
|
-
assert edges_equal(nx.transitive_closure(G, True).edges(), soln, directed=True)
|
|
390
|
-
assert edges_equal(
|
|
391
|
-
nx.transitive_closure(G, None).edges(), solution, directed=True
|
|
392
|
-
)
|
|
393
|
-
|
|
394
|
-
G = nx.DiGraph([(1, 2), (2, 3), (3, 1)])
|
|
395
|
-
solution = sorted([(1, 2), (2, 1), (2, 3), (3, 2), (1, 3), (3, 1)])
|
|
396
|
-
soln = sorted(solution + [(n, n) for n in G])
|
|
397
|
-
assert edges_equal(
|
|
398
|
-
sorted(nx.transitive_closure(G).edges()), soln, directed=True
|
|
399
|
-
)
|
|
400
|
-
assert edges_equal(
|
|
401
|
-
sorted(nx.transitive_closure(G, False).edges()), soln, directed=True
|
|
402
|
-
)
|
|
403
|
-
assert edges_equal(
|
|
404
|
-
sorted(nx.transitive_closure(G, None).edges()), solution, directed=True
|
|
405
|
-
)
|
|
406
|
-
assert edges_equal(
|
|
407
|
-
sorted(nx.transitive_closure(G, True).edges()), soln, directed=True
|
|
408
|
-
)
|
|
409
|
-
|
|
410
|
-
G = nx.Graph([(1, 2), (2, 3), (3, 4)])
|
|
411
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
|
412
|
-
soln = sorted(solution + [(n, n) for n in G])
|
|
413
|
-
assert edges_equal(nx.transitive_closure(G).edges(), solution)
|
|
414
|
-
assert edges_equal(nx.transitive_closure(G, False).edges(), solution)
|
|
415
|
-
assert edges_equal(nx.transitive_closure(G, True).edges(), soln)
|
|
416
|
-
assert edges_equal(nx.transitive_closure(G, None).edges(), solution)
|
|
417
|
-
|
|
418
|
-
G = nx.MultiGraph([(1, 2), (2, 3), (3, 4)])
|
|
419
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
|
420
|
-
soln = sorted(solution + [(n, n) for n in G])
|
|
421
|
-
assert edges_equal(nx.transitive_closure(G).edges(), solution)
|
|
422
|
-
assert edges_equal(nx.transitive_closure(G, False).edges(), solution)
|
|
423
|
-
assert edges_equal(nx.transitive_closure(G, True).edges(), soln)
|
|
424
|
-
assert edges_equal(nx.transitive_closure(G, None).edges(), solution)
|
|
425
|
-
|
|
426
|
-
G = nx.MultiDiGraph([(1, 2), (2, 3), (3, 4)])
|
|
427
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
|
428
|
-
soln = sorted(solution + [(n, n) for n in G])
|
|
429
|
-
assert edges_equal(nx.transitive_closure(G).edges(), solution, directed=True)
|
|
430
|
-
assert edges_equal(
|
|
431
|
-
nx.transitive_closure(G, False).edges(), solution, directed=True
|
|
432
|
-
)
|
|
433
|
-
assert edges_equal(nx.transitive_closure(G, True).edges(), soln, directed=True)
|
|
434
|
-
assert edges_equal(
|
|
435
|
-
nx.transitive_closure(G, None).edges(), solution, directed=True
|
|
436
|
-
)
|
|
437
|
-
|
|
438
|
-
def test_transitive_closure_dag(self):
|
|
439
|
-
G = nx.DiGraph([(1, 2), (2, 3), (3, 4)])
|
|
440
|
-
transitive_closure = nx.algorithms.dag.transitive_closure_dag
|
|
441
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
|
442
|
-
assert edges_equal(transitive_closure(G).edges(), solution, directed=True)
|
|
443
|
-
G = nx.DiGraph([(1, 2), (2, 3), (2, 4)])
|
|
444
|
-
solution = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4)]
|
|
445
|
-
assert edges_equal(transitive_closure(G).edges(), solution, directed=True)
|
|
446
|
-
G = nx.Graph([(1, 2), (2, 3), (3, 4)])
|
|
447
|
-
pytest.raises(nx.NetworkXNotImplemented, transitive_closure, G)
|
|
448
|
-
|
|
449
|
-
# test if edge data is copied
|
|
450
|
-
G = nx.DiGraph([(1, 2, {"a": 3}), (2, 3, {"b": 0}), (3, 4)])
|
|
451
|
-
H = transitive_closure(G)
|
|
452
|
-
for u, v in G.edges():
|
|
453
|
-
assert G.get_edge_data(u, v) == H.get_edge_data(u, v)
|
|
454
|
-
|
|
455
|
-
k = 10
|
|
456
|
-
G = nx.DiGraph((i, i + 1, {"foo": "bar", "weight": i}) for i in range(k))
|
|
457
|
-
H = transitive_closure(G)
|
|
458
|
-
for u, v in G.edges():
|
|
459
|
-
assert G.get_edge_data(u, v) == H.get_edge_data(u, v)
|
|
460
|
-
|
|
461
|
-
def test_transitive_reduction(self):
|
|
462
|
-
G = nx.DiGraph([(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)])
|
|
463
|
-
transitive_reduction = nx.algorithms.dag.transitive_reduction
|
|
464
|
-
solution = [(1, 2), (2, 3), (3, 4)]
|
|
465
|
-
assert edges_equal(transitive_reduction(G).edges(), solution, directed=True)
|
|
466
|
-
G = nx.DiGraph([(1, 2), (1, 3), (1, 4), (2, 3), (2, 4)])
|
|
467
|
-
transitive_reduction = nx.algorithms.dag.transitive_reduction
|
|
468
|
-
solution = [(1, 2), (2, 3), (2, 4)]
|
|
469
|
-
assert edges_equal(transitive_reduction(G).edges(), solution, directed=True)
|
|
470
|
-
G = nx.Graph([(1, 2), (2, 3), (3, 4)])
|
|
471
|
-
pytest.raises(nx.NetworkXNotImplemented, transitive_reduction, G)
|
|
472
|
-
|
|
473
|
-
def _check_antichains(self, solution, result):
|
|
474
|
-
sol = [frozenset(a) for a in solution]
|
|
475
|
-
res = [frozenset(a) for a in result]
|
|
476
|
-
assert set(sol) == set(res)
|
|
477
|
-
|
|
478
|
-
def test_antichains(self):
|
|
479
|
-
antichains = nx.algorithms.dag.antichains
|
|
480
|
-
G = nx.DiGraph([(1, 2), (2, 3), (3, 4)])
|
|
481
|
-
solution = [[], [4], [3], [2], [1]]
|
|
482
|
-
self._check_antichains(list(antichains(G)), solution)
|
|
483
|
-
G = nx.DiGraph([(1, 2), (2, 3), (2, 4), (3, 5), (5, 6), (5, 7)])
|
|
484
|
-
solution = [
|
|
485
|
-
[],
|
|
486
|
-
[4],
|
|
487
|
-
[7],
|
|
488
|
-
[7, 4],
|
|
489
|
-
[6],
|
|
490
|
-
[6, 4],
|
|
491
|
-
[6, 7],
|
|
492
|
-
[6, 7, 4],
|
|
493
|
-
[5],
|
|
494
|
-
[5, 4],
|
|
495
|
-
[3],
|
|
496
|
-
[3, 4],
|
|
497
|
-
[2],
|
|
498
|
-
[1],
|
|
499
|
-
]
|
|
500
|
-
self._check_antichains(list(antichains(G)), solution)
|
|
501
|
-
G = nx.DiGraph([(1, 2), (1, 3), (3, 4), (3, 5), (5, 6)])
|
|
502
|
-
solution = [
|
|
503
|
-
[],
|
|
504
|
-
[6],
|
|
505
|
-
[5],
|
|
506
|
-
[4],
|
|
507
|
-
[4, 6],
|
|
508
|
-
[4, 5],
|
|
509
|
-
[3],
|
|
510
|
-
[2],
|
|
511
|
-
[2, 6],
|
|
512
|
-
[2, 5],
|
|
513
|
-
[2, 4],
|
|
514
|
-
[2, 4, 6],
|
|
515
|
-
[2, 4, 5],
|
|
516
|
-
[2, 3],
|
|
517
|
-
[1],
|
|
518
|
-
]
|
|
519
|
-
self._check_antichains(list(antichains(G)), solution)
|
|
520
|
-
G = nx.DiGraph({0: [1, 2], 1: [4], 2: [3], 3: [4]})
|
|
521
|
-
solution = [[], [4], [3], [2], [1], [1, 3], [1, 2], [0]]
|
|
522
|
-
self._check_antichains(list(antichains(G)), solution)
|
|
523
|
-
G = nx.DiGraph()
|
|
524
|
-
self._check_antichains(list(antichains(G)), [[]])
|
|
525
|
-
G = nx.DiGraph()
|
|
526
|
-
G.add_nodes_from([0, 1, 2])
|
|
527
|
-
solution = [[], [0], [1], [1, 0], [2], [2, 0], [2, 1], [2, 1, 0]]
|
|
528
|
-
self._check_antichains(list(antichains(G)), solution)
|
|
529
|
-
|
|
530
|
-
def f(x):
|
|
531
|
-
return list(antichains(x))
|
|
532
|
-
|
|
533
|
-
G = nx.Graph([(1, 2), (2, 3), (3, 4)])
|
|
534
|
-
pytest.raises(nx.NetworkXNotImplemented, f, G)
|
|
535
|
-
G = nx.DiGraph([(1, 2), (2, 3), (3, 1)])
|
|
536
|
-
pytest.raises(nx.NetworkXUnfeasible, f, G)
|
|
537
|
-
|
|
538
|
-
def test_lexicographical_topological_sort(self):
|
|
539
|
-
G = nx.DiGraph([(1, 2), (2, 3), (1, 4), (1, 5), (2, 6)])
|
|
540
|
-
assert list(nx.lexicographical_topological_sort(G)) == [1, 2, 3, 4, 5, 6]
|
|
541
|
-
assert list(nx.lexicographical_topological_sort(G, key=lambda x: x)) == [
|
|
542
|
-
1,
|
|
543
|
-
2,
|
|
544
|
-
3,
|
|
545
|
-
4,
|
|
546
|
-
5,
|
|
547
|
-
6,
|
|
548
|
-
]
|
|
549
|
-
assert list(nx.lexicographical_topological_sort(G, key=lambda x: -x)) == [
|
|
550
|
-
1,
|
|
551
|
-
5,
|
|
552
|
-
4,
|
|
553
|
-
2,
|
|
554
|
-
6,
|
|
555
|
-
3,
|
|
556
|
-
]
|
|
557
|
-
|
|
558
|
-
def test_lexicographical_topological_sort2(self):
|
|
559
|
-
"""
|
|
560
|
-
Check the case of two or more nodes with same key value.
|
|
561
|
-
Want to avoid exception raised due to comparing nodes directly.
|
|
562
|
-
See Issue #3493
|
|
563
|
-
"""
|
|
564
|
-
|
|
565
|
-
class Test_Node:
|
|
566
|
-
def __init__(self, n):
|
|
567
|
-
self.label = n
|
|
568
|
-
self.priority = 1
|
|
569
|
-
|
|
570
|
-
def __repr__(self):
|
|
571
|
-
return f"Node({self.label})"
|
|
572
|
-
|
|
573
|
-
def sorting_key(node):
|
|
574
|
-
return node.priority
|
|
575
|
-
|
|
576
|
-
test_nodes = [Test_Node(n) for n in range(4)]
|
|
577
|
-
G = nx.DiGraph()
|
|
578
|
-
edges = [(0, 1), (0, 2), (0, 3), (2, 3)]
|
|
579
|
-
G.add_edges_from((test_nodes[a], test_nodes[b]) for a, b in edges)
|
|
580
|
-
|
|
581
|
-
sorting = list(nx.lexicographical_topological_sort(G, key=sorting_key))
|
|
582
|
-
assert sorting == test_nodes
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
def test_topological_generations():
|
|
586
|
-
G = nx.DiGraph(
|
|
587
|
-
{1: [2, 3], 2: [4, 5], 3: [7], 4: [], 5: [6, 7], 6: [], 7: []}
|
|
588
|
-
).reverse()
|
|
589
|
-
# order within each generation is inconsequential
|
|
590
|
-
generations = [sorted(gen) for gen in nx.topological_generations(G)]
|
|
591
|
-
expected = [[4, 6, 7], [3, 5], [2], [1]]
|
|
592
|
-
assert generations == expected
|
|
593
|
-
|
|
594
|
-
MG = nx.MultiDiGraph(G.edges)
|
|
595
|
-
MG.add_edge(2, 1)
|
|
596
|
-
generations = [sorted(gen) for gen in nx.topological_generations(MG)]
|
|
597
|
-
assert generations == expected
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
def test_topological_generations_empty():
|
|
601
|
-
G = nx.DiGraph()
|
|
602
|
-
assert list(nx.topological_generations(G)) == []
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
def test_topological_generations_cycle():
|
|
606
|
-
G = nx.DiGraph([[2, 1], [3, 1], [1, 2]])
|
|
607
|
-
with pytest.raises(nx.NetworkXUnfeasible):
|
|
608
|
-
list(nx.topological_generations(G))
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
def test_is_aperiodic_cycle():
|
|
612
|
-
G = nx.DiGraph()
|
|
613
|
-
nx.add_cycle(G, [1, 2, 3, 4])
|
|
614
|
-
assert not nx.is_aperiodic(G)
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
def test_is_aperiodic_cycle2():
|
|
618
|
-
G = nx.DiGraph()
|
|
619
|
-
nx.add_cycle(G, [1, 2, 3, 4])
|
|
620
|
-
nx.add_cycle(G, [3, 4, 5, 6, 7])
|
|
621
|
-
assert nx.is_aperiodic(G)
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
def test_is_aperiodic_cycle3():
|
|
625
|
-
G = nx.DiGraph()
|
|
626
|
-
nx.add_cycle(G, [1, 2, 3, 4])
|
|
627
|
-
nx.add_cycle(G, [3, 4, 5, 6])
|
|
628
|
-
assert not nx.is_aperiodic(G)
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
def test_is_aperiodic_cycle4():
|
|
632
|
-
G = nx.DiGraph()
|
|
633
|
-
nx.add_cycle(G, [1, 2, 3, 4])
|
|
634
|
-
G.add_edge(1, 3)
|
|
635
|
-
assert nx.is_aperiodic(G)
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
def test_is_aperiodic_selfloop():
|
|
639
|
-
G = nx.DiGraph()
|
|
640
|
-
nx.add_cycle(G, [1, 2, 3, 4])
|
|
641
|
-
G.add_edge(1, 1)
|
|
642
|
-
assert nx.is_aperiodic(G)
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
def test_is_aperiodic_null_graph_raises():
|
|
646
|
-
G = nx.DiGraph()
|
|
647
|
-
pytest.raises(nx.NetworkXPointlessConcept, nx.is_aperiodic, G)
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
def test_is_aperiodic_undirected_raises():
|
|
651
|
-
G = nx.Graph([(1, 2), (2, 3), (3, 1)])
|
|
652
|
-
pytest.raises(nx.NetworkXError, nx.is_aperiodic, G)
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
def test_is_aperiodic_disconnected_raises():
|
|
656
|
-
G = nx.DiGraph()
|
|
657
|
-
nx.add_cycle(G, [0, 1, 2])
|
|
658
|
-
G.add_edge(3, 3)
|
|
659
|
-
pytest.raises(nx.NetworkXError, nx.is_aperiodic, G)
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
def test_is_aperiodic_weakly_connected_raises():
|
|
663
|
-
G = nx.DiGraph([(1, 2), (2, 3)])
|
|
664
|
-
pytest.raises(nx.NetworkXError, nx.is_aperiodic, G)
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
def test_is_aperiodic_empty_graph():
|
|
668
|
-
G = nx.empty_graph(create_using=nx.DiGraph)
|
|
669
|
-
with pytest.raises(nx.NetworkXPointlessConcept, match="Graph has no nodes."):
|
|
670
|
-
nx.is_aperiodic(G)
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
def test_is_aperiodic_bipartite():
|
|
674
|
-
# Bipartite graph
|
|
675
|
-
G = nx.DiGraph(nx.davis_southern_women_graph())
|
|
676
|
-
assert not nx.is_aperiodic(G)
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
def test_is_aperiodic_single_node():
|
|
680
|
-
G = nx.DiGraph()
|
|
681
|
-
G.add_node(0)
|
|
682
|
-
assert not nx.is_aperiodic(G)
|
|
683
|
-
G.add_edge(0, 0)
|
|
684
|
-
assert nx.is_aperiodic(G)
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
class TestDagToBranching:
|
|
688
|
-
"""Unit tests for the :func:`networkx.dag_to_branching` function."""
|
|
689
|
-
|
|
690
|
-
def test_single_root(self):
|
|
691
|
-
"""Tests that a directed acyclic graph with a single degree
|
|
692
|
-
zero node produces an arborescence.
|
|
693
|
-
|
|
694
|
-
"""
|
|
695
|
-
G = nx.DiGraph([(0, 1), (0, 2), (1, 3), (2, 3)])
|
|
696
|
-
B = nx.dag_to_branching(G)
|
|
697
|
-
expected = nx.DiGraph([(0, 1), (1, 3), (0, 2), (2, 4)])
|
|
698
|
-
assert nx.is_arborescence(B)
|
|
699
|
-
assert nx.is_isomorphic(B, expected)
|
|
700
|
-
|
|
701
|
-
def test_multiple_roots(self):
|
|
702
|
-
"""Tests that a directed acyclic graph with multiple degree zero
|
|
703
|
-
nodes creates an arborescence with multiple (weakly) connected
|
|
704
|
-
components.
|
|
705
|
-
|
|
706
|
-
"""
|
|
707
|
-
G = nx.DiGraph([(0, 1), (0, 2), (1, 3), (2, 3), (5, 2)])
|
|
708
|
-
B = nx.dag_to_branching(G)
|
|
709
|
-
expected = nx.DiGraph([(0, 1), (1, 3), (0, 2), (2, 4), (5, 6), (6, 7)])
|
|
710
|
-
assert nx.is_branching(B)
|
|
711
|
-
assert not nx.is_arborescence(B)
|
|
712
|
-
assert nx.is_isomorphic(B, expected)
|
|
713
|
-
|
|
714
|
-
# # Attributes are not copied by this function. If they were, this would
|
|
715
|
-
# # be a good test to uncomment.
|
|
716
|
-
# def test_copy_attributes(self):
|
|
717
|
-
# """Tests that node attributes are copied in the branching."""
|
|
718
|
-
# G = nx.DiGraph([(0, 1), (0, 2), (1, 3), (2, 3)])
|
|
719
|
-
# for v in G:
|
|
720
|
-
# G.node[v]['label'] = str(v)
|
|
721
|
-
# B = nx.dag_to_branching(G)
|
|
722
|
-
# # Determine the root node of the branching.
|
|
723
|
-
# root = next(v for v, d in B.in_degree() if d == 0)
|
|
724
|
-
# assert_equal(B.node[root]['label'], '0')
|
|
725
|
-
# children = B[root]
|
|
726
|
-
# # Get the left and right children, nodes 1 and 2, respectively.
|
|
727
|
-
# left, right = sorted(children, key=lambda v: B.node[v]['label'])
|
|
728
|
-
# assert_equal(B.node[left]['label'], '1')
|
|
729
|
-
# assert_equal(B.node[right]['label'], '2')
|
|
730
|
-
# # Get the left grandchild.
|
|
731
|
-
# children = B[left]
|
|
732
|
-
# assert_equal(len(children), 1)
|
|
733
|
-
# left_grandchild = arbitrary_element(children)
|
|
734
|
-
# assert_equal(B.node[left_grandchild]['label'], '3')
|
|
735
|
-
# # Get the right grandchild.
|
|
736
|
-
# children = B[right]
|
|
737
|
-
# assert_equal(len(children), 1)
|
|
738
|
-
# right_grandchild = arbitrary_element(children)
|
|
739
|
-
# assert_equal(B.node[right_grandchild]['label'], '3')
|
|
740
|
-
|
|
741
|
-
def test_already_arborescence(self):
|
|
742
|
-
"""Tests that a directed acyclic graph that is already an
|
|
743
|
-
arborescence produces an isomorphic arborescence as output.
|
|
744
|
-
|
|
745
|
-
"""
|
|
746
|
-
A = nx.balanced_tree(2, 2, create_using=nx.DiGraph())
|
|
747
|
-
B = nx.dag_to_branching(A)
|
|
748
|
-
assert nx.is_isomorphic(A, B)
|
|
749
|
-
|
|
750
|
-
def test_already_branching(self):
|
|
751
|
-
"""Tests that a directed acyclic graph that is already a
|
|
752
|
-
branching produces an isomorphic branching as output.
|
|
753
|
-
|
|
754
|
-
"""
|
|
755
|
-
T1 = nx.balanced_tree(2, 2, create_using=nx.DiGraph())
|
|
756
|
-
T2 = nx.balanced_tree(2, 2, create_using=nx.DiGraph())
|
|
757
|
-
G = nx.disjoint_union(T1, T2)
|
|
758
|
-
B = nx.dag_to_branching(G)
|
|
759
|
-
assert nx.is_isomorphic(G, B)
|
|
760
|
-
|
|
761
|
-
def test_not_acyclic(self):
|
|
762
|
-
"""Tests that a non-acyclic graph causes an exception."""
|
|
763
|
-
with pytest.raises(nx.HasACycle):
|
|
764
|
-
G = nx.DiGraph(pairwise("abc", cyclic=True))
|
|
765
|
-
nx.dag_to_branching(G)
|
|
766
|
-
|
|
767
|
-
def test_undirected(self):
|
|
768
|
-
with pytest.raises(nx.NetworkXNotImplemented):
|
|
769
|
-
nx.dag_to_branching(nx.Graph())
|
|
770
|
-
|
|
771
|
-
def test_multigraph(self):
|
|
772
|
-
with pytest.raises(nx.NetworkXNotImplemented):
|
|
773
|
-
nx.dag_to_branching(nx.MultiGraph())
|
|
774
|
-
|
|
775
|
-
def test_multidigraph(self):
|
|
776
|
-
with pytest.raises(nx.NetworkXNotImplemented):
|
|
777
|
-
nx.dag_to_branching(nx.MultiDiGraph())
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
def test_ancestors_descendants_undirected():
|
|
781
|
-
"""Regression test to ensure ancestors and descendants work as expected on
|
|
782
|
-
undirected graphs."""
|
|
783
|
-
G = nx.path_graph(5)
|
|
784
|
-
nx.ancestors(G, 2) == nx.descendants(G, 2) == {0, 1, 3, 4}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
def test_v_structures_raise():
|
|
788
|
-
G = nx.Graph()
|
|
789
|
-
with pytest.raises(nx.NetworkXNotImplemented, match="for undirected type"):
|
|
790
|
-
nx.dag.v_structures(G)
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
@pytest.mark.parametrize(
|
|
794
|
-
("edgelist", "expected"),
|
|
795
|
-
(
|
|
796
|
-
(
|
|
797
|
-
[(0, 1), (0, 2), (3, 2)],
|
|
798
|
-
{(0, 2, 3)},
|
|
799
|
-
),
|
|
800
|
-
(
|
|
801
|
-
[("A", "B"), ("C", "B"), ("D", "G"), ("D", "E"), ("G", "E")],
|
|
802
|
-
{("A", "B", "C")},
|
|
803
|
-
),
|
|
804
|
-
([(0, 1), (2, 1), (0, 2)], set()), # adjacent parents case: see gh-7385
|
|
805
|
-
),
|
|
806
|
-
)
|
|
807
|
-
def test_v_structures(edgelist, expected):
|
|
808
|
-
G = nx.DiGraph(edgelist)
|
|
809
|
-
v_structs = set(nx.dag.v_structures(G))
|
|
810
|
-
assert v_structs == expected
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
def test_colliders_raise():
|
|
814
|
-
G = nx.Graph()
|
|
815
|
-
with pytest.raises(nx.NetworkXNotImplemented, match="for undirected type"):
|
|
816
|
-
nx.dag.colliders(G)
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
@pytest.mark.parametrize(
|
|
820
|
-
("edgelist", "expected"),
|
|
821
|
-
(
|
|
822
|
-
(
|
|
823
|
-
[(0, 1), (0, 2), (3, 2)],
|
|
824
|
-
{(0, 2, 3)},
|
|
825
|
-
),
|
|
826
|
-
(
|
|
827
|
-
[("A", "B"), ("C", "B"), ("D", "G"), ("D", "E"), ("G", "E")],
|
|
828
|
-
{("A", "B", "C"), ("D", "E", "G")},
|
|
829
|
-
),
|
|
830
|
-
),
|
|
831
|
-
)
|
|
832
|
-
def test_colliders(edgelist, expected):
|
|
833
|
-
G = nx.DiGraph(edgelist)
|
|
834
|
-
colliders = set(nx.dag.colliders(G))
|
|
835
|
-
assert colliders == expected
|