okstra 0.114.0 → 0.116.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/kr/architecture.md +2 -2
- package/docs/kr/follow-ups/2026-07-10-final-report-option-3.md +51 -0
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/agents/workers/report-writer-worker.md +1 -0
- package/runtime/prompts/launch.template.md +34 -0
- package/runtime/prompts/lead/convergence.md +2 -0
- package/runtime/prompts/lead/okstra-lead-contract.md +1 -1
- package/runtime/prompts/lead/report-writer.md +1 -1
- package/runtime/prompts/profiles/implementation-planning.md +1 -0
- package/runtime/python/okstra_ctl/implementation_stage.py +46 -39
- package/runtime/python/okstra_ctl/incremental_carry.py +70 -0
- package/runtime/python/okstra_ctl/incremental_scope.py +89 -0
- package/runtime/python/okstra_ctl/report_views.py +151 -12
- package/runtime/python/okstra_ctl/run.py +24 -24
- package/runtime/python/okstra_ctl/stage_targets.py +26 -0
- 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 +39 -0
- package/runtime/templates/reports/final-report.template.md +27 -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-run.py +50 -0
- package/src/cli-registry.mjs +14 -0
- package/src/commands/execute/incremental-carry.mjs +20 -0
- package/src/commands/execute/incremental-scope.mjs +20 -0
- 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,110 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
pytest.importorskip("numpy")
|
|
4
|
-
pytest.importorskip("scipy")
|
|
5
|
-
|
|
6
|
-
import networkx as nx
|
|
7
|
-
from networkx.algorithms.centrality.subgraph_alg import (
|
|
8
|
-
communicability_betweenness_centrality,
|
|
9
|
-
estrada_index,
|
|
10
|
-
subgraph_centrality,
|
|
11
|
-
subgraph_centrality_exp,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class TestSubgraph:
|
|
16
|
-
def test_subgraph_centrality(self):
|
|
17
|
-
answer = {0: 1.5430806348152433, 1: 1.5430806348152433}
|
|
18
|
-
result = subgraph_centrality(nx.path_graph(2))
|
|
19
|
-
for k, v in result.items():
|
|
20
|
-
assert answer[k] == pytest.approx(v, abs=1e-7)
|
|
21
|
-
|
|
22
|
-
answer1 = {
|
|
23
|
-
"1": 1.6445956054135658,
|
|
24
|
-
"Albert": 2.4368257358712189,
|
|
25
|
-
"Aric": 2.4368257358712193,
|
|
26
|
-
"Dan": 3.1306328496328168,
|
|
27
|
-
"Franck": 2.3876142275231915,
|
|
28
|
-
}
|
|
29
|
-
G1 = nx.Graph(
|
|
30
|
-
[
|
|
31
|
-
("Franck", "Aric"),
|
|
32
|
-
("Aric", "Dan"),
|
|
33
|
-
("Dan", "Albert"),
|
|
34
|
-
("Albert", "Franck"),
|
|
35
|
-
("Dan", "1"),
|
|
36
|
-
("Franck", "Albert"),
|
|
37
|
-
]
|
|
38
|
-
)
|
|
39
|
-
result1 = subgraph_centrality(G1)
|
|
40
|
-
for k, v in result1.items():
|
|
41
|
-
assert answer1[k] == pytest.approx(v, abs=1e-7)
|
|
42
|
-
result1 = subgraph_centrality_exp(G1)
|
|
43
|
-
for k, v in result1.items():
|
|
44
|
-
assert answer1[k] == pytest.approx(v, abs=1e-7)
|
|
45
|
-
|
|
46
|
-
def test_subgraph_centrality_big_graph(self):
|
|
47
|
-
g199 = nx.complete_graph(199)
|
|
48
|
-
g200 = nx.complete_graph(200)
|
|
49
|
-
|
|
50
|
-
comm199 = nx.subgraph_centrality(g199)
|
|
51
|
-
comm199_exp = nx.subgraph_centrality_exp(g199)
|
|
52
|
-
|
|
53
|
-
comm200 = nx.subgraph_centrality(g200)
|
|
54
|
-
comm200_exp = nx.subgraph_centrality_exp(g200)
|
|
55
|
-
|
|
56
|
-
def test_communicability_betweenness_centrality_small(self):
|
|
57
|
-
result = communicability_betweenness_centrality(nx.path_graph(2))
|
|
58
|
-
assert result == {0: 0, 1: 0}
|
|
59
|
-
|
|
60
|
-
result = communicability_betweenness_centrality(nx.path_graph(1))
|
|
61
|
-
assert result == {0: 0}
|
|
62
|
-
|
|
63
|
-
result = communicability_betweenness_centrality(nx.path_graph(0))
|
|
64
|
-
assert result == {}
|
|
65
|
-
|
|
66
|
-
answer = {0: 0.1411224421177313, 1: 1.0, 2: 0.1411224421177313}
|
|
67
|
-
result = communicability_betweenness_centrality(nx.path_graph(3))
|
|
68
|
-
for k, v in result.items():
|
|
69
|
-
assert answer[k] == pytest.approx(v, abs=1e-7)
|
|
70
|
-
|
|
71
|
-
result = communicability_betweenness_centrality(nx.complete_graph(3))
|
|
72
|
-
for k, v in result.items():
|
|
73
|
-
assert 0.49786143366223296 == pytest.approx(v, abs=1e-7)
|
|
74
|
-
|
|
75
|
-
def test_communicability_betweenness_centrality(self):
|
|
76
|
-
answer = {
|
|
77
|
-
0: 0.07017447951484615,
|
|
78
|
-
1: 0.71565598701107991,
|
|
79
|
-
2: 0.71565598701107991,
|
|
80
|
-
3: 0.07017447951484615,
|
|
81
|
-
}
|
|
82
|
-
result = communicability_betweenness_centrality(nx.path_graph(4))
|
|
83
|
-
for k, v in result.items():
|
|
84
|
-
assert answer[k] == pytest.approx(v, abs=1e-7)
|
|
85
|
-
|
|
86
|
-
answer1 = {
|
|
87
|
-
"1": 0.060039074193949521,
|
|
88
|
-
"Albert": 0.315470761661372,
|
|
89
|
-
"Aric": 0.31547076166137211,
|
|
90
|
-
"Dan": 0.68297778678316201,
|
|
91
|
-
"Franck": 0.21977926617449497,
|
|
92
|
-
}
|
|
93
|
-
G1 = nx.Graph(
|
|
94
|
-
[
|
|
95
|
-
("Franck", "Aric"),
|
|
96
|
-
("Aric", "Dan"),
|
|
97
|
-
("Dan", "Albert"),
|
|
98
|
-
("Albert", "Franck"),
|
|
99
|
-
("Dan", "1"),
|
|
100
|
-
("Franck", "Albert"),
|
|
101
|
-
]
|
|
102
|
-
)
|
|
103
|
-
result1 = communicability_betweenness_centrality(G1)
|
|
104
|
-
for k, v in result1.items():
|
|
105
|
-
assert answer1[k] == pytest.approx(v, abs=1e-7)
|
|
106
|
-
|
|
107
|
-
def test_estrada_index(self):
|
|
108
|
-
answer = 1041.2470334195475
|
|
109
|
-
result = estrada_index(nx.karate_club_graph())
|
|
110
|
-
assert answer == pytest.approx(result, abs=1e-7)
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
"""Test trophic levels, trophic differences and trophic coherence"""
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
import networkx as nx
|
|
6
|
-
|
|
7
|
-
np = pytest.importorskip("numpy")
|
|
8
|
-
pytest.importorskip("scipy")
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def test_trophic_levels():
|
|
12
|
-
"""Trivial example"""
|
|
13
|
-
G = nx.DiGraph()
|
|
14
|
-
G.add_edge("a", "b")
|
|
15
|
-
G.add_edge("b", "c")
|
|
16
|
-
|
|
17
|
-
d = nx.trophic_levels(G)
|
|
18
|
-
assert d == {"a": 1, "b": 2, "c": 3}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_trophic_levels_levine():
|
|
22
|
-
"""Example from Figure 5 in Stephen Levine (1980) J. theor. Biol. 83,
|
|
23
|
-
195-207
|
|
24
|
-
"""
|
|
25
|
-
S = nx.DiGraph()
|
|
26
|
-
S.add_edge(1, 2, weight=1.0)
|
|
27
|
-
S.add_edge(1, 3, weight=0.2)
|
|
28
|
-
S.add_edge(1, 4, weight=0.8)
|
|
29
|
-
S.add_edge(2, 3, weight=0.2)
|
|
30
|
-
S.add_edge(2, 5, weight=0.3)
|
|
31
|
-
S.add_edge(4, 3, weight=0.6)
|
|
32
|
-
S.add_edge(4, 5, weight=0.7)
|
|
33
|
-
S.add_edge(5, 4, weight=0.2)
|
|
34
|
-
|
|
35
|
-
# save copy for later, test intermediate implementation details first
|
|
36
|
-
S2 = S.copy()
|
|
37
|
-
|
|
38
|
-
# drop nodes of in-degree zero
|
|
39
|
-
z = [nid for nid, d in S.in_degree if d == 0]
|
|
40
|
-
for nid in z:
|
|
41
|
-
S.remove_node(nid)
|
|
42
|
-
|
|
43
|
-
# find adjacency matrix
|
|
44
|
-
q = nx.linalg.graphmatrix.adjacency_matrix(S).T
|
|
45
|
-
|
|
46
|
-
# fmt: off
|
|
47
|
-
expected_q = np.array([
|
|
48
|
-
[0, 0, 0., 0],
|
|
49
|
-
[0.2, 0, 0.6, 0],
|
|
50
|
-
[0, 0, 0, 0.2],
|
|
51
|
-
[0.3, 0, 0.7, 0]
|
|
52
|
-
])
|
|
53
|
-
# fmt: on
|
|
54
|
-
assert np.array_equal(q.todense(), expected_q)
|
|
55
|
-
|
|
56
|
-
# must be square, size of number of nodes
|
|
57
|
-
assert len(q.shape) == 2
|
|
58
|
-
assert q.shape[0] == q.shape[1]
|
|
59
|
-
assert q.shape[0] == len(S)
|
|
60
|
-
|
|
61
|
-
nn = q.shape[0]
|
|
62
|
-
|
|
63
|
-
i = np.eye(nn)
|
|
64
|
-
n = np.linalg.inv(i - q)
|
|
65
|
-
y = np.asarray(n) @ np.ones(nn)
|
|
66
|
-
|
|
67
|
-
expected_y = np.array([1, 2.07906977, 1.46511628, 2.3255814])
|
|
68
|
-
assert np.allclose(y, expected_y)
|
|
69
|
-
|
|
70
|
-
expected_d = {1: 1, 2: 2, 3: 3.07906977, 4: 2.46511628, 5: 3.3255814}
|
|
71
|
-
|
|
72
|
-
d = nx.trophic_levels(S2)
|
|
73
|
-
|
|
74
|
-
for nid, level in d.items():
|
|
75
|
-
expected_level = expected_d[nid]
|
|
76
|
-
assert expected_level == pytest.approx(level, abs=1e-7)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def test_trophic_levels_simple():
|
|
80
|
-
matrix_a = np.array([[0, 0], [1, 0]])
|
|
81
|
-
G = nx.from_numpy_array(matrix_a, create_using=nx.DiGraph)
|
|
82
|
-
d = nx.trophic_levels(G)
|
|
83
|
-
assert d[0] == pytest.approx(2, abs=1e-7)
|
|
84
|
-
assert d[1] == pytest.approx(1, abs=1e-7)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def test_trophic_levels_more_complex():
|
|
88
|
-
# fmt: off
|
|
89
|
-
matrix = np.array([
|
|
90
|
-
[0, 1, 0, 0],
|
|
91
|
-
[0, 0, 1, 0],
|
|
92
|
-
[0, 0, 0, 1],
|
|
93
|
-
[0, 0, 0, 0]
|
|
94
|
-
])
|
|
95
|
-
# fmt: on
|
|
96
|
-
G = nx.from_numpy_array(matrix, create_using=nx.DiGraph)
|
|
97
|
-
d = nx.trophic_levels(G)
|
|
98
|
-
expected_result = [1, 2, 3, 4]
|
|
99
|
-
for ind in range(4):
|
|
100
|
-
assert d[ind] == pytest.approx(expected_result[ind], abs=1e-7)
|
|
101
|
-
|
|
102
|
-
# fmt: off
|
|
103
|
-
matrix = np.array([
|
|
104
|
-
[0, 1, 1, 0],
|
|
105
|
-
[0, 0, 1, 1],
|
|
106
|
-
[0, 0, 0, 1],
|
|
107
|
-
[0, 0, 0, 0]
|
|
108
|
-
])
|
|
109
|
-
# fmt: on
|
|
110
|
-
G = nx.from_numpy_array(matrix, create_using=nx.DiGraph)
|
|
111
|
-
d = nx.trophic_levels(G)
|
|
112
|
-
|
|
113
|
-
expected_result = [1, 2, 2.5, 3.25]
|
|
114
|
-
for ind in range(4):
|
|
115
|
-
assert d[ind] == pytest.approx(expected_result[ind], abs=1e-7)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def test_trophic_levels_even_more_complex():
|
|
119
|
-
# fmt: off
|
|
120
|
-
# Another, bigger matrix
|
|
121
|
-
matrix = np.array([
|
|
122
|
-
[0, 0, 0, 0, 0],
|
|
123
|
-
[0, 1, 0, 1, 0],
|
|
124
|
-
[1, 0, 0, 0, 0],
|
|
125
|
-
[0, 1, 0, 0, 0],
|
|
126
|
-
[0, 0, 0, 1, 0]
|
|
127
|
-
])
|
|
128
|
-
# Generated this linear system using pen and paper:
|
|
129
|
-
K = np.array([
|
|
130
|
-
[1, 0, -1, 0, 0],
|
|
131
|
-
[0, 0.5, 0, -0.5, 0],
|
|
132
|
-
[0, 0, 1, 0, 0],
|
|
133
|
-
[0, -0.5, 0, 1, -0.5],
|
|
134
|
-
[0, 0, 0, 0, 1],
|
|
135
|
-
])
|
|
136
|
-
# fmt: on
|
|
137
|
-
result_1 = np.ravel(np.linalg.inv(K) @ np.ones(5))
|
|
138
|
-
G = nx.from_numpy_array(matrix, create_using=nx.DiGraph)
|
|
139
|
-
result_2 = nx.trophic_levels(G)
|
|
140
|
-
|
|
141
|
-
for ind in range(5):
|
|
142
|
-
assert result_1[ind] == pytest.approx(result_2[ind], abs=1e-7)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def test_trophic_levels_singular_matrix():
|
|
146
|
-
"""Should raise an error with graphs with only non-basal nodes"""
|
|
147
|
-
matrix = np.identity(4)
|
|
148
|
-
G = nx.from_numpy_array(matrix, create_using=nx.DiGraph)
|
|
149
|
-
with pytest.raises(nx.NetworkXError, match="no basal nodes"):
|
|
150
|
-
nx.trophic_levels(G)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def test_trophic_levels_singular_with_basal():
|
|
154
|
-
"""Should fail to compute if there are any parts of the graph which are not
|
|
155
|
-
reachable from any basal node (with in-degree zero).
|
|
156
|
-
"""
|
|
157
|
-
G = nx.DiGraph()
|
|
158
|
-
# a has in-degree zero
|
|
159
|
-
G.add_edge("a", "b")
|
|
160
|
-
|
|
161
|
-
# b is one level above a, c and d
|
|
162
|
-
G.add_edge("c", "b")
|
|
163
|
-
G.add_edge("d", "b")
|
|
164
|
-
|
|
165
|
-
# c and d form a loop, neither are reachable from a
|
|
166
|
-
G.add_edge("c", "d")
|
|
167
|
-
G.add_edge("d", "c")
|
|
168
|
-
|
|
169
|
-
with pytest.raises(nx.NetworkXError) as e:
|
|
170
|
-
nx.trophic_levels(G)
|
|
171
|
-
msg = (
|
|
172
|
-
"Trophic levels are only defined for graphs where every node "
|
|
173
|
-
+ "has a path from a basal node (basal nodes are nodes with no "
|
|
174
|
-
+ "incoming edges)."
|
|
175
|
-
)
|
|
176
|
-
assert msg in str(e.value)
|
|
177
|
-
|
|
178
|
-
# if self-loops are allowed, smaller example:
|
|
179
|
-
G = nx.DiGraph()
|
|
180
|
-
G.add_edge("a", "b") # a has in-degree zero
|
|
181
|
-
G.add_edge("c", "b") # b is one level above a and c
|
|
182
|
-
G.add_edge("c", "c") # c has a self-loop
|
|
183
|
-
with pytest.raises(nx.NetworkXError) as e:
|
|
184
|
-
nx.trophic_levels(G)
|
|
185
|
-
msg = (
|
|
186
|
-
"Trophic levels are only defined for graphs where every node "
|
|
187
|
-
+ "has a path from a basal node (basal nodes are nodes with no "
|
|
188
|
-
+ "incoming edges)."
|
|
189
|
-
)
|
|
190
|
-
assert msg in str(e.value)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
def test_trophic_differences():
|
|
194
|
-
matrix_a = np.array([[0, 1], [0, 0]])
|
|
195
|
-
G = nx.from_numpy_array(matrix_a, create_using=nx.DiGraph)
|
|
196
|
-
diffs = nx.trophic_differences(G)
|
|
197
|
-
assert diffs[(0, 1)] == pytest.approx(1, abs=1e-7)
|
|
198
|
-
|
|
199
|
-
# fmt: off
|
|
200
|
-
matrix_b = np.array([
|
|
201
|
-
[0, 1, 1, 0],
|
|
202
|
-
[0, 0, 1, 1],
|
|
203
|
-
[0, 0, 0, 1],
|
|
204
|
-
[0, 0, 0, 0]
|
|
205
|
-
])
|
|
206
|
-
# fmt: on
|
|
207
|
-
G = nx.from_numpy_array(matrix_b, create_using=nx.DiGraph)
|
|
208
|
-
diffs = nx.trophic_differences(G)
|
|
209
|
-
|
|
210
|
-
assert diffs[(0, 1)] == pytest.approx(1, abs=1e-7)
|
|
211
|
-
assert diffs[(0, 2)] == pytest.approx(1.5, abs=1e-7)
|
|
212
|
-
assert diffs[(1, 2)] == pytest.approx(0.5, abs=1e-7)
|
|
213
|
-
assert diffs[(1, 3)] == pytest.approx(1.25, abs=1e-7)
|
|
214
|
-
assert diffs[(2, 3)] == pytest.approx(0.75, abs=1e-7)
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
def test_trophic_incoherence_parameter_no_cannibalism():
|
|
218
|
-
matrix_a = np.array([[0, 1], [0, 0]])
|
|
219
|
-
G = nx.from_numpy_array(matrix_a, create_using=nx.DiGraph)
|
|
220
|
-
q = nx.trophic_incoherence_parameter(G, cannibalism=False)
|
|
221
|
-
assert q == pytest.approx(0, abs=1e-7)
|
|
222
|
-
|
|
223
|
-
# fmt: off
|
|
224
|
-
matrix_b = np.array([
|
|
225
|
-
[0, 1, 1, 0],
|
|
226
|
-
[0, 0, 1, 1],
|
|
227
|
-
[0, 0, 0, 1],
|
|
228
|
-
[0, 0, 0, 0]
|
|
229
|
-
])
|
|
230
|
-
# fmt: on
|
|
231
|
-
G = nx.from_numpy_array(matrix_b, create_using=nx.DiGraph)
|
|
232
|
-
q = nx.trophic_incoherence_parameter(G, cannibalism=False)
|
|
233
|
-
assert q == pytest.approx(np.std([1, 1.5, 0.5, 0.75, 1.25]), abs=1e-7)
|
|
234
|
-
|
|
235
|
-
# fmt: off
|
|
236
|
-
matrix_c = np.array([
|
|
237
|
-
[0, 1, 1, 0],
|
|
238
|
-
[0, 1, 1, 1],
|
|
239
|
-
[0, 0, 0, 1],
|
|
240
|
-
[0, 0, 0, 1]
|
|
241
|
-
])
|
|
242
|
-
# fmt: on
|
|
243
|
-
G = nx.from_numpy_array(matrix_c, create_using=nx.DiGraph)
|
|
244
|
-
q = nx.trophic_incoherence_parameter(G, cannibalism=False)
|
|
245
|
-
# Ignore the -link
|
|
246
|
-
assert q == pytest.approx(np.std([1, 1.5, 0.5, 0.75, 1.25]), abs=1e-7)
|
|
247
|
-
|
|
248
|
-
# no self-loops case
|
|
249
|
-
# fmt: off
|
|
250
|
-
matrix_d = np.array([
|
|
251
|
-
[0, 1, 1, 0],
|
|
252
|
-
[0, 0, 1, 1],
|
|
253
|
-
[0, 0, 0, 1],
|
|
254
|
-
[0, 0, 0, 0]
|
|
255
|
-
])
|
|
256
|
-
# fmt: on
|
|
257
|
-
G = nx.from_numpy_array(matrix_d, create_using=nx.DiGraph)
|
|
258
|
-
q = nx.trophic_incoherence_parameter(G, cannibalism=False)
|
|
259
|
-
# Ignore the -link
|
|
260
|
-
assert q == pytest.approx(np.std([1, 1.5, 0.5, 0.75, 1.25]), abs=1e-7)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
def test_trophic_incoherence_parameter_cannibalism():
|
|
264
|
-
matrix_a = np.array([[0, 1], [0, 0]])
|
|
265
|
-
G = nx.from_numpy_array(matrix_a, create_using=nx.DiGraph)
|
|
266
|
-
q = nx.trophic_incoherence_parameter(G, cannibalism=True)
|
|
267
|
-
assert q == pytest.approx(0, abs=1e-7)
|
|
268
|
-
|
|
269
|
-
# fmt: off
|
|
270
|
-
matrix_b = np.array([
|
|
271
|
-
[0, 0, 0, 0, 0],
|
|
272
|
-
[0, 1, 0, 1, 0],
|
|
273
|
-
[1, 0, 0, 0, 0],
|
|
274
|
-
[0, 1, 0, 0, 0],
|
|
275
|
-
[0, 0, 0, 1, 0]
|
|
276
|
-
])
|
|
277
|
-
# fmt: on
|
|
278
|
-
G = nx.from_numpy_array(matrix_b, create_using=nx.DiGraph)
|
|
279
|
-
q = nx.trophic_incoherence_parameter(G, cannibalism=True)
|
|
280
|
-
assert q == pytest.approx(2, abs=1e-7)
|
|
281
|
-
|
|
282
|
-
# fmt: off
|
|
283
|
-
matrix_c = np.array([
|
|
284
|
-
[0, 1, 1, 0],
|
|
285
|
-
[0, 0, 1, 1],
|
|
286
|
-
[0, 0, 0, 1],
|
|
287
|
-
[0, 0, 0, 0]
|
|
288
|
-
])
|
|
289
|
-
# fmt: on
|
|
290
|
-
G = nx.from_numpy_array(matrix_c, create_using=nx.DiGraph)
|
|
291
|
-
q = nx.trophic_incoherence_parameter(G, cannibalism=True)
|
|
292
|
-
# Ignore the -link
|
|
293
|
-
assert q == pytest.approx(np.std([1, 1.5, 0.5, 0.75, 1.25]), abs=1e-7)
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
def test_no_basal_node():
|
|
297
|
-
G = nx.DiGraph([(1, 2), (2, 3), (3, 1)]) # No basal node, should raise an error
|
|
298
|
-
with pytest.raises(nx.NetworkXError, match="no basal node"):
|
|
299
|
-
nx.trophic_levels(G)
|
|
300
|
-
G.add_node(4) # add basal node, but not connected
|
|
301
|
-
with pytest.raises(nx.NetworkXError, match="every node .* path from a basal node"):
|
|
302
|
-
nx.trophic_levels(G)
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Unit tests for VoteRank.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
import networkx as nx
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class TestVoteRankCentrality:
|
|
9
|
-
# Example Graph present in reference paper
|
|
10
|
-
def test_voterank_centrality_1(self):
|
|
11
|
-
G = nx.Graph()
|
|
12
|
-
G.add_edges_from(
|
|
13
|
-
[
|
|
14
|
-
(7, 8),
|
|
15
|
-
(7, 5),
|
|
16
|
-
(7, 9),
|
|
17
|
-
(5, 0),
|
|
18
|
-
(0, 1),
|
|
19
|
-
(0, 2),
|
|
20
|
-
(0, 3),
|
|
21
|
-
(0, 4),
|
|
22
|
-
(1, 6),
|
|
23
|
-
(2, 6),
|
|
24
|
-
(3, 6),
|
|
25
|
-
(4, 6),
|
|
26
|
-
]
|
|
27
|
-
)
|
|
28
|
-
assert [0, 7, 6] == nx.voterank(G)
|
|
29
|
-
|
|
30
|
-
def test_voterank_emptygraph(self):
|
|
31
|
-
G = nx.Graph()
|
|
32
|
-
assert [] == nx.voterank(G)
|
|
33
|
-
|
|
34
|
-
# Graph unit test
|
|
35
|
-
def test_voterank_centrality_2(self):
|
|
36
|
-
G = nx.florentine_families_graph()
|
|
37
|
-
d = nx.voterank(G, 4)
|
|
38
|
-
exact = ["Medici", "Strozzi", "Guadagni", "Castellani"]
|
|
39
|
-
assert exact == d
|
|
40
|
-
|
|
41
|
-
# DiGraph unit test
|
|
42
|
-
def test_voterank_centrality_3(self):
|
|
43
|
-
G = nx.gnc_graph(10, seed=7)
|
|
44
|
-
d = nx.voterank(G, 4)
|
|
45
|
-
exact = [3, 6, 8]
|
|
46
|
-
assert exact == d
|
|
47
|
-
|
|
48
|
-
# MultiGraph unit test
|
|
49
|
-
def test_voterank_centrality_4(self):
|
|
50
|
-
G = nx.MultiGraph()
|
|
51
|
-
G.add_edges_from(
|
|
52
|
-
[(0, 1), (0, 1), (1, 2), (2, 5), (2, 5), (5, 6), (5, 6), (2, 4), (4, 3)]
|
|
53
|
-
)
|
|
54
|
-
exact = [2, 1, 5, 4]
|
|
55
|
-
assert exact == nx.voterank(G)
|
|
56
|
-
|
|
57
|
-
# MultiDiGraph unit test
|
|
58
|
-
def test_voterank_centrality_5(self):
|
|
59
|
-
G = nx.MultiDiGraph()
|
|
60
|
-
G.add_edges_from(
|
|
61
|
-
[(0, 1), (0, 1), (1, 2), (2, 5), (2, 5), (5, 6), (5, 6), (2, 4), (4, 3)]
|
|
62
|
-
)
|
|
63
|
-
exact = [2, 0, 5, 4]
|
|
64
|
-
assert exact == nx.voterank(G)
|
|
File without changes
|