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,349 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
import networkx as nx
|
|
4
|
-
from networkx.utils import edges_equal, graphs_equal, nodes_equal
|
|
5
|
-
|
|
6
|
-
np = pytest.importorskip("numpy")
|
|
7
|
-
pd = pytest.importorskip("pandas")
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class TestConvertPandas:
|
|
11
|
-
def setup_method(self):
|
|
12
|
-
self.rng = np.random.RandomState(seed=5)
|
|
13
|
-
ints = self.rng.randint(1, 11, size=(3, 2))
|
|
14
|
-
a = ["A", "B", "C"]
|
|
15
|
-
b = ["D", "A", "E"]
|
|
16
|
-
df = pd.DataFrame(ints, columns=["weight", "cost"])
|
|
17
|
-
df[0] = a # Column label 0 (int)
|
|
18
|
-
df["b"] = b # Column label 'b' (str)
|
|
19
|
-
self.df = df
|
|
20
|
-
|
|
21
|
-
mdf = pd.DataFrame([[4, 16, "A", "D"]], columns=["weight", "cost", 0, "b"])
|
|
22
|
-
self.mdf = pd.concat([df, mdf])
|
|
23
|
-
|
|
24
|
-
def test_exceptions(self):
|
|
25
|
-
G = pd.DataFrame(["a"]) # adj
|
|
26
|
-
pytest.raises(nx.NetworkXError, nx.to_networkx_graph, G)
|
|
27
|
-
G = pd.DataFrame(["a", 0.0]) # elist
|
|
28
|
-
pytest.raises(nx.NetworkXError, nx.to_networkx_graph, G)
|
|
29
|
-
df = pd.DataFrame([[1, 1], [1, 0]], dtype=int, index=[1, 2], columns=["a", "b"])
|
|
30
|
-
pytest.raises(nx.NetworkXError, nx.from_pandas_adjacency, df)
|
|
31
|
-
|
|
32
|
-
def test_from_edgelist_all_attr(self):
|
|
33
|
-
Gtrue = nx.Graph(
|
|
34
|
-
[
|
|
35
|
-
("E", "C", {"cost": 9, "weight": 10}),
|
|
36
|
-
("B", "A", {"cost": 1, "weight": 7}),
|
|
37
|
-
("A", "D", {"cost": 7, "weight": 4}),
|
|
38
|
-
]
|
|
39
|
-
)
|
|
40
|
-
G = nx.from_pandas_edgelist(self.df, 0, "b", True)
|
|
41
|
-
assert graphs_equal(G, Gtrue)
|
|
42
|
-
# MultiGraph
|
|
43
|
-
MGtrue = nx.MultiGraph(Gtrue)
|
|
44
|
-
MGtrue.add_edge("A", "D", cost=16, weight=4)
|
|
45
|
-
MG = nx.from_pandas_edgelist(self.mdf, 0, "b", True, nx.MultiGraph())
|
|
46
|
-
assert graphs_equal(MG, MGtrue)
|
|
47
|
-
|
|
48
|
-
def test_from_edgelist_multi_attr(self):
|
|
49
|
-
Gtrue = nx.Graph(
|
|
50
|
-
[
|
|
51
|
-
("E", "C", {"cost": 9, "weight": 10}),
|
|
52
|
-
("B", "A", {"cost": 1, "weight": 7}),
|
|
53
|
-
("A", "D", {"cost": 7, "weight": 4}),
|
|
54
|
-
]
|
|
55
|
-
)
|
|
56
|
-
G = nx.from_pandas_edgelist(self.df, 0, "b", ["weight", "cost"])
|
|
57
|
-
assert graphs_equal(G, Gtrue)
|
|
58
|
-
|
|
59
|
-
def test_from_edgelist_multi_attr_incl_target(self):
|
|
60
|
-
Gtrue = nx.Graph(
|
|
61
|
-
[
|
|
62
|
-
("E", "C", {0: "C", "b": "E", "weight": 10}),
|
|
63
|
-
("B", "A", {0: "B", "b": "A", "weight": 7}),
|
|
64
|
-
("A", "D", {0: "A", "b": "D", "weight": 4}),
|
|
65
|
-
]
|
|
66
|
-
)
|
|
67
|
-
G = nx.from_pandas_edgelist(self.df, 0, "b", [0, "b", "weight"])
|
|
68
|
-
assert graphs_equal(G, Gtrue)
|
|
69
|
-
|
|
70
|
-
def test_from_edgelist_multidigraph_and_edge_attr(self):
|
|
71
|
-
# example from issue #2374
|
|
72
|
-
edges = [
|
|
73
|
-
("X1", "X4", {"Co": "zA", "Mi": 0, "St": "X1"}),
|
|
74
|
-
("X1", "X4", {"Co": "zB", "Mi": 54, "St": "X2"}),
|
|
75
|
-
("X1", "X4", {"Co": "zB", "Mi": 49, "St": "X3"}),
|
|
76
|
-
("X1", "X4", {"Co": "zB", "Mi": 44, "St": "X4"}),
|
|
77
|
-
("Y1", "Y3", {"Co": "zC", "Mi": 0, "St": "Y1"}),
|
|
78
|
-
("Y1", "Y3", {"Co": "zC", "Mi": 34, "St": "Y2"}),
|
|
79
|
-
("Y1", "Y3", {"Co": "zC", "Mi": 29, "St": "X2"}),
|
|
80
|
-
("Y1", "Y3", {"Co": "zC", "Mi": 24, "St": "Y3"}),
|
|
81
|
-
("Z1", "Z3", {"Co": "zD", "Mi": 0, "St": "Z1"}),
|
|
82
|
-
("Z1", "Z3", {"Co": "zD", "Mi": 14, "St": "X3"}),
|
|
83
|
-
]
|
|
84
|
-
Gtrue = nx.MultiDiGraph(edges)
|
|
85
|
-
data = {
|
|
86
|
-
"O": ["X1", "X1", "X1", "X1", "Y1", "Y1", "Y1", "Y1", "Z1", "Z1"],
|
|
87
|
-
"D": ["X4", "X4", "X4", "X4", "Y3", "Y3", "Y3", "Y3", "Z3", "Z3"],
|
|
88
|
-
"St": ["X1", "X2", "X3", "X4", "Y1", "Y2", "X2", "Y3", "Z1", "X3"],
|
|
89
|
-
"Co": ["zA", "zB", "zB", "zB", "zC", "zC", "zC", "zC", "zD", "zD"],
|
|
90
|
-
"Mi": [0, 54, 49, 44, 0, 34, 29, 24, 0, 14],
|
|
91
|
-
}
|
|
92
|
-
df = pd.DataFrame.from_dict(data)
|
|
93
|
-
G1 = nx.from_pandas_edgelist(
|
|
94
|
-
df, source="O", target="D", edge_attr=True, create_using=nx.MultiDiGraph
|
|
95
|
-
)
|
|
96
|
-
G2 = nx.from_pandas_edgelist(
|
|
97
|
-
df,
|
|
98
|
-
source="O",
|
|
99
|
-
target="D",
|
|
100
|
-
edge_attr=["St", "Co", "Mi"],
|
|
101
|
-
create_using=nx.MultiDiGraph,
|
|
102
|
-
)
|
|
103
|
-
assert graphs_equal(G1, Gtrue)
|
|
104
|
-
assert graphs_equal(G2, Gtrue)
|
|
105
|
-
|
|
106
|
-
def test_from_edgelist_one_attr(self):
|
|
107
|
-
Gtrue = nx.Graph(
|
|
108
|
-
[
|
|
109
|
-
("E", "C", {"weight": 10}),
|
|
110
|
-
("B", "A", {"weight": 7}),
|
|
111
|
-
("A", "D", {"weight": 4}),
|
|
112
|
-
]
|
|
113
|
-
)
|
|
114
|
-
G = nx.from_pandas_edgelist(self.df, 0, "b", "weight")
|
|
115
|
-
assert graphs_equal(G, Gtrue)
|
|
116
|
-
|
|
117
|
-
def test_from_edgelist_int_attr_name(self):
|
|
118
|
-
# note: this also tests that edge_attr can be `source`
|
|
119
|
-
Gtrue = nx.Graph(
|
|
120
|
-
[("E", "C", {0: "C"}), ("B", "A", {0: "B"}), ("A", "D", {0: "A"})]
|
|
121
|
-
)
|
|
122
|
-
G = nx.from_pandas_edgelist(self.df, 0, "b", 0)
|
|
123
|
-
assert graphs_equal(G, Gtrue)
|
|
124
|
-
|
|
125
|
-
def test_from_edgelist_invalid_attr(self):
|
|
126
|
-
pytest.raises(
|
|
127
|
-
nx.NetworkXError, nx.from_pandas_edgelist, self.df, 0, "b", "misspell"
|
|
128
|
-
)
|
|
129
|
-
pytest.raises(nx.NetworkXError, nx.from_pandas_edgelist, self.df, 0, "b", 1)
|
|
130
|
-
# see Issue #3562
|
|
131
|
-
edgeframe = pd.DataFrame([[0, 1], [1, 2], [2, 0]], columns=["s", "t"])
|
|
132
|
-
pytest.raises(
|
|
133
|
-
nx.NetworkXError, nx.from_pandas_edgelist, edgeframe, "s", "t", True
|
|
134
|
-
)
|
|
135
|
-
pytest.raises(
|
|
136
|
-
nx.NetworkXError, nx.from_pandas_edgelist, edgeframe, "s", "t", "weight"
|
|
137
|
-
)
|
|
138
|
-
pytest.raises(
|
|
139
|
-
nx.NetworkXError,
|
|
140
|
-
nx.from_pandas_edgelist,
|
|
141
|
-
edgeframe,
|
|
142
|
-
"s",
|
|
143
|
-
"t",
|
|
144
|
-
["weight", "size"],
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
def test_from_edgelist_no_attr(self):
|
|
148
|
-
Gtrue = nx.Graph([("E", "C", {}), ("B", "A", {}), ("A", "D", {})])
|
|
149
|
-
G = nx.from_pandas_edgelist(self.df, 0, "b")
|
|
150
|
-
assert graphs_equal(G, Gtrue)
|
|
151
|
-
|
|
152
|
-
def test_from_edgelist(self):
|
|
153
|
-
# Pandas DataFrame
|
|
154
|
-
G = nx.cycle_graph(10)
|
|
155
|
-
G.add_weighted_edges_from((u, v, u) for u, v in list(G.edges))
|
|
156
|
-
|
|
157
|
-
edgelist = nx.to_edgelist(G)
|
|
158
|
-
source = [s for s, t, d in edgelist]
|
|
159
|
-
target = [t for s, t, d in edgelist]
|
|
160
|
-
weight = [d["weight"] for s, t, d in edgelist]
|
|
161
|
-
edges = pd.DataFrame({"source": source, "target": target, "weight": weight})
|
|
162
|
-
|
|
163
|
-
GG = nx.from_pandas_edgelist(edges, edge_attr="weight")
|
|
164
|
-
assert nodes_equal(G.nodes(), GG.nodes())
|
|
165
|
-
assert edges_equal(G.edges(), GG.edges())
|
|
166
|
-
GW = nx.to_networkx_graph(edges, create_using=nx.Graph)
|
|
167
|
-
assert nodes_equal(G.nodes(), GW.nodes())
|
|
168
|
-
assert edges_equal(G.edges(), GW.edges())
|
|
169
|
-
|
|
170
|
-
def test_to_edgelist_default_source_or_target_col_exists(self):
|
|
171
|
-
G = nx.path_graph(10)
|
|
172
|
-
G.add_weighted_edges_from((u, v, u) for u, v in list(G.edges))
|
|
173
|
-
nx.set_edge_attributes(G, 0, name="source")
|
|
174
|
-
pytest.raises(nx.NetworkXError, nx.to_pandas_edgelist, G)
|
|
175
|
-
|
|
176
|
-
# drop source column to test an exception raised for the target column
|
|
177
|
-
for u, v, d in G.edges(data=True):
|
|
178
|
-
d.pop("source", None)
|
|
179
|
-
|
|
180
|
-
nx.set_edge_attributes(G, 0, name="target")
|
|
181
|
-
pytest.raises(nx.NetworkXError, nx.to_pandas_edgelist, G)
|
|
182
|
-
|
|
183
|
-
def test_to_edgelist_custom_source_or_target_col_exists(self):
|
|
184
|
-
G = nx.path_graph(10)
|
|
185
|
-
G.add_weighted_edges_from((u, v, u) for u, v in list(G.edges))
|
|
186
|
-
nx.set_edge_attributes(G, 0, name="source_col_name")
|
|
187
|
-
pytest.raises(
|
|
188
|
-
nx.NetworkXError, nx.to_pandas_edgelist, G, source="source_col_name"
|
|
189
|
-
)
|
|
190
|
-
|
|
191
|
-
# drop source column to test an exception raised for the target column
|
|
192
|
-
for u, v, d in G.edges(data=True):
|
|
193
|
-
d.pop("source_col_name", None)
|
|
194
|
-
|
|
195
|
-
nx.set_edge_attributes(G, 0, name="target_col_name")
|
|
196
|
-
pytest.raises(
|
|
197
|
-
nx.NetworkXError, nx.to_pandas_edgelist, G, target="target_col_name"
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
def test_to_edgelist_edge_key_col_exists(self):
|
|
201
|
-
G = nx.path_graph(10, create_using=nx.MultiGraph)
|
|
202
|
-
G.add_weighted_edges_from((u, v, u) for u, v in list(G.edges()))
|
|
203
|
-
nx.set_edge_attributes(G, 0, name="edge_key_name")
|
|
204
|
-
pytest.raises(
|
|
205
|
-
nx.NetworkXError, nx.to_pandas_edgelist, G, edge_key="edge_key_name"
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
def test_from_adjacency(self):
|
|
209
|
-
nodelist = [1, 2]
|
|
210
|
-
dftrue = pd.DataFrame(
|
|
211
|
-
[[1, 1], [1, 0]], dtype=int, index=nodelist, columns=nodelist
|
|
212
|
-
)
|
|
213
|
-
G = nx.Graph([(1, 1), (1, 2)])
|
|
214
|
-
df = nx.to_pandas_adjacency(G, dtype=int)
|
|
215
|
-
pd.testing.assert_frame_equal(df, dftrue)
|
|
216
|
-
|
|
217
|
-
@pytest.mark.parametrize("graph", [nx.Graph, nx.MultiGraph])
|
|
218
|
-
def test_roundtrip(self, graph):
|
|
219
|
-
# edgelist
|
|
220
|
-
Gtrue = graph([(1, 1), (1, 2)])
|
|
221
|
-
df = nx.to_pandas_edgelist(Gtrue)
|
|
222
|
-
G = nx.from_pandas_edgelist(df, create_using=graph)
|
|
223
|
-
assert graphs_equal(Gtrue, G)
|
|
224
|
-
# adjacency
|
|
225
|
-
adj = {1: {1: {"weight": 1}, 2: {"weight": 1}}, 2: {1: {"weight": 1}}}
|
|
226
|
-
Gtrue = graph(adj)
|
|
227
|
-
df = nx.to_pandas_adjacency(Gtrue, dtype=int)
|
|
228
|
-
G = nx.from_pandas_adjacency(df, create_using=graph)
|
|
229
|
-
assert graphs_equal(Gtrue, G)
|
|
230
|
-
|
|
231
|
-
def test_from_adjacency_named(self):
|
|
232
|
-
# example from issue #3105
|
|
233
|
-
data = {
|
|
234
|
-
"A": {"A": 0, "B": 0, "C": 0},
|
|
235
|
-
"B": {"A": 1, "B": 0, "C": 0},
|
|
236
|
-
"C": {"A": 0, "B": 1, "C": 0},
|
|
237
|
-
}
|
|
238
|
-
dftrue = pd.DataFrame(data, dtype=np.intp)
|
|
239
|
-
df = dftrue[["A", "C", "B"]]
|
|
240
|
-
G = nx.from_pandas_adjacency(df, create_using=nx.DiGraph())
|
|
241
|
-
df = nx.to_pandas_adjacency(G, dtype=np.intp)
|
|
242
|
-
pd.testing.assert_frame_equal(df, dftrue)
|
|
243
|
-
|
|
244
|
-
@pytest.mark.parametrize("edge_attr", [["attr2", "attr3"], True])
|
|
245
|
-
def test_edgekey_with_multigraph(self, edge_attr):
|
|
246
|
-
df = pd.DataFrame(
|
|
247
|
-
{
|
|
248
|
-
"source": {"A": "N1", "B": "N2", "C": "N1", "D": "N1"},
|
|
249
|
-
"target": {"A": "N2", "B": "N3", "C": "N1", "D": "N2"},
|
|
250
|
-
"attr1": {"A": "F1", "B": "F2", "C": "F3", "D": "F4"},
|
|
251
|
-
"attr2": {"A": 1, "B": 0, "C": 0, "D": 0},
|
|
252
|
-
"attr3": {"A": 0, "B": 1, "C": 0, "D": 1},
|
|
253
|
-
}
|
|
254
|
-
)
|
|
255
|
-
Gtrue = nx.MultiGraph(
|
|
256
|
-
[
|
|
257
|
-
("N1", "N2", "F1", {"attr2": 1, "attr3": 0}),
|
|
258
|
-
("N2", "N3", "F2", {"attr2": 0, "attr3": 1}),
|
|
259
|
-
("N1", "N1", "F3", {"attr2": 0, "attr3": 0}),
|
|
260
|
-
("N1", "N2", "F4", {"attr2": 0, "attr3": 1}),
|
|
261
|
-
]
|
|
262
|
-
)
|
|
263
|
-
# example from issue #4065
|
|
264
|
-
G = nx.from_pandas_edgelist(
|
|
265
|
-
df,
|
|
266
|
-
source="source",
|
|
267
|
-
target="target",
|
|
268
|
-
edge_attr=edge_attr,
|
|
269
|
-
edge_key="attr1",
|
|
270
|
-
create_using=nx.MultiGraph(),
|
|
271
|
-
)
|
|
272
|
-
assert graphs_equal(G, Gtrue)
|
|
273
|
-
|
|
274
|
-
df_roundtrip = nx.to_pandas_edgelist(G, edge_key="attr1")
|
|
275
|
-
df_roundtrip = df_roundtrip.sort_values("attr1")
|
|
276
|
-
df_roundtrip.index = ["A", "B", "C", "D"]
|
|
277
|
-
pd.testing.assert_frame_equal(
|
|
278
|
-
df, df_roundtrip[["source", "target", "attr1", "attr2", "attr3"]]
|
|
279
|
-
)
|
|
280
|
-
|
|
281
|
-
def test_edgekey_with_normal_graph_no_action(self):
|
|
282
|
-
Gtrue = nx.Graph(
|
|
283
|
-
[
|
|
284
|
-
("E", "C", {"cost": 9, "weight": 10}),
|
|
285
|
-
("B", "A", {"cost": 1, "weight": 7}),
|
|
286
|
-
("A", "D", {"cost": 7, "weight": 4}),
|
|
287
|
-
]
|
|
288
|
-
)
|
|
289
|
-
G = nx.from_pandas_edgelist(self.df, 0, "b", True, edge_key="weight")
|
|
290
|
-
assert graphs_equal(G, Gtrue)
|
|
291
|
-
|
|
292
|
-
def test_nonexisting_edgekey_raises(self):
|
|
293
|
-
with pytest.raises(nx.exception.NetworkXError):
|
|
294
|
-
nx.from_pandas_edgelist(
|
|
295
|
-
self.df,
|
|
296
|
-
source="source",
|
|
297
|
-
target="target",
|
|
298
|
-
edge_key="Not_real",
|
|
299
|
-
edge_attr=True,
|
|
300
|
-
create_using=nx.MultiGraph(),
|
|
301
|
-
)
|
|
302
|
-
|
|
303
|
-
def test_multigraph_with_edgekey_no_edgeattrs(self):
|
|
304
|
-
Gtrue = nx.MultiGraph()
|
|
305
|
-
Gtrue.add_edge(0, 1, key=0)
|
|
306
|
-
Gtrue.add_edge(0, 1, key=3)
|
|
307
|
-
df = nx.to_pandas_edgelist(Gtrue, edge_key="key")
|
|
308
|
-
expected = pd.DataFrame({"source": [0, 0], "target": [1, 1], "key": [0, 3]})
|
|
309
|
-
pd.testing.assert_frame_equal(expected, df)
|
|
310
|
-
G = nx.from_pandas_edgelist(df, edge_key="key", create_using=nx.MultiGraph)
|
|
311
|
-
assert graphs_equal(Gtrue, G)
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
def test_to_pandas_adjacency_with_nodelist():
|
|
315
|
-
G = nx.complete_graph(5)
|
|
316
|
-
nodelist = [1, 4]
|
|
317
|
-
expected = pd.DataFrame(
|
|
318
|
-
[[0, 1], [1, 0]], dtype=int, index=nodelist, columns=nodelist
|
|
319
|
-
)
|
|
320
|
-
pd.testing.assert_frame_equal(
|
|
321
|
-
expected, nx.to_pandas_adjacency(G, nodelist, dtype=int)
|
|
322
|
-
)
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
def test_to_pandas_edgelist_with_nodelist():
|
|
326
|
-
G = nx.Graph()
|
|
327
|
-
G.add_edges_from([(0, 1), (1, 2), (1, 3)], weight=2.0)
|
|
328
|
-
G.add_edge(0, 5, weight=100)
|
|
329
|
-
df = nx.to_pandas_edgelist(G, nodelist=[1, 2])
|
|
330
|
-
assert 0 not in df["source"].to_numpy()
|
|
331
|
-
assert 100 not in df["weight"].to_numpy()
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
def test_from_pandas_adjacency_with_index_collisions():
|
|
335
|
-
"""See gh-7407"""
|
|
336
|
-
df = pd.DataFrame(
|
|
337
|
-
[
|
|
338
|
-
[0, 1, 0, 0],
|
|
339
|
-
[0, 0, 1, 0],
|
|
340
|
-
[0, 0, 0, 1],
|
|
341
|
-
[0, 0, 0, 0],
|
|
342
|
-
],
|
|
343
|
-
index=[1010001, 2, 1, 1010002],
|
|
344
|
-
columns=[1010001, 2, 1, 1010002],
|
|
345
|
-
)
|
|
346
|
-
G = nx.from_pandas_adjacency(df, create_using=nx.DiGraph)
|
|
347
|
-
expected = nx.DiGraph([(1010001, 2), (2, 1), (1, 1010002)])
|
|
348
|
-
assert nodes_equal(G.nodes, expected.nodes)
|
|
349
|
-
assert edges_equal(G.edges, expected.edges, directed=True)
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
import networkx as nx
|
|
4
|
-
from networkx.utils import graphs_equal
|
|
5
|
-
|
|
6
|
-
np = pytest.importorskip("numpy")
|
|
7
|
-
sp = pytest.importorskip("scipy")
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class TestConvertScipy:
|
|
11
|
-
def setup_method(self):
|
|
12
|
-
self.G1 = nx.barbell_graph(10, 3)
|
|
13
|
-
self.G2 = nx.cycle_graph(10, create_using=nx.DiGraph)
|
|
14
|
-
|
|
15
|
-
self.G3 = self.create_weighted(nx.Graph())
|
|
16
|
-
self.G4 = self.create_weighted(nx.DiGraph())
|
|
17
|
-
|
|
18
|
-
def test_exceptions(self):
|
|
19
|
-
class G:
|
|
20
|
-
format = None
|
|
21
|
-
|
|
22
|
-
pytest.raises(nx.NetworkXError, nx.to_networkx_graph, G)
|
|
23
|
-
|
|
24
|
-
def create_weighted(self, G):
|
|
25
|
-
g = nx.cycle_graph(4)
|
|
26
|
-
e = list(g.edges())
|
|
27
|
-
source = [u for u, v in e]
|
|
28
|
-
dest = [v for u, v in e]
|
|
29
|
-
weight = [s + 10 for s in source]
|
|
30
|
-
ex = zip(source, dest, weight)
|
|
31
|
-
G.add_weighted_edges_from(ex)
|
|
32
|
-
return G
|
|
33
|
-
|
|
34
|
-
def identity_conversion(self, G, A, create_using):
|
|
35
|
-
GG = nx.from_scipy_sparse_array(A, create_using=create_using)
|
|
36
|
-
assert nx.is_isomorphic(G, GG)
|
|
37
|
-
|
|
38
|
-
GW = nx.to_networkx_graph(A, create_using=create_using)
|
|
39
|
-
assert nx.is_isomorphic(G, GW)
|
|
40
|
-
|
|
41
|
-
GI = nx.empty_graph(0, create_using).__class__(A)
|
|
42
|
-
assert nx.is_isomorphic(G, GI)
|
|
43
|
-
|
|
44
|
-
ACSR = A.tocsr()
|
|
45
|
-
GI = nx.empty_graph(0, create_using).__class__(ACSR)
|
|
46
|
-
assert nx.is_isomorphic(G, GI)
|
|
47
|
-
|
|
48
|
-
ACOO = A.tocoo()
|
|
49
|
-
GI = nx.empty_graph(0, create_using).__class__(ACOO)
|
|
50
|
-
assert nx.is_isomorphic(G, GI)
|
|
51
|
-
|
|
52
|
-
ACSC = A.tocsc()
|
|
53
|
-
GI = nx.empty_graph(0, create_using).__class__(ACSC)
|
|
54
|
-
assert nx.is_isomorphic(G, GI)
|
|
55
|
-
|
|
56
|
-
AD = A.todense()
|
|
57
|
-
GI = nx.empty_graph(0, create_using).__class__(AD)
|
|
58
|
-
assert nx.is_isomorphic(G, GI)
|
|
59
|
-
|
|
60
|
-
AA = A.toarray()
|
|
61
|
-
GI = nx.empty_graph(0, create_using).__class__(AA)
|
|
62
|
-
assert nx.is_isomorphic(G, GI)
|
|
63
|
-
|
|
64
|
-
def test_shape(self):
|
|
65
|
-
"Conversion from non-square sparse array."
|
|
66
|
-
A = sp.sparse.lil_array([[1, 2, 3], [4, 5, 6]])
|
|
67
|
-
pytest.raises(nx.NetworkXError, nx.from_scipy_sparse_array, A)
|
|
68
|
-
|
|
69
|
-
def test_identity_graph_matrix(self):
|
|
70
|
-
"Conversion from graph to sparse matrix to graph."
|
|
71
|
-
A = nx.to_scipy_sparse_array(self.G1)
|
|
72
|
-
self.identity_conversion(self.G1, A, nx.Graph())
|
|
73
|
-
|
|
74
|
-
def test_identity_digraph_matrix(self):
|
|
75
|
-
"Conversion from digraph to sparse matrix to digraph."
|
|
76
|
-
A = nx.to_scipy_sparse_array(self.G2)
|
|
77
|
-
self.identity_conversion(self.G2, A, nx.DiGraph())
|
|
78
|
-
|
|
79
|
-
def test_identity_weighted_graph_matrix(self):
|
|
80
|
-
"""Conversion from weighted graph to sparse matrix to weighted graph."""
|
|
81
|
-
A = nx.to_scipy_sparse_array(self.G3)
|
|
82
|
-
self.identity_conversion(self.G3, A, nx.Graph())
|
|
83
|
-
|
|
84
|
-
def test_identity_weighted_digraph_matrix(self):
|
|
85
|
-
"""Conversion from weighted digraph to sparse matrix to weighted digraph."""
|
|
86
|
-
A = nx.to_scipy_sparse_array(self.G4)
|
|
87
|
-
self.identity_conversion(self.G4, A, nx.DiGraph())
|
|
88
|
-
|
|
89
|
-
def test_nodelist(self):
|
|
90
|
-
"""Conversion from graph to sparse matrix to graph with nodelist."""
|
|
91
|
-
P4 = nx.path_graph(4)
|
|
92
|
-
P3 = nx.path_graph(3)
|
|
93
|
-
nodelist = list(P3.nodes())
|
|
94
|
-
A = nx.to_scipy_sparse_array(P4, nodelist=nodelist)
|
|
95
|
-
GA = nx.Graph(A)
|
|
96
|
-
assert nx.is_isomorphic(GA, P3)
|
|
97
|
-
|
|
98
|
-
pytest.raises(nx.NetworkXError, nx.to_scipy_sparse_array, P3, nodelist=[])
|
|
99
|
-
# Test nodelist duplicates.
|
|
100
|
-
long_nl = nodelist + [0]
|
|
101
|
-
pytest.raises(nx.NetworkXError, nx.to_scipy_sparse_array, P3, nodelist=long_nl)
|
|
102
|
-
|
|
103
|
-
# Test nodelist contains non-nodes
|
|
104
|
-
non_nl = [-1, 0, 1, 2]
|
|
105
|
-
pytest.raises(nx.NetworkXError, nx.to_scipy_sparse_array, P3, nodelist=non_nl)
|
|
106
|
-
|
|
107
|
-
def test_weight_keyword(self):
|
|
108
|
-
WP4 = nx.Graph()
|
|
109
|
-
WP4.add_edges_from((n, n + 1, {"weight": 0.5, "other": 0.3}) for n in range(3))
|
|
110
|
-
P4 = nx.path_graph(4)
|
|
111
|
-
A = nx.to_scipy_sparse_array(P4)
|
|
112
|
-
np.testing.assert_equal(
|
|
113
|
-
A.todense(), nx.to_scipy_sparse_array(WP4, weight=None).todense()
|
|
114
|
-
)
|
|
115
|
-
np.testing.assert_equal(
|
|
116
|
-
0.5 * A.todense(), nx.to_scipy_sparse_array(WP4).todense()
|
|
117
|
-
)
|
|
118
|
-
np.testing.assert_equal(
|
|
119
|
-
0.3 * A.todense(), nx.to_scipy_sparse_array(WP4, weight="other").todense()
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
def test_format_keyword(self):
|
|
123
|
-
WP4 = nx.Graph()
|
|
124
|
-
WP4.add_edges_from((n, n + 1, {"weight": 0.5, "other": 0.3}) for n in range(3))
|
|
125
|
-
P4 = nx.path_graph(4)
|
|
126
|
-
A = nx.to_scipy_sparse_array(P4, format="csr")
|
|
127
|
-
np.testing.assert_equal(
|
|
128
|
-
A.todense(), nx.to_scipy_sparse_array(WP4, weight=None).todense()
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
A = nx.to_scipy_sparse_array(P4, format="csc")
|
|
132
|
-
np.testing.assert_equal(
|
|
133
|
-
A.todense(), nx.to_scipy_sparse_array(WP4, weight=None).todense()
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
A = nx.to_scipy_sparse_array(P4, format="coo")
|
|
137
|
-
np.testing.assert_equal(
|
|
138
|
-
A.todense(), nx.to_scipy_sparse_array(WP4, weight=None).todense()
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
A = nx.to_scipy_sparse_array(P4, format="bsr")
|
|
142
|
-
np.testing.assert_equal(
|
|
143
|
-
A.todense(), nx.to_scipy_sparse_array(WP4, weight=None).todense()
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
A = nx.to_scipy_sparse_array(P4, format="lil")
|
|
147
|
-
np.testing.assert_equal(
|
|
148
|
-
A.todense(), nx.to_scipy_sparse_array(WP4, weight=None).todense()
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
A = nx.to_scipy_sparse_array(P4, format="dia")
|
|
152
|
-
np.testing.assert_equal(
|
|
153
|
-
A.todense(), nx.to_scipy_sparse_array(WP4, weight=None).todense()
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
A = nx.to_scipy_sparse_array(P4, format="dok")
|
|
157
|
-
np.testing.assert_equal(
|
|
158
|
-
A.todense(), nx.to_scipy_sparse_array(WP4, weight=None).todense()
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
def test_format_keyword_raise(self):
|
|
162
|
-
with pytest.raises(nx.NetworkXError):
|
|
163
|
-
WP4 = nx.Graph()
|
|
164
|
-
WP4.add_edges_from(
|
|
165
|
-
(n, n + 1, {"weight": 0.5, "other": 0.3}) for n in range(3)
|
|
166
|
-
)
|
|
167
|
-
P4 = nx.path_graph(4)
|
|
168
|
-
nx.to_scipy_sparse_array(P4, format="any_other")
|
|
169
|
-
|
|
170
|
-
def test_null_raise(self):
|
|
171
|
-
with pytest.raises(nx.NetworkXError):
|
|
172
|
-
nx.to_scipy_sparse_array(nx.Graph())
|
|
173
|
-
|
|
174
|
-
def test_empty(self):
|
|
175
|
-
G = nx.Graph()
|
|
176
|
-
G.add_node(1)
|
|
177
|
-
M = nx.to_scipy_sparse_array(G)
|
|
178
|
-
np.testing.assert_equal(M.toarray(), np.array([[0]]))
|
|
179
|
-
|
|
180
|
-
def test_ordering(self):
|
|
181
|
-
G = nx.DiGraph()
|
|
182
|
-
G.add_edge(1, 2)
|
|
183
|
-
G.add_edge(2, 3)
|
|
184
|
-
G.add_edge(3, 1)
|
|
185
|
-
M = nx.to_scipy_sparse_array(G, nodelist=[3, 2, 1])
|
|
186
|
-
np.testing.assert_equal(
|
|
187
|
-
M.toarray(), np.array([[0, 0, 1], [1, 0, 0], [0, 1, 0]])
|
|
188
|
-
)
|
|
189
|
-
|
|
190
|
-
def test_selfloop_graph(self):
|
|
191
|
-
G = nx.Graph([(1, 1)])
|
|
192
|
-
M = nx.to_scipy_sparse_array(G)
|
|
193
|
-
np.testing.assert_equal(M.toarray(), np.array([[1]]))
|
|
194
|
-
|
|
195
|
-
G.add_edges_from([(2, 3), (3, 4)])
|
|
196
|
-
M = nx.to_scipy_sparse_array(G, nodelist=[2, 3, 4])
|
|
197
|
-
np.testing.assert_equal(
|
|
198
|
-
M.toarray(), np.array([[0, 1, 0], [1, 0, 1], [0, 1, 0]])
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
def test_selfloop_digraph(self):
|
|
202
|
-
G = nx.DiGraph([(1, 1)])
|
|
203
|
-
M = nx.to_scipy_sparse_array(G)
|
|
204
|
-
np.testing.assert_equal(M.toarray(), np.array([[1]]))
|
|
205
|
-
|
|
206
|
-
G.add_edges_from([(2, 3), (3, 4)])
|
|
207
|
-
M = nx.to_scipy_sparse_array(G, nodelist=[2, 3, 4])
|
|
208
|
-
np.testing.assert_equal(
|
|
209
|
-
M.toarray(), np.array([[0, 1, 0], [0, 0, 1], [0, 0, 0]])
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
def test_from_scipy_sparse_array_parallel_edges(self):
|
|
213
|
-
"""Tests that the :func:`networkx.from_scipy_sparse_array` function
|
|
214
|
-
interprets integer weights as the number of parallel edges when
|
|
215
|
-
creating a multigraph.
|
|
216
|
-
|
|
217
|
-
"""
|
|
218
|
-
A = sp.sparse.csr_array([[1, 1], [1, 2]])
|
|
219
|
-
# First, with a simple graph, each integer entry in the adjacency
|
|
220
|
-
# matrix is interpreted as the weight of a single edge in the graph.
|
|
221
|
-
expected = nx.DiGraph()
|
|
222
|
-
edges = [(0, 0), (0, 1), (1, 0)]
|
|
223
|
-
expected.add_weighted_edges_from([(u, v, 1) for (u, v) in edges])
|
|
224
|
-
expected.add_edge(1, 1, weight=2)
|
|
225
|
-
actual = nx.from_scipy_sparse_array(
|
|
226
|
-
A, parallel_edges=True, create_using=nx.DiGraph
|
|
227
|
-
)
|
|
228
|
-
assert graphs_equal(actual, expected)
|
|
229
|
-
actual = nx.from_scipy_sparse_array(
|
|
230
|
-
A, parallel_edges=False, create_using=nx.DiGraph
|
|
231
|
-
)
|
|
232
|
-
assert graphs_equal(actual, expected)
|
|
233
|
-
# Now each integer entry in the adjacency matrix is interpreted as the
|
|
234
|
-
# number of parallel edges in the graph if the appropriate keyword
|
|
235
|
-
# argument is specified.
|
|
236
|
-
edges = [(0, 0), (0, 1), (1, 0), (1, 1), (1, 1)]
|
|
237
|
-
expected = nx.MultiDiGraph()
|
|
238
|
-
expected.add_weighted_edges_from([(u, v, 1) for (u, v) in edges])
|
|
239
|
-
actual = nx.from_scipy_sparse_array(
|
|
240
|
-
A, parallel_edges=True, create_using=nx.MultiDiGraph
|
|
241
|
-
)
|
|
242
|
-
assert graphs_equal(actual, expected)
|
|
243
|
-
expected = nx.MultiDiGraph()
|
|
244
|
-
expected.add_edges_from(set(edges), weight=1)
|
|
245
|
-
# The sole self-loop (edge 0) on vertex 1 should have weight 2.
|
|
246
|
-
expected[1][1][0]["weight"] = 2
|
|
247
|
-
actual = nx.from_scipy_sparse_array(
|
|
248
|
-
A, parallel_edges=False, create_using=nx.MultiDiGraph
|
|
249
|
-
)
|
|
250
|
-
assert graphs_equal(actual, expected)
|
|
251
|
-
|
|
252
|
-
def test_symmetric(self):
|
|
253
|
-
"""Tests that a symmetric matrix has edges added only once to an
|
|
254
|
-
undirected multigraph when using
|
|
255
|
-
:func:`networkx.from_scipy_sparse_array`.
|
|
256
|
-
|
|
257
|
-
"""
|
|
258
|
-
A = sp.sparse.csr_array([[0, 1], [1, 0]])
|
|
259
|
-
G = nx.from_scipy_sparse_array(A, create_using=nx.MultiGraph)
|
|
260
|
-
expected = nx.MultiGraph()
|
|
261
|
-
expected.add_edge(0, 1, weight=1)
|
|
262
|
-
assert graphs_equal(G, expected)
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
@pytest.mark.parametrize("sparse_format", ("csr", "csc", "dok"))
|
|
266
|
-
def test_from_scipy_sparse_array_formats(sparse_format):
|
|
267
|
-
"""Test all formats supported by _generate_weighted_edges."""
|
|
268
|
-
# trinode complete graph with non-uniform edge weights
|
|
269
|
-
expected = nx.Graph()
|
|
270
|
-
expected.add_edges_from(
|
|
271
|
-
[
|
|
272
|
-
(0, 1, {"weight": 3}),
|
|
273
|
-
(0, 2, {"weight": 2}),
|
|
274
|
-
(1, 0, {"weight": 3}),
|
|
275
|
-
(1, 2, {"weight": 1}),
|
|
276
|
-
(2, 0, {"weight": 2}),
|
|
277
|
-
(2, 1, {"weight": 1}),
|
|
278
|
-
]
|
|
279
|
-
)
|
|
280
|
-
A = sp.sparse.coo_array([[0, 3, 2], [3, 0, 1], [2, 1, 0]]).asformat(sparse_format)
|
|
281
|
-
assert graphs_equal(expected, nx.from_scipy_sparse_array(A))
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
import networkx as nx
|
|
4
|
-
|
|
5
|
-
# smoke tests for exceptions
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def test_raises_networkxexception():
|
|
9
|
-
with pytest.raises(nx.NetworkXException):
|
|
10
|
-
raise nx.NetworkXException
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_raises_networkxerr():
|
|
14
|
-
with pytest.raises(nx.NetworkXError):
|
|
15
|
-
raise nx.NetworkXError
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def test_raises_networkx_pointless_concept():
|
|
19
|
-
with pytest.raises(nx.NetworkXPointlessConcept):
|
|
20
|
-
raise nx.NetworkXPointlessConcept
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def test_raises_networkxalgorithmerr():
|
|
24
|
-
with pytest.raises(nx.NetworkXAlgorithmError):
|
|
25
|
-
raise nx.NetworkXAlgorithmError
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def test_raises_networkx_unfeasible():
|
|
29
|
-
with pytest.raises(nx.NetworkXUnfeasible):
|
|
30
|
-
raise nx.NetworkXUnfeasible
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def test_raises_networkx_no_path():
|
|
34
|
-
with pytest.raises(nx.NetworkXNoPath):
|
|
35
|
-
raise nx.NetworkXNoPath
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def test_raises_networkx_unbounded():
|
|
39
|
-
with pytest.raises(nx.NetworkXUnbounded):
|
|
40
|
-
raise nx.NetworkXUnbounded
|