okstra 0.107.2 → 0.109.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/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/prompts/lead/okstra-lead-contract.md +1 -1
- package/runtime/prompts/profiles/_common-contract.md +3 -2
- package/runtime/python/okstra_ctl/graphify_cmd.py +225 -0
- package/runtime/python/okstra_ctl/resolve_task_key.py +15 -9
- package/runtime/python/okstra_ctl/session.py +44 -0
- package/runtime/python/okstra_project/__init__.py +2 -0
- package/runtime/python/okstra_project/state.py +36 -0
- package/runtime/python/okstra_token_usage/claude.py +15 -9
- package/runtime/python/okstra_token_usage/cli.py +23 -0
- package/runtime/python/okstra_token_usage/collect.py +163 -4
- package/runtime/python/okstra_vendor/__init__.py +41 -0
- package/runtime/python/okstra_vendor/graphify/.vendored-version +1 -0
- package/runtime/python/okstra_vendor/graphify/__init__.py +28 -0
- package/runtime/python/okstra_vendor/graphify/__main__.py +1371 -0
- package/runtime/python/okstra_vendor/graphify/analyze.py +540 -0
- package/runtime/python/okstra_vendor/graphify/benchmark.py +129 -0
- package/runtime/python/okstra_vendor/graphify/build.py +107 -0
- package/runtime/python/okstra_vendor/graphify/cache.py +169 -0
- package/runtime/python/okstra_vendor/graphify/cluster.py +137 -0
- package/runtime/python/okstra_vendor/graphify/detect.py +510 -0
- package/runtime/python/okstra_vendor/graphify/export.py +1014 -0
- package/runtime/python/okstra_vendor/graphify/extract.py +3277 -0
- package/runtime/python/okstra_vendor/graphify/hooks.py +220 -0
- package/runtime/python/okstra_vendor/graphify/ingest.py +297 -0
- package/runtime/python/okstra_vendor/graphify/manifest.py +4 -0
- package/runtime/python/okstra_vendor/graphify/report.py +175 -0
- package/runtime/python/okstra_vendor/graphify/security.py +203 -0
- package/runtime/python/okstra_vendor/graphify/serve.py +373 -0
- package/runtime/python/okstra_vendor/graphify/skill-aider.md +1184 -0
- package/runtime/python/okstra_vendor/graphify/skill-claw.md +1184 -0
- package/runtime/python/okstra_vendor/graphify/skill-codex.md +1242 -0
- package/runtime/python/okstra_vendor/graphify/skill-copilot.md +1268 -0
- package/runtime/python/okstra_vendor/graphify/skill-droid.md +1239 -0
- package/runtime/python/okstra_vendor/graphify/skill-kiro.md +1183 -0
- package/runtime/python/okstra_vendor/graphify/skill-opencode.md +1238 -0
- package/runtime/python/okstra_vendor/graphify/skill-trae.md +1208 -0
- package/runtime/python/okstra_vendor/graphify/skill-vscode.md +253 -0
- package/runtime/python/okstra_vendor/graphify/skill-windows.md +1245 -0
- package/runtime/python/okstra_vendor/graphify/skill.md +1319 -0
- package/runtime/python/okstra_vendor/graphify/transcribe.py +182 -0
- package/runtime/python/okstra_vendor/graphify/validate.py +72 -0
- package/runtime/python/okstra_vendor/graphify/watch.py +188 -0
- package/runtime/python/okstra_vendor/graphify/wiki.py +214 -0
- package/runtime/python/okstra_vendor/networkx/__init__.py +62 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +134 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +26 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +259 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +71 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +412 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +396 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +150 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +149 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +369 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +44 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +143 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +53 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +265 -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 +41 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_clique.py +112 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_connectivity.py +199 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_density.py +146 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_distance_measures.py +59 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_dominating_set.py +78 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_kcomponents.py +303 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_matching.py +8 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_maxcut.py +94 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_ramsey.py +31 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_steinertree.py +306 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_traveling_salesman.py +1014 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_treewidth.py +274 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_vertex_cover.py +68 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +1508 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +255 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +83 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +5 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +122 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +302 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +255 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +160 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +127 -0
- 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 +81 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_connectivity.py +143 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_correlation.py +122 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_mixing.py +174 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_neighbor_degree.py +107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_pairs.py +87 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +164 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +322 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +290 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +289 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +57 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +360 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +105 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +603 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +316 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +590 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +232 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +526 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +112 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +69 -0
- 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 +125 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_centrality.py +192 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_cluster.py +84 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_covering.py +33 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_edgelist.py +240 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_extendability.py +334 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_generators.py +407 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_link_analysis.py +218 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matching.py +327 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matrix.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_project.py +409 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_redundancy.py +35 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py +80 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +168 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +205 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +164 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +20 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +591 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +236 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +282 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +364 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +227 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +96 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +150 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +357 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +130 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +787 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +331 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +150 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +200 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +128 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +209 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +141 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +361 -0
- 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 +923 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py +354 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_closeness_centrality.py +274 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality.py +259 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality_subset.py +147 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_closeness.py +43 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_degree_centrality.py +144 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_dispersion.py +73 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py +186 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_group.py +277 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_harmonic_centrality.py +122 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_katz_centrality.py +345 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_laplacian_centrality.py +220 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_load_centrality.py +344 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_percolation_centrality.py +87 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_reaching.py +140 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_second_order_centrality.py +82 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_subgraph.py +110 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_trophic.py +302 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_voterank.py +64 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +181 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +95 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +172 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +443 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +818 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +732 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +4 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +505 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +565 -0
- 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 +863 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +163 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +28 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +153 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +354 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +171 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +30 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +216 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +79 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +338 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +162 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +220 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +384 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +227 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +452 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +347 -0
- 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 +147 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_bipartitions.py +157 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_centrality.py +85 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_divisive.py +106 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_kclique.py +91 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_label_propagation.py +241 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_leiden.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_local.py +76 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_louvain.py +264 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_lukes.py +152 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_modularity_max.py +340 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_quality.py +139 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_utils.py +26 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +6 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +115 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +394 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +282 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +71 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +359 -0
- 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 +70 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_biconnected.py +248 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_connected.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_semiconnected.py +55 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_strongly_connected.py +193 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_weakly_connected.py +96 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +196 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +11 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +811 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +616 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +408 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +1270 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +592 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +220 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +235 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +152 -0
- 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 +421 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_cuts.py +309 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_disjoint_paths.py +249 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_augmentation.py +502 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_kcomponents.py +488 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcomponents.py +323 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcutsets.py +280 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_stoer_wagner.py +102 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/core.py +588 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +142 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +416 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +1234 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +677 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +1392 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +1095 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +272 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +142 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +268 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +167 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +470 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +11 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +370 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +407 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +238 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +241 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +178 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +611 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +356 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +662 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +425 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +300 -0
- 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 +128 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow.py +573 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow_large_graph.py +155 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_mincost.py +475 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_networksimplex.py +481 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/wlm3.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +194 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +435 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +483 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +57 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +196 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +7 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +1306 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +336 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +1262 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +352 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +308 -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 +719 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphism.py +103 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py +490 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_match_helpers.py +64 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_temporalisomorphvf2.py +212 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_tree_isomorphism.py +202 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp.py +1655 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp_helpers.py +3118 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py +196 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +264 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +1102 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +192 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +2 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +337 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +498 -0
- 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 +77 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_pagerank.py +213 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +687 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +280 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +1148 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +27 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +738 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/tests/test_contraction.py +544 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +78 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +59 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +219 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +155 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +4 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +324 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +468 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +633 -0
- 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 +328 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_binary.py +451 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_product.py +491 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_unary.py +55 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +77 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +73 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +464 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +1463 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +306 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +98 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +167 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +5 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +239 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +264 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +716 -0
- 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 +254 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense.py +212 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense_numpy.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_generic.py +511 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_unweighted.py +149 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_weighted.py +983 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +625 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +2542 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +2107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +966 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +404 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +30 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +296 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +374 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +564 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +406 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_asteroidal.py +23 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_boundary.py +154 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_bridges.py +144 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_broadcasting.py +109 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chains.py +136 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chordal.py +129 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_clique.py +300 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cluster.py +678 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_communicability.py +80 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_core.py +266 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_covering.py +85 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cuts.py +171 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cycles.py +984 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_d_separation.py +340 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dag.py +835 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_measures.py +831 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_regular.py +85 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominance.py +299 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominating.py +115 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_efficiency.py +58 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_euler.py +314 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graph_hashing.py +872 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graphical.py +163 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hierarchy.py +46 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hybrid.py +24 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_isolate.py +26 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_link_prediction.py +615 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_lowest_common_ancestors.py +459 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_matching.py +556 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_max_weight_clique.py +179 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_mis.py +62 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_moral.py +15 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_node_classification.py +140 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_non_randomness.py +60 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_perfect_graph.py +27 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planar_drawing.py +274 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planarity.py +556 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_polynomials.py +57 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_reciprocity.py +37 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_regular.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_richclub.py +149 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_similarity.py +1158 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_simple_paths.py +803 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smallworld.py +76 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smetric.py +8 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_sparsifiers.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_structuralholes.py +191 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_summarization.py +642 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_swap.py +179 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_threshold.py +270 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_time_dependent.py +431 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_tournament.py +161 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_triads.py +248 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_vitality.py +41 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_voronoi.py +103 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_walks.py +54 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_wiener.py +157 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +981 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +142 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +406 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +5 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +90 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +576 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +529 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +185 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +182 -0
- 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 +25 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_bfs.py +203 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_dfs.py +307 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgebfs.py +147 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgedfs.py +131 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +7 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +1042 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +413 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +219 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +1281 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +106 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +273 -0
- 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 +624 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_coding.py +114 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_decomposition.py +79 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_distance_measures.py +99 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_mst.py +934 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_operations.py +53 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_recognition.py +174 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +500 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +76 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +86 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +77 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +278 -0
- package/runtime/python/okstra_vendor/networkx/classes/__init__.py +13 -0
- package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +435 -0
- package/runtime/python/okstra_vendor/networkx/classes/digraph.py +1363 -0
- package/runtime/python/okstra_vendor/networkx/classes/filters.py +95 -0
- package/runtime/python/okstra_vendor/networkx/classes/function.py +1549 -0
- package/runtime/python/okstra_vendor/networkx/classes/graph.py +2082 -0
- package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +269 -0
- package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +977 -0
- package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +1294 -0
- package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +1447 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/dispatch_interface.py +192 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/historical_tests.py +476 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_coreviews.py +362 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph.py +331 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph_historical.py +110 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_filters.py +177 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_function.py +1045 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph.py +950 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph_historical.py +12 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graphviews.py +349 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_multidigraph.py +459 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_multigraph.py +528 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_reportviews.py +1421 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_special.py +131 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_subgraphviews.py +371 -0
- package/runtime/python/okstra_vendor/networkx/conftest.py +261 -0
- package/runtime/python/okstra_vendor/networkx/convert.py +502 -0
- package/runtime/python/okstra_vendor/networkx/convert_matrix.py +1314 -0
- package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +7 -0
- package/runtime/python/okstra_vendor/networkx/drawing/layout.py +2036 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +470 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +570 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +361 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +2978 -0
- 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 +237 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_image_comparison_pylab_mpl.py +229 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_latex.py +285 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_layout.py +631 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pydot.py +146 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pylab.py +1582 -0
- package/runtime/python/okstra_vendor/networkx/exception.py +131 -0
- package/runtime/python/okstra_vendor/networkx/generators/__init__.py +34 -0
- package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
- package/runtime/python/okstra_vendor/networkx/generators/atlas.py +227 -0
- package/runtime/python/okstra_vendor/networkx/generators/classic.py +1091 -0
- package/runtime/python/okstra_vendor/networkx/generators/cographs.py +68 -0
- package/runtime/python/okstra_vendor/networkx/generators/community.py +1070 -0
- package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +886 -0
- package/runtime/python/okstra_vendor/networkx/generators/directed.py +572 -0
- package/runtime/python/okstra_vendor/networkx/generators/duplication.py +174 -0
- package/runtime/python/okstra_vendor/networkx/generators/ego.py +66 -0
- package/runtime/python/okstra_vendor/networkx/generators/expanders.py +499 -0
- package/runtime/python/okstra_vendor/networkx/generators/geometric.py +1037 -0
- package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +163 -0
- package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +443 -0
- package/runtime/python/okstra_vendor/networkx/generators/intersection.py +125 -0
- package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +70 -0
- package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +664 -0
- package/runtime/python/okstra_vendor/networkx/generators/lattice.py +405 -0
- package/runtime/python/okstra_vendor/networkx/generators/line.py +501 -0
- package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +110 -0
- package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +259 -0
- package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +117 -0
- package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +1416 -0
- package/runtime/python/okstra_vendor/networkx/generators/small.py +1070 -0
- package/runtime/python/okstra_vendor/networkx/generators/social.py +554 -0
- package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +120 -0
- package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +54 -0
- package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +131 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_atlas.py +75 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_classic.py +642 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_cographs.py +20 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_community.py +362 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_degree_seq.py +224 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_directed.py +189 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_duplication.py +103 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_ego.py +39 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_expanders.py +182 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_geometric.py +488 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_harary_graph.py +133 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_internet_as_graphs.py +221 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_intersection.py +28 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_interval_graph.py +144 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_joint_degree_seq.py +125 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_lattice.py +264 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_line.py +316 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_mycielski.py +30 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_nonisomorphic_trees.py +82 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_clustered.py +33 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_graphs.py +495 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_small.py +220 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_spectral_graph_forge.py +49 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_stochastic.py +72 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_sudoku.py +92 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_time_series.py +64 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_trees.py +195 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_triads.py +15 -0
- package/runtime/python/okstra_vendor/networkx/generators/time_series.py +74 -0
- package/runtime/python/okstra_vendor/networkx/generators/trees.py +1070 -0
- package/runtime/python/okstra_vendor/networkx/generators/triads.py +94 -0
- package/runtime/python/okstra_vendor/networkx/lazy_imports.py +188 -0
- package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +13 -0
- package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +650 -0
- package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +466 -0
- package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +77 -0
- package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +168 -0
- package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +512 -0
- package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +166 -0
- package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +186 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_algebraic_connectivity.py +400 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_attrmatrix.py +108 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_bethehessian.py +40 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_graphmatrix.py +275 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_laplacian.py +334 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_modularity.py +86 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_spectrum.py +70 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +17 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +330 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +489 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +1084 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +879 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +427 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +1053 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +19 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +156 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +190 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +261 -0
- 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 +78 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_cytoscape.py +78 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_node_link.py +109 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_tree.py +48 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +137 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +108 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +393 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +113 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +286 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +379 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_adjlist.py +354 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_edgelist.py +318 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gexf.py +612 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gml.py +744 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graph6.py +181 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graphml.py +1531 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_leda.py +30 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_p2g.py +63 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_pajek.py +128 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_sparse6.py +166 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_text.py +1742 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/text.py +851 -0
- package/runtime/python/okstra_vendor/networkx/relabel.py +285 -0
- package/runtime/python/okstra_vendor/networkx/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_all_random_functions.py +248 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert.py +321 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_numpy.py +531 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_pandas.py +349 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_scipy.py +281 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_exceptions.py +40 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_import.py +11 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_lazy_imports.py +96 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_relabel.py +349 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_removed_functions_exception_messages.py +8 -0
- package/runtime/python/okstra_vendor/networkx/utils/__init__.py +8 -0
- package/runtime/python/okstra_vendor/networkx/utils/backends.py +2171 -0
- package/runtime/python/okstra_vendor/networkx/utils/configs.py +396 -0
- package/runtime/python/okstra_vendor/networkx/utils/decorators.py +1233 -0
- package/runtime/python/okstra_vendor/networkx/utils/heaps.py +338 -0
- package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +297 -0
- package/runtime/python/okstra_vendor/networkx/utils/misc.py +703 -0
- package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +198 -0
- package/runtime/python/okstra_vendor/networkx/utils/rcm.py +159 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test__init.py +11 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_backends.py +225 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_config.py +263 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_decorators.py +510 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_heaps.py +131 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_mapped_queue.py +268 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_misc.py +393 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_random_sequence.py +53 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_rcm.py +63 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_unionfind.py +55 -0
- package/runtime/python/okstra_vendor/networkx/utils/union_find.py +106 -0
- package/runtime/skills/okstra-graphify/SKILL.md +161 -0
- package/runtime/skills/okstra-inspect/SKILL.md +17 -9
- package/runtime/templates/reports/settings.template.json +4 -0
- package/runtime/validators/forbidden_actions.py +8 -2
- package/runtime/validators/validate_session_conformance.py +26 -5
- package/src/cli-registry.mjs +7 -0
- package/src/commands/graphify.mjs +32 -0
- package/src/commands/lifecycle/doctor.mjs +9 -0
- package/src/lib/skill-catalog.mjs +1 -0
|
@@ -0,0 +1,984 @@
|
|
|
1
|
+
import random
|
|
2
|
+
from itertools import chain, islice, tee
|
|
3
|
+
from math import inf
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
import networkx as nx
|
|
8
|
+
from networkx.algorithms.traversal.edgedfs import FORWARD, REVERSE
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def check_independent(basis):
|
|
12
|
+
if len(basis) == 0:
|
|
13
|
+
return
|
|
14
|
+
|
|
15
|
+
np = pytest.importorskip("numpy")
|
|
16
|
+
sp = pytest.importorskip("scipy") # Required by incidence_matrix
|
|
17
|
+
|
|
18
|
+
H = nx.Graph()
|
|
19
|
+
for b in basis:
|
|
20
|
+
nx.add_cycle(H, b)
|
|
21
|
+
inc = nx.incidence_matrix(H, oriented=True)
|
|
22
|
+
rank = np.linalg.matrix_rank(inc.toarray(), tol=None, hermitian=False)
|
|
23
|
+
assert inc.shape[1] - rank == len(basis)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class TestCycles:
|
|
27
|
+
@classmethod
|
|
28
|
+
def setup_class(cls):
|
|
29
|
+
G = nx.Graph()
|
|
30
|
+
nx.add_cycle(G, [0, 1, 2, 3])
|
|
31
|
+
nx.add_cycle(G, [0, 3, 4, 5])
|
|
32
|
+
nx.add_cycle(G, [0, 1, 6, 7, 8])
|
|
33
|
+
G.add_edge(8, 9)
|
|
34
|
+
cls.G = G
|
|
35
|
+
|
|
36
|
+
def is_cyclic_permutation(self, a, b):
|
|
37
|
+
n = len(a)
|
|
38
|
+
if len(b) != n:
|
|
39
|
+
return False
|
|
40
|
+
l = a + a
|
|
41
|
+
return any(l[i : i + n] == b for i in range(n))
|
|
42
|
+
|
|
43
|
+
def test_cycle_basis(self):
|
|
44
|
+
G = self.G
|
|
45
|
+
cy = nx.cycle_basis(G, 0)
|
|
46
|
+
sort_cy = sorted(sorted(c) for c in cy)
|
|
47
|
+
assert sort_cy == [[0, 1, 2, 3], [0, 1, 6, 7, 8], [0, 3, 4, 5]]
|
|
48
|
+
cy = nx.cycle_basis(G, 1)
|
|
49
|
+
sort_cy = sorted(sorted(c) for c in cy)
|
|
50
|
+
assert sort_cy == [[0, 1, 2, 3], [0, 1, 6, 7, 8], [0, 3, 4, 5]]
|
|
51
|
+
cy = nx.cycle_basis(G, 9)
|
|
52
|
+
sort_cy = sorted(sorted(c) for c in cy)
|
|
53
|
+
assert sort_cy == [[0, 1, 2, 3], [0, 1, 6, 7, 8], [0, 3, 4, 5]]
|
|
54
|
+
# test disconnected graphs
|
|
55
|
+
nx.add_cycle(G, "ABC")
|
|
56
|
+
cy = nx.cycle_basis(G, 9)
|
|
57
|
+
sort_cy = sorted(sorted(c) for c in cy[:-1]) + [sorted(cy[-1])]
|
|
58
|
+
assert sort_cy == [[0, 1, 2, 3], [0, 1, 6, 7, 8], [0, 3, 4, 5], ["A", "B", "C"]]
|
|
59
|
+
|
|
60
|
+
def test_cycle_basis2(self):
|
|
61
|
+
with pytest.raises(nx.NetworkXNotImplemented):
|
|
62
|
+
G = nx.DiGraph()
|
|
63
|
+
cy = nx.cycle_basis(G, 0)
|
|
64
|
+
|
|
65
|
+
def test_cycle_basis3(self):
|
|
66
|
+
with pytest.raises(nx.NetworkXNotImplemented):
|
|
67
|
+
G = nx.MultiGraph()
|
|
68
|
+
cy = nx.cycle_basis(G, 0)
|
|
69
|
+
|
|
70
|
+
def test_cycle_basis_ordered(self):
|
|
71
|
+
# see gh-6654 replace sets with (ordered) dicts
|
|
72
|
+
G = nx.cycle_graph(5)
|
|
73
|
+
G.update(nx.cycle_graph(range(3, 8)))
|
|
74
|
+
cbG = nx.cycle_basis(G)
|
|
75
|
+
|
|
76
|
+
perm = {1: 0, 0: 1} # switch 0 and 1
|
|
77
|
+
H = nx.relabel_nodes(G, perm)
|
|
78
|
+
cbH = [[perm.get(n, n) for n in cyc] for cyc in nx.cycle_basis(H)]
|
|
79
|
+
assert cbG == cbH
|
|
80
|
+
|
|
81
|
+
def test_cycle_basis_self_loop(self):
|
|
82
|
+
"""Tests the function for graphs with self loops"""
|
|
83
|
+
G = nx.Graph()
|
|
84
|
+
nx.add_cycle(G, [0, 1, 2, 3])
|
|
85
|
+
nx.add_cycle(G, [0, 0, 6, 2])
|
|
86
|
+
cy = nx.cycle_basis(G)
|
|
87
|
+
sort_cy = sorted(sorted(c) for c in cy)
|
|
88
|
+
assert sort_cy == [[0], [0, 1, 2], [0, 2, 3], [0, 2, 6]]
|
|
89
|
+
|
|
90
|
+
def test_simple_cycles(self):
|
|
91
|
+
edges = [(0, 0), (0, 1), (0, 2), (1, 2), (2, 0), (2, 1), (2, 2)]
|
|
92
|
+
G = nx.DiGraph(edges)
|
|
93
|
+
cc = sorted(nx.simple_cycles(G))
|
|
94
|
+
ca = [[0], [0, 1, 2], [0, 2], [1, 2], [2]]
|
|
95
|
+
assert len(cc) == len(ca)
|
|
96
|
+
for c in cc:
|
|
97
|
+
assert any(self.is_cyclic_permutation(c, rc) for rc in ca)
|
|
98
|
+
|
|
99
|
+
def test_simple_cycles_singleton(self):
|
|
100
|
+
G = nx.Graph([(0, 0)]) # self-loop
|
|
101
|
+
assert list(nx.simple_cycles(G)) == [[0]]
|
|
102
|
+
|
|
103
|
+
def test_unsortable(self):
|
|
104
|
+
# this test ensures that graphs whose nodes without an intrinsic
|
|
105
|
+
# ordering do not cause issues
|
|
106
|
+
G = nx.DiGraph()
|
|
107
|
+
nx.add_cycle(G, ["a", 1])
|
|
108
|
+
c = list(nx.simple_cycles(G))
|
|
109
|
+
assert len(c) == 1
|
|
110
|
+
|
|
111
|
+
def test_simple_cycles_small(self):
|
|
112
|
+
G = nx.DiGraph()
|
|
113
|
+
nx.add_cycle(G, [1, 2, 3])
|
|
114
|
+
c = sorted(nx.simple_cycles(G))
|
|
115
|
+
assert len(c) == 1
|
|
116
|
+
assert self.is_cyclic_permutation(c[0], [1, 2, 3])
|
|
117
|
+
nx.add_cycle(G, [10, 20, 30])
|
|
118
|
+
cc = sorted(nx.simple_cycles(G))
|
|
119
|
+
assert len(cc) == 2
|
|
120
|
+
ca = [[1, 2, 3], [10, 20, 30]]
|
|
121
|
+
for c in cc:
|
|
122
|
+
assert any(self.is_cyclic_permutation(c, rc) for rc in ca)
|
|
123
|
+
|
|
124
|
+
def test_simple_cycles_empty(self):
|
|
125
|
+
G = nx.DiGraph()
|
|
126
|
+
assert list(nx.simple_cycles(G)) == []
|
|
127
|
+
|
|
128
|
+
def worst_case_graph(self, k):
|
|
129
|
+
# see figure 1 in Johnson's paper
|
|
130
|
+
# this graph has exactly 3k simple cycles
|
|
131
|
+
G = nx.DiGraph()
|
|
132
|
+
for n in range(2, k + 2):
|
|
133
|
+
G.add_edge(1, n)
|
|
134
|
+
G.add_edge(n, k + 2)
|
|
135
|
+
G.add_edge(2 * k + 1, 1)
|
|
136
|
+
for n in range(k + 2, 2 * k + 2):
|
|
137
|
+
G.add_edge(n, 2 * k + 2)
|
|
138
|
+
G.add_edge(n, n + 1)
|
|
139
|
+
G.add_edge(2 * k + 3, k + 2)
|
|
140
|
+
for n in range(2 * k + 3, 3 * k + 3):
|
|
141
|
+
G.add_edge(2 * k + 2, n)
|
|
142
|
+
G.add_edge(n, 3 * k + 3)
|
|
143
|
+
G.add_edge(3 * k + 3, 2 * k + 2)
|
|
144
|
+
return G
|
|
145
|
+
|
|
146
|
+
def test_worst_case_graph(self):
|
|
147
|
+
# see figure 1 in Johnson's paper
|
|
148
|
+
for k in range(3, 10):
|
|
149
|
+
G = self.worst_case_graph(k)
|
|
150
|
+
l = len(list(nx.simple_cycles(G)))
|
|
151
|
+
assert l == 3 * k
|
|
152
|
+
|
|
153
|
+
def test_recursive_simple_and_not(self):
|
|
154
|
+
for k in range(2, 10):
|
|
155
|
+
G = self.worst_case_graph(k)
|
|
156
|
+
cc = sorted(nx.simple_cycles(G))
|
|
157
|
+
rcc = sorted(nx.recursive_simple_cycles(G))
|
|
158
|
+
assert len(cc) == len(rcc)
|
|
159
|
+
for c in cc:
|
|
160
|
+
assert any(self.is_cyclic_permutation(c, r) for r in rcc)
|
|
161
|
+
for rc in rcc:
|
|
162
|
+
assert any(self.is_cyclic_permutation(rc, c) for c in cc)
|
|
163
|
+
|
|
164
|
+
def test_simple_graph_with_reported_bug(self):
|
|
165
|
+
G = nx.DiGraph()
|
|
166
|
+
edges = [
|
|
167
|
+
(0, 2),
|
|
168
|
+
(0, 3),
|
|
169
|
+
(1, 0),
|
|
170
|
+
(1, 3),
|
|
171
|
+
(2, 1),
|
|
172
|
+
(2, 4),
|
|
173
|
+
(3, 2),
|
|
174
|
+
(3, 4),
|
|
175
|
+
(4, 0),
|
|
176
|
+
(4, 1),
|
|
177
|
+
(4, 5),
|
|
178
|
+
(5, 0),
|
|
179
|
+
(5, 1),
|
|
180
|
+
(5, 2),
|
|
181
|
+
(5, 3),
|
|
182
|
+
]
|
|
183
|
+
G.add_edges_from(edges)
|
|
184
|
+
cc = sorted(nx.simple_cycles(G))
|
|
185
|
+
assert len(cc) == 26
|
|
186
|
+
rcc = sorted(nx.recursive_simple_cycles(G))
|
|
187
|
+
assert len(cc) == len(rcc)
|
|
188
|
+
for c in cc:
|
|
189
|
+
assert any(self.is_cyclic_permutation(c, rc) for rc in rcc)
|
|
190
|
+
for rc in rcc:
|
|
191
|
+
assert any(self.is_cyclic_permutation(rc, c) for c in cc)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def pairwise(iterable):
|
|
195
|
+
a, b = tee(iterable)
|
|
196
|
+
next(b, None)
|
|
197
|
+
return zip(a, b)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def cycle_edges(c):
|
|
201
|
+
return pairwise(chain(c, islice(c, 1)))
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def directed_cycle_edgeset(c):
|
|
205
|
+
return frozenset(cycle_edges(c))
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def undirected_cycle_edgeset(c):
|
|
209
|
+
if len(c) == 1:
|
|
210
|
+
return frozenset(cycle_edges(c))
|
|
211
|
+
return frozenset(map(frozenset, cycle_edges(c)))
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def multigraph_cycle_edgeset(c):
|
|
215
|
+
if len(c) <= 2:
|
|
216
|
+
return frozenset(cycle_edges(c))
|
|
217
|
+
else:
|
|
218
|
+
return frozenset(map(frozenset, cycle_edges(c)))
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class TestCycleEnumeration:
|
|
222
|
+
@staticmethod
|
|
223
|
+
def K(n):
|
|
224
|
+
return nx.complete_graph(n)
|
|
225
|
+
|
|
226
|
+
@staticmethod
|
|
227
|
+
def D(n):
|
|
228
|
+
return nx.complete_graph(n).to_directed()
|
|
229
|
+
|
|
230
|
+
@staticmethod
|
|
231
|
+
def edgeset_function(g):
|
|
232
|
+
if g.is_directed():
|
|
233
|
+
return directed_cycle_edgeset
|
|
234
|
+
elif g.is_multigraph():
|
|
235
|
+
return multigraph_cycle_edgeset
|
|
236
|
+
else:
|
|
237
|
+
return undirected_cycle_edgeset
|
|
238
|
+
|
|
239
|
+
def check_cycle(self, g, c, es, cache, source, original_c, length_bound, chordless):
|
|
240
|
+
if length_bound is not None and len(c) > length_bound:
|
|
241
|
+
raise RuntimeError(
|
|
242
|
+
f"computed cycle {original_c} exceeds length bound {length_bound}"
|
|
243
|
+
)
|
|
244
|
+
if source == "computed":
|
|
245
|
+
if es in cache:
|
|
246
|
+
raise RuntimeError(
|
|
247
|
+
f"computed cycle {original_c} has already been found!"
|
|
248
|
+
)
|
|
249
|
+
else:
|
|
250
|
+
cache[es] = tuple(original_c)
|
|
251
|
+
else:
|
|
252
|
+
if es in cache:
|
|
253
|
+
cache.pop(es)
|
|
254
|
+
else:
|
|
255
|
+
raise RuntimeError(f"expected cycle {original_c} was not computed")
|
|
256
|
+
|
|
257
|
+
if not all(g.has_edge(*e) for e in es):
|
|
258
|
+
raise RuntimeError(
|
|
259
|
+
f"{source} claimed cycle {original_c} is not a cycle of g"
|
|
260
|
+
)
|
|
261
|
+
if chordless and len(g.subgraph(c).edges) > len(c):
|
|
262
|
+
raise RuntimeError(f"{source} cycle {original_c} is not chordless")
|
|
263
|
+
|
|
264
|
+
def check_cycle_algorithm(
|
|
265
|
+
self,
|
|
266
|
+
g,
|
|
267
|
+
expected_cycles,
|
|
268
|
+
length_bound=None,
|
|
269
|
+
chordless=False,
|
|
270
|
+
algorithm=None,
|
|
271
|
+
):
|
|
272
|
+
if algorithm is None:
|
|
273
|
+
algorithm = nx.chordless_cycles if chordless else nx.simple_cycles
|
|
274
|
+
|
|
275
|
+
# note: we shuffle the labels of g to rule out accidentally-correct
|
|
276
|
+
# behavior which occurred during the development of chordless cycle
|
|
277
|
+
# enumeration algorithms
|
|
278
|
+
|
|
279
|
+
relabel = list(range(len(g)))
|
|
280
|
+
rng = random.Random(42)
|
|
281
|
+
rng.shuffle(relabel)
|
|
282
|
+
label = dict(zip(g, relabel))
|
|
283
|
+
unlabel = dict(zip(relabel, g))
|
|
284
|
+
h = nx.relabel_nodes(g, label, copy=True)
|
|
285
|
+
|
|
286
|
+
edgeset = self.edgeset_function(h)
|
|
287
|
+
|
|
288
|
+
params = {}
|
|
289
|
+
if length_bound is not None:
|
|
290
|
+
params["length_bound"] = length_bound
|
|
291
|
+
|
|
292
|
+
cycle_cache = {}
|
|
293
|
+
for c in algorithm(h, **params):
|
|
294
|
+
original_c = [unlabel[x] for x in c]
|
|
295
|
+
es = edgeset(c)
|
|
296
|
+
self.check_cycle(
|
|
297
|
+
h, c, es, cycle_cache, "computed", original_c, length_bound, chordless
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
if isinstance(expected_cycles, int):
|
|
301
|
+
if len(cycle_cache) != expected_cycles:
|
|
302
|
+
raise RuntimeError(
|
|
303
|
+
f"expected {expected_cycles} cycles, got {len(cycle_cache)}"
|
|
304
|
+
)
|
|
305
|
+
return
|
|
306
|
+
for original_c in expected_cycles:
|
|
307
|
+
c = [label[x] for x in original_c]
|
|
308
|
+
es = edgeset(c)
|
|
309
|
+
self.check_cycle(
|
|
310
|
+
h, c, es, cycle_cache, "expected", original_c, length_bound, chordless
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
if len(cycle_cache):
|
|
314
|
+
for c in cycle_cache.values():
|
|
315
|
+
raise RuntimeError(
|
|
316
|
+
f"computed cycle {c} is valid but not in the expected cycle set!"
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
def check_cycle_enumeration_integer_sequence(
|
|
320
|
+
self,
|
|
321
|
+
g_family,
|
|
322
|
+
cycle_counts,
|
|
323
|
+
length_bound=None,
|
|
324
|
+
chordless=False,
|
|
325
|
+
algorithm=None,
|
|
326
|
+
):
|
|
327
|
+
for g, num_cycles in zip(g_family, cycle_counts):
|
|
328
|
+
self.check_cycle_algorithm(
|
|
329
|
+
g,
|
|
330
|
+
num_cycles,
|
|
331
|
+
length_bound=length_bound,
|
|
332
|
+
chordless=chordless,
|
|
333
|
+
algorithm=algorithm,
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
def test_directed_chordless_cycle_digons(self):
|
|
337
|
+
g = nx.DiGraph()
|
|
338
|
+
nx.add_cycle(g, range(5))
|
|
339
|
+
nx.add_cycle(g, range(5)[::-1])
|
|
340
|
+
g.add_edge(0, 0)
|
|
341
|
+
expected_cycles = [(0,), (1, 2), (2, 3), (3, 4)]
|
|
342
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True)
|
|
343
|
+
|
|
344
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True, length_bound=2)
|
|
345
|
+
|
|
346
|
+
expected_cycles = [c for c in expected_cycles if len(c) < 2]
|
|
347
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True, length_bound=1)
|
|
348
|
+
|
|
349
|
+
def test_chordless_cycles_multigraph_self_loops(self):
|
|
350
|
+
G = nx.MultiGraph([(1, 1), (2, 2), (1, 2), (1, 2)])
|
|
351
|
+
expected_cycles = [[1], [2]]
|
|
352
|
+
self.check_cycle_algorithm(G, expected_cycles, chordless=True)
|
|
353
|
+
|
|
354
|
+
G.add_edges_from([(2, 3), (3, 4), (3, 4), (1, 3)])
|
|
355
|
+
expected_cycles = [[1], [2], [3, 4]]
|
|
356
|
+
self.check_cycle_algorithm(G, expected_cycles, chordless=True)
|
|
357
|
+
|
|
358
|
+
def test_directed_chordless_cycle_undirected(self):
|
|
359
|
+
g = nx.DiGraph([(1, 2), (2, 3), (3, 4), (4, 5), (5, 0), (5, 1), (0, 2)])
|
|
360
|
+
expected_cycles = [(0, 2, 3, 4, 5), (1, 2, 3, 4, 5)]
|
|
361
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True)
|
|
362
|
+
|
|
363
|
+
g = nx.DiGraph()
|
|
364
|
+
nx.add_cycle(g, range(5))
|
|
365
|
+
nx.add_cycle(g, range(4, 9))
|
|
366
|
+
g.add_edge(7, 3)
|
|
367
|
+
expected_cycles = [(0, 1, 2, 3, 4), (3, 4, 5, 6, 7), (4, 5, 6, 7, 8)]
|
|
368
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True)
|
|
369
|
+
|
|
370
|
+
g.add_edge(3, 7)
|
|
371
|
+
expected_cycles = [(0, 1, 2, 3, 4), (3, 7), (4, 5, 6, 7, 8)]
|
|
372
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True)
|
|
373
|
+
|
|
374
|
+
expected_cycles = [(3, 7)]
|
|
375
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True, length_bound=4)
|
|
376
|
+
|
|
377
|
+
g.remove_edge(7, 3)
|
|
378
|
+
expected_cycles = [(0, 1, 2, 3, 4), (4, 5, 6, 7, 8)]
|
|
379
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True)
|
|
380
|
+
|
|
381
|
+
g = nx.DiGraph((i, j) for i in range(10) for j in range(i))
|
|
382
|
+
expected_cycles = []
|
|
383
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True)
|
|
384
|
+
|
|
385
|
+
def test_chordless_cycles_directed(self):
|
|
386
|
+
G = nx.DiGraph()
|
|
387
|
+
nx.add_cycle(G, range(5))
|
|
388
|
+
nx.add_cycle(G, range(4, 12))
|
|
389
|
+
expected = [[*range(5)], [*range(4, 12)]]
|
|
390
|
+
self.check_cycle_algorithm(G, expected, chordless=True)
|
|
391
|
+
self.check_cycle_algorithm(
|
|
392
|
+
G, [c for c in expected if len(c) <= 5], length_bound=5, chordless=True
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
G.add_edge(7, 3)
|
|
396
|
+
expected.append([*range(3, 8)])
|
|
397
|
+
self.check_cycle_algorithm(G, expected, chordless=True)
|
|
398
|
+
self.check_cycle_algorithm(
|
|
399
|
+
G, [c for c in expected if len(c) <= 5], length_bound=5, chordless=True
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
G.add_edge(3, 7)
|
|
403
|
+
expected[-1] = [7, 3]
|
|
404
|
+
self.check_cycle_algorithm(G, expected, chordless=True)
|
|
405
|
+
self.check_cycle_algorithm(
|
|
406
|
+
G, [c for c in expected if len(c) <= 5], length_bound=5, chordless=True
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
expected.pop()
|
|
410
|
+
G.remove_edge(7, 3)
|
|
411
|
+
self.check_cycle_algorithm(G, expected, chordless=True)
|
|
412
|
+
self.check_cycle_algorithm(
|
|
413
|
+
G, [c for c in expected if len(c) <= 5], length_bound=5, chordless=True
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
def test_directed_chordless_cycle_diclique(self):
|
|
417
|
+
g_family = [self.D(n) for n in range(10)]
|
|
418
|
+
expected_cycles = [(n * n - n) // 2 for n in range(10)]
|
|
419
|
+
self.check_cycle_enumeration_integer_sequence(
|
|
420
|
+
g_family, expected_cycles, chordless=True
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
expected_cycles = [(n * n - n) // 2 for n in range(10)]
|
|
424
|
+
self.check_cycle_enumeration_integer_sequence(
|
|
425
|
+
g_family, expected_cycles, length_bound=2
|
|
426
|
+
)
|
|
427
|
+
|
|
428
|
+
def test_directed_chordless_loop_blockade(self):
|
|
429
|
+
g = nx.DiGraph((i, i) for i in range(10))
|
|
430
|
+
nx.add_cycle(g, range(10))
|
|
431
|
+
expected_cycles = [(i,) for i in range(10)]
|
|
432
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True)
|
|
433
|
+
|
|
434
|
+
self.check_cycle_algorithm(g, expected_cycles, length_bound=1)
|
|
435
|
+
|
|
436
|
+
g = nx.MultiDiGraph(g)
|
|
437
|
+
g.add_edges_from((i, i) for i in range(0, 10, 2))
|
|
438
|
+
expected_cycles = [(i,) for i in range(1, 10, 2)]
|
|
439
|
+
self.check_cycle_algorithm(g, expected_cycles, chordless=True)
|
|
440
|
+
|
|
441
|
+
def test_simple_cycles_notable_clique_sequences(self):
|
|
442
|
+
# A000292: Number of labeled graphs on n+3 nodes that are triangles.
|
|
443
|
+
g_family = [self.K(n) for n in range(2, 12)]
|
|
444
|
+
expected = [0, 1, 4, 10, 20, 35, 56, 84, 120, 165, 220]
|
|
445
|
+
self.check_cycle_enumeration_integer_sequence(
|
|
446
|
+
g_family, expected, length_bound=3
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
def triangles(g, **kwargs):
|
|
450
|
+
yield from (c for c in nx.simple_cycles(g, **kwargs) if len(c) == 3)
|
|
451
|
+
|
|
452
|
+
# directed complete graphs have twice as many triangles thanks to reversal
|
|
453
|
+
g_family = [self.D(n) for n in range(2, 12)]
|
|
454
|
+
expected = [2 * e for e in expected]
|
|
455
|
+
self.check_cycle_enumeration_integer_sequence(
|
|
456
|
+
g_family, expected, length_bound=3, algorithm=triangles
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
def four_cycles(g, **kwargs):
|
|
460
|
+
yield from (c for c in nx.simple_cycles(g, **kwargs) if len(c) == 4)
|
|
461
|
+
|
|
462
|
+
# A050534: the number of 4-cycles in the complete graph K_{n+1}
|
|
463
|
+
expected = [0, 0, 0, 3, 15, 45, 105, 210, 378, 630, 990]
|
|
464
|
+
g_family = [self.K(n) for n in range(1, 12)]
|
|
465
|
+
self.check_cycle_enumeration_integer_sequence(
|
|
466
|
+
g_family, expected, length_bound=4, algorithm=four_cycles
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
# directed complete graphs have twice as many 4-cycles thanks to reversal
|
|
470
|
+
expected = [2 * e for e in expected]
|
|
471
|
+
g_family = [self.D(n) for n in range(1, 15)]
|
|
472
|
+
self.check_cycle_enumeration_integer_sequence(
|
|
473
|
+
g_family, expected, length_bound=4, algorithm=four_cycles
|
|
474
|
+
)
|
|
475
|
+
|
|
476
|
+
# A006231: the number of elementary circuits in a complete directed graph with n nodes
|
|
477
|
+
expected = [0, 1, 5, 20, 84, 409, 2365]
|
|
478
|
+
g_family = [self.D(n) for n in range(1, 8)]
|
|
479
|
+
self.check_cycle_enumeration_integer_sequence(g_family, expected)
|
|
480
|
+
|
|
481
|
+
# A002807: Number of cycles in the complete graph on n nodes K_{n}.
|
|
482
|
+
expected = [0, 0, 0, 1, 7, 37, 197, 1172]
|
|
483
|
+
g_family = [self.K(n) for n in range(8)]
|
|
484
|
+
self.check_cycle_enumeration_integer_sequence(g_family, expected)
|
|
485
|
+
|
|
486
|
+
def test_directed_chordless_cycle_parallel_multiedges(self):
|
|
487
|
+
g = nx.MultiGraph()
|
|
488
|
+
|
|
489
|
+
nx.add_cycle(g, range(5))
|
|
490
|
+
expected = [[*range(5)]]
|
|
491
|
+
self.check_cycle_algorithm(g, expected, chordless=True)
|
|
492
|
+
|
|
493
|
+
nx.add_cycle(g, range(5))
|
|
494
|
+
expected = [*cycle_edges(range(5))]
|
|
495
|
+
self.check_cycle_algorithm(g, expected, chordless=True)
|
|
496
|
+
|
|
497
|
+
nx.add_cycle(g, range(5))
|
|
498
|
+
expected = []
|
|
499
|
+
self.check_cycle_algorithm(g, expected, chordless=True)
|
|
500
|
+
|
|
501
|
+
g = nx.MultiDiGraph()
|
|
502
|
+
|
|
503
|
+
nx.add_cycle(g, range(5))
|
|
504
|
+
expected = [[*range(5)]]
|
|
505
|
+
self.check_cycle_algorithm(g, expected, chordless=True)
|
|
506
|
+
|
|
507
|
+
nx.add_cycle(g, range(5))
|
|
508
|
+
self.check_cycle_algorithm(g, [], chordless=True)
|
|
509
|
+
|
|
510
|
+
nx.add_cycle(g, range(5))
|
|
511
|
+
self.check_cycle_algorithm(g, [], chordless=True)
|
|
512
|
+
|
|
513
|
+
g = nx.MultiDiGraph()
|
|
514
|
+
|
|
515
|
+
nx.add_cycle(g, range(5))
|
|
516
|
+
nx.add_cycle(g, range(5)[::-1])
|
|
517
|
+
expected = [*cycle_edges(range(5))]
|
|
518
|
+
self.check_cycle_algorithm(g, expected, chordless=True)
|
|
519
|
+
|
|
520
|
+
nx.add_cycle(g, range(5))
|
|
521
|
+
self.check_cycle_algorithm(g, [], chordless=True)
|
|
522
|
+
|
|
523
|
+
def test_chordless_cycles_graph(self):
|
|
524
|
+
G = nx.Graph()
|
|
525
|
+
nx.add_cycle(G, range(5))
|
|
526
|
+
nx.add_cycle(G, range(4, 12))
|
|
527
|
+
expected = [[*range(5)], [*range(4, 12)]]
|
|
528
|
+
self.check_cycle_algorithm(G, expected, chordless=True)
|
|
529
|
+
self.check_cycle_algorithm(
|
|
530
|
+
G, [c for c in expected if len(c) <= 5], length_bound=5, chordless=True
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
G.add_edge(7, 3)
|
|
534
|
+
expected.append([*range(3, 8)])
|
|
535
|
+
expected.append([4, 3, 7, 8, 9, 10, 11])
|
|
536
|
+
self.check_cycle_algorithm(G, expected, chordless=True)
|
|
537
|
+
self.check_cycle_algorithm(
|
|
538
|
+
G, [c for c in expected if len(c) <= 5], length_bound=5, chordless=True
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
def test_chordless_cycles_giant_hamiltonian(self):
|
|
542
|
+
# ... o - e - o - e - o ... # o = odd, e = even
|
|
543
|
+
# ... ---/ \-----/ \--- ... # <-- "long" edges
|
|
544
|
+
#
|
|
545
|
+
# each long edge belongs to exactly one triangle, and one giant cycle
|
|
546
|
+
# of length n/2. The remaining edges each belong to a triangle
|
|
547
|
+
|
|
548
|
+
n = 1000
|
|
549
|
+
assert n % 2 == 0
|
|
550
|
+
G = nx.Graph()
|
|
551
|
+
for v in range(n):
|
|
552
|
+
if not v % 2:
|
|
553
|
+
G.add_edge(v, (v + 2) % n)
|
|
554
|
+
G.add_edge(v, (v + 1) % n)
|
|
555
|
+
|
|
556
|
+
expected = [[*range(0, n, 2)]] + [
|
|
557
|
+
[x % n for x in range(i, i + 3)] for i in range(0, n, 2)
|
|
558
|
+
]
|
|
559
|
+
self.check_cycle_algorithm(G, expected, chordless=True)
|
|
560
|
+
self.check_cycle_algorithm(
|
|
561
|
+
G, [c for c in expected if len(c) <= 3], length_bound=3, chordless=True
|
|
562
|
+
)
|
|
563
|
+
|
|
564
|
+
# ... o -> e -> o -> e -> o ... # o = odd, e = even
|
|
565
|
+
# ... <---/ \---<---/ \---< ... # <-- "long" edges
|
|
566
|
+
#
|
|
567
|
+
# this time, we orient the short and long edges in opposition
|
|
568
|
+
# the cycle structure of this graph is the same, but we need to reverse
|
|
569
|
+
# the long one in our representation. Also, we need to drop the size
|
|
570
|
+
# because our partitioning algorithm uses strongly connected components
|
|
571
|
+
# instead of separating graphs by their strong articulation points
|
|
572
|
+
|
|
573
|
+
n = 100
|
|
574
|
+
assert n % 2 == 0
|
|
575
|
+
G = nx.DiGraph()
|
|
576
|
+
for v in range(n):
|
|
577
|
+
G.add_edge(v, (v + 1) % n)
|
|
578
|
+
if not v % 2:
|
|
579
|
+
G.add_edge((v + 2) % n, v)
|
|
580
|
+
|
|
581
|
+
expected = [[*range(n - 2, -2, -2)]] + [
|
|
582
|
+
[x % n for x in range(i, i + 3)] for i in range(0, n, 2)
|
|
583
|
+
]
|
|
584
|
+
self.check_cycle_algorithm(G, expected, chordless=True)
|
|
585
|
+
self.check_cycle_algorithm(
|
|
586
|
+
G, [c for c in expected if len(c) <= 3], length_bound=3, chordless=True
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
def test_simple_cycles_acyclic_tournament(self):
|
|
590
|
+
n = 10
|
|
591
|
+
G = nx.DiGraph((x, y) for x in range(n) for y in range(x))
|
|
592
|
+
self.check_cycle_algorithm(G, [])
|
|
593
|
+
self.check_cycle_algorithm(G, [], chordless=True)
|
|
594
|
+
|
|
595
|
+
for k in range(n + 1):
|
|
596
|
+
self.check_cycle_algorithm(G, [], length_bound=k)
|
|
597
|
+
self.check_cycle_algorithm(G, [], length_bound=k, chordless=True)
|
|
598
|
+
|
|
599
|
+
def test_simple_cycles_graph(self):
|
|
600
|
+
testG = nx.cycle_graph(8)
|
|
601
|
+
cyc1 = tuple(range(8))
|
|
602
|
+
self.check_cycle_algorithm(testG, [cyc1])
|
|
603
|
+
|
|
604
|
+
testG.add_edge(4, -1)
|
|
605
|
+
nx.add_path(testG, [3, -2, -3, -4])
|
|
606
|
+
self.check_cycle_algorithm(testG, [cyc1])
|
|
607
|
+
|
|
608
|
+
testG.update(nx.cycle_graph(range(8, 16)))
|
|
609
|
+
cyc2 = tuple(range(8, 16))
|
|
610
|
+
self.check_cycle_algorithm(testG, [cyc1, cyc2])
|
|
611
|
+
|
|
612
|
+
testG.update(nx.cycle_graph(range(4, 12)))
|
|
613
|
+
cyc3 = tuple(range(4, 12))
|
|
614
|
+
expected = {
|
|
615
|
+
(0, 1, 2, 3, 4, 5, 6, 7), # cyc1
|
|
616
|
+
(8, 9, 10, 11, 12, 13, 14, 15), # cyc2
|
|
617
|
+
(4, 5, 6, 7, 8, 9, 10, 11), # cyc3
|
|
618
|
+
(4, 5, 6, 7, 8, 15, 14, 13, 12, 11), # cyc2 + cyc3
|
|
619
|
+
(0, 1, 2, 3, 4, 11, 10, 9, 8, 7), # cyc1 + cyc3
|
|
620
|
+
(0, 1, 2, 3, 4, 11, 12, 13, 14, 15, 8, 7), # cyc1 + cyc2 + cyc3
|
|
621
|
+
}
|
|
622
|
+
self.check_cycle_algorithm(testG, expected)
|
|
623
|
+
assert len(expected) == (2**3 - 1) - 1 # 1 disjoint comb: cyc1 + cyc2
|
|
624
|
+
|
|
625
|
+
# Basis size = 5 (2 loops overlapping gives 5 small loops
|
|
626
|
+
# E
|
|
627
|
+
# / \ Note: A-F = 10-15
|
|
628
|
+
# 1-2-3-4-5
|
|
629
|
+
# / | | \ cyc1=012DAB -- left
|
|
630
|
+
# 0 D F 6 cyc2=234E -- top
|
|
631
|
+
# \ | | / cyc3=45678F -- right
|
|
632
|
+
# B-A-9-8-7 cyc4=89AC -- bottom
|
|
633
|
+
# \ / cyc5=234F89AD -- middle
|
|
634
|
+
# C
|
|
635
|
+
#
|
|
636
|
+
# combinations of 5 basis elements: 2^5 - 1 (one includes no cycles)
|
|
637
|
+
#
|
|
638
|
+
# disjoint combs: (11 total) not simple cycles
|
|
639
|
+
# Any pair not including cyc5 => choose(4, 2) = 6
|
|
640
|
+
# Any triple not including cyc5 => choose(4, 3) = 4
|
|
641
|
+
# Any quad not including cyc5 => choose(4, 4) = 1
|
|
642
|
+
#
|
|
643
|
+
# we expect 31 - 11 = 20 simple cycles
|
|
644
|
+
#
|
|
645
|
+
testG = nx.cycle_graph(12)
|
|
646
|
+
testG.update(nx.cycle_graph([12, 10, 13, 2, 14, 4, 15, 8]).edges)
|
|
647
|
+
expected = (2**5 - 1) - 11 # 11 disjoint combinations
|
|
648
|
+
self.check_cycle_algorithm(testG, expected)
|
|
649
|
+
|
|
650
|
+
def test_simple_cycles_bounded(self):
|
|
651
|
+
# iteratively construct a cluster of nested cycles running in the same direction
|
|
652
|
+
# there should be one cycle of every length
|
|
653
|
+
d = nx.DiGraph()
|
|
654
|
+
expected = []
|
|
655
|
+
for n in range(10):
|
|
656
|
+
nx.add_cycle(d, range(n))
|
|
657
|
+
expected.append(n)
|
|
658
|
+
for k, e in enumerate(expected):
|
|
659
|
+
self.check_cycle_algorithm(d, e, length_bound=k)
|
|
660
|
+
|
|
661
|
+
# iteratively construct a path of undirected cycles, connected at articulation
|
|
662
|
+
# points. there should be one cycle of every length except 2: no digons
|
|
663
|
+
g = nx.Graph()
|
|
664
|
+
top = 0
|
|
665
|
+
expected = []
|
|
666
|
+
for n in range(10):
|
|
667
|
+
expected.append(n if n < 2 else n - 1)
|
|
668
|
+
if n == 2:
|
|
669
|
+
# no digons in undirected graphs
|
|
670
|
+
continue
|
|
671
|
+
nx.add_cycle(g, range(top, top + n))
|
|
672
|
+
top += n
|
|
673
|
+
for k, e in enumerate(expected):
|
|
674
|
+
self.check_cycle_algorithm(g, e, length_bound=k)
|
|
675
|
+
|
|
676
|
+
def test_simple_cycles_bound_corner_cases(self):
|
|
677
|
+
G = nx.cycle_graph(4)
|
|
678
|
+
DG = nx.cycle_graph(4, create_using=nx.DiGraph)
|
|
679
|
+
assert list(nx.simple_cycles(G, length_bound=0)) == []
|
|
680
|
+
assert list(nx.simple_cycles(DG, length_bound=0)) == []
|
|
681
|
+
assert list(nx.chordless_cycles(G, length_bound=0)) == []
|
|
682
|
+
assert list(nx.chordless_cycles(DG, length_bound=0)) == []
|
|
683
|
+
|
|
684
|
+
def test_simple_cycles_bound_error(self):
|
|
685
|
+
with pytest.raises(ValueError):
|
|
686
|
+
G = nx.DiGraph()
|
|
687
|
+
for c in nx.simple_cycles(G, -1):
|
|
688
|
+
assert False
|
|
689
|
+
|
|
690
|
+
with pytest.raises(ValueError):
|
|
691
|
+
G = nx.Graph()
|
|
692
|
+
for c in nx.simple_cycles(G, -1):
|
|
693
|
+
assert False
|
|
694
|
+
|
|
695
|
+
with pytest.raises(ValueError):
|
|
696
|
+
G = nx.Graph()
|
|
697
|
+
for c in nx.chordless_cycles(G, -1):
|
|
698
|
+
assert False
|
|
699
|
+
|
|
700
|
+
with pytest.raises(ValueError):
|
|
701
|
+
G = nx.DiGraph()
|
|
702
|
+
for c in nx.chordless_cycles(G, -1):
|
|
703
|
+
assert False
|
|
704
|
+
|
|
705
|
+
def test_chordless_cycles_clique(self):
|
|
706
|
+
g_family = [self.K(n) for n in range(2, 15)]
|
|
707
|
+
expected = [0, 1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364]
|
|
708
|
+
self.check_cycle_enumeration_integer_sequence(
|
|
709
|
+
g_family, expected, chordless=True
|
|
710
|
+
)
|
|
711
|
+
|
|
712
|
+
# directed cliques have as many digons as undirected graphs have edges
|
|
713
|
+
expected = [(n * n - n) // 2 for n in range(15)]
|
|
714
|
+
g_family = [self.D(n) for n in range(15)]
|
|
715
|
+
self.check_cycle_enumeration_integer_sequence(
|
|
716
|
+
g_family, expected, chordless=True
|
|
717
|
+
)
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
# These tests might fail with hash randomization since they depend on
|
|
721
|
+
# edge_dfs. For more information, see the comments in:
|
|
722
|
+
# networkx/algorithms/traversal/tests/test_edgedfs.py
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
class TestFindCycle:
|
|
726
|
+
@classmethod
|
|
727
|
+
def setup_class(cls):
|
|
728
|
+
cls.nodes = [0, 1, 2, 3]
|
|
729
|
+
cls.edges = [(-1, 0), (0, 1), (1, 0), (1, 0), (2, 1), (3, 1)]
|
|
730
|
+
|
|
731
|
+
def test_graph_nocycle(self):
|
|
732
|
+
G = nx.Graph(self.edges)
|
|
733
|
+
pytest.raises(nx.exception.NetworkXNoCycle, nx.find_cycle, G, self.nodes)
|
|
734
|
+
|
|
735
|
+
def test_graph_cycle(self):
|
|
736
|
+
G = nx.Graph(self.edges)
|
|
737
|
+
G.add_edge(2, 0)
|
|
738
|
+
x = list(nx.find_cycle(G, self.nodes))
|
|
739
|
+
x_ = [(0, 1), (1, 2), (2, 0)]
|
|
740
|
+
assert x == x_
|
|
741
|
+
|
|
742
|
+
def test_graph_orientation_none(self):
|
|
743
|
+
G = nx.Graph(self.edges)
|
|
744
|
+
G.add_edge(2, 0)
|
|
745
|
+
x = list(nx.find_cycle(G, self.nodes, orientation=None))
|
|
746
|
+
x_ = [(0, 1), (1, 2), (2, 0)]
|
|
747
|
+
assert x == x_
|
|
748
|
+
|
|
749
|
+
def test_graph_orientation_original(self):
|
|
750
|
+
G = nx.Graph(self.edges)
|
|
751
|
+
G.add_edge(2, 0)
|
|
752
|
+
x = list(nx.find_cycle(G, self.nodes, orientation="original"))
|
|
753
|
+
x_ = [(0, 1, FORWARD), (1, 2, FORWARD), (2, 0, FORWARD)]
|
|
754
|
+
assert x == x_
|
|
755
|
+
|
|
756
|
+
def test_digraph(self):
|
|
757
|
+
G = nx.DiGraph(self.edges)
|
|
758
|
+
x = list(nx.find_cycle(G, self.nodes))
|
|
759
|
+
x_ = [(0, 1), (1, 0)]
|
|
760
|
+
assert x == x_
|
|
761
|
+
|
|
762
|
+
def test_digraph_orientation_none(self):
|
|
763
|
+
G = nx.DiGraph(self.edges)
|
|
764
|
+
x = list(nx.find_cycle(G, self.nodes, orientation=None))
|
|
765
|
+
x_ = [(0, 1), (1, 0)]
|
|
766
|
+
assert x == x_
|
|
767
|
+
|
|
768
|
+
def test_digraph_orientation_original(self):
|
|
769
|
+
G = nx.DiGraph(self.edges)
|
|
770
|
+
x = list(nx.find_cycle(G, self.nodes, orientation="original"))
|
|
771
|
+
x_ = [(0, 1, FORWARD), (1, 0, FORWARD)]
|
|
772
|
+
assert x == x_
|
|
773
|
+
|
|
774
|
+
def test_multigraph(self):
|
|
775
|
+
G = nx.MultiGraph(self.edges)
|
|
776
|
+
x = list(nx.find_cycle(G, self.nodes))
|
|
777
|
+
x_ = [(0, 1, 0), (1, 0, 1)] # or (1, 0, 2)
|
|
778
|
+
# Hash randomization...could be any edge.
|
|
779
|
+
assert x[0] == x_[0]
|
|
780
|
+
assert x[1][:2] == x_[1][:2]
|
|
781
|
+
|
|
782
|
+
def test_multidigraph(self):
|
|
783
|
+
G = nx.MultiDiGraph(self.edges)
|
|
784
|
+
x = list(nx.find_cycle(G, self.nodes))
|
|
785
|
+
x_ = [(0, 1, 0), (1, 0, 0)] # (1, 0, 1)
|
|
786
|
+
assert x[0] == x_[0]
|
|
787
|
+
assert x[1][:2] == x_[1][:2]
|
|
788
|
+
|
|
789
|
+
def test_digraph_ignore(self):
|
|
790
|
+
G = nx.DiGraph(self.edges)
|
|
791
|
+
x = list(nx.find_cycle(G, self.nodes, orientation="ignore"))
|
|
792
|
+
x_ = [(0, 1, FORWARD), (1, 0, FORWARD)]
|
|
793
|
+
assert x == x_
|
|
794
|
+
|
|
795
|
+
def test_digraph_reverse(self):
|
|
796
|
+
G = nx.DiGraph(self.edges)
|
|
797
|
+
x = list(nx.find_cycle(G, self.nodes, orientation="reverse"))
|
|
798
|
+
x_ = [(1, 0, REVERSE), (0, 1, REVERSE)]
|
|
799
|
+
assert x == x_
|
|
800
|
+
|
|
801
|
+
def test_multidigraph_ignore(self):
|
|
802
|
+
G = nx.MultiDiGraph(self.edges)
|
|
803
|
+
x = list(nx.find_cycle(G, self.nodes, orientation="ignore"))
|
|
804
|
+
x_ = [(0, 1, 0, FORWARD), (1, 0, 0, FORWARD)] # or (1, 0, 1, 1)
|
|
805
|
+
assert x[0] == x_[0]
|
|
806
|
+
assert x[1][:2] == x_[1][:2]
|
|
807
|
+
assert x[1][3] == x_[1][3]
|
|
808
|
+
|
|
809
|
+
def test_multidigraph_ignore2(self):
|
|
810
|
+
# Loop traversed an edge while ignoring its orientation.
|
|
811
|
+
G = nx.MultiDiGraph([(0, 1), (1, 2), (1, 2)])
|
|
812
|
+
x = list(nx.find_cycle(G, [0, 1, 2], orientation="ignore"))
|
|
813
|
+
x_ = [(1, 2, 0, FORWARD), (1, 2, 1, REVERSE)]
|
|
814
|
+
assert x == x_
|
|
815
|
+
|
|
816
|
+
def test_multidigraph_original(self):
|
|
817
|
+
# Node 2 doesn't need to be searched again from visited from 4.
|
|
818
|
+
# The goal here is to cover the case when 2 to be researched from 4,
|
|
819
|
+
# when 4 is visited from the first time (so we must make sure that 4
|
|
820
|
+
# is not visited from 2, and hence, we respect the edge orientation).
|
|
821
|
+
G = nx.MultiDiGraph([(0, 1), (1, 2), (2, 3), (4, 2)])
|
|
822
|
+
pytest.raises(
|
|
823
|
+
nx.exception.NetworkXNoCycle,
|
|
824
|
+
nx.find_cycle,
|
|
825
|
+
G,
|
|
826
|
+
[0, 1, 2, 3, 4],
|
|
827
|
+
orientation="original",
|
|
828
|
+
)
|
|
829
|
+
|
|
830
|
+
def test_dag(self):
|
|
831
|
+
G = nx.DiGraph([(0, 1), (0, 2), (1, 2)])
|
|
832
|
+
pytest.raises(
|
|
833
|
+
nx.exception.NetworkXNoCycle, nx.find_cycle, G, orientation="original"
|
|
834
|
+
)
|
|
835
|
+
x = list(nx.find_cycle(G, orientation="ignore"))
|
|
836
|
+
assert x == [(0, 1, FORWARD), (1, 2, FORWARD), (0, 2, REVERSE)]
|
|
837
|
+
|
|
838
|
+
def test_prev_explored(self):
|
|
839
|
+
# https://github.com/networkx/networkx/issues/2323
|
|
840
|
+
|
|
841
|
+
G = nx.DiGraph()
|
|
842
|
+
G.add_edges_from([(1, 0), (2, 0), (1, 2), (2, 1)])
|
|
843
|
+
pytest.raises(nx.NetworkXNoCycle, nx.find_cycle, G, source=0)
|
|
844
|
+
x = list(nx.find_cycle(G, 1))
|
|
845
|
+
x_ = [(1, 2), (2, 1)]
|
|
846
|
+
assert x == x_
|
|
847
|
+
|
|
848
|
+
x = list(nx.find_cycle(G, 2))
|
|
849
|
+
x_ = [(2, 1), (1, 2)]
|
|
850
|
+
assert x == x_
|
|
851
|
+
|
|
852
|
+
x = list(nx.find_cycle(G))
|
|
853
|
+
x_ = [(1, 2), (2, 1)]
|
|
854
|
+
assert x == x_
|
|
855
|
+
|
|
856
|
+
def test_no_cycle(self):
|
|
857
|
+
# https://github.com/networkx/networkx/issues/2439
|
|
858
|
+
|
|
859
|
+
G = nx.DiGraph()
|
|
860
|
+
G.add_edges_from([(1, 2), (2, 0), (3, 1), (3, 2)])
|
|
861
|
+
pytest.raises(nx.NetworkXNoCycle, nx.find_cycle, G, source=0)
|
|
862
|
+
pytest.raises(nx.NetworkXNoCycle, nx.find_cycle, G)
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
def assert_basis_equal(a, b):
|
|
866
|
+
assert sorted(a) == sorted(b)
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
class TestMinimumCycleBasis:
|
|
870
|
+
@classmethod
|
|
871
|
+
def setup_class(cls):
|
|
872
|
+
T = nx.Graph()
|
|
873
|
+
nx.add_cycle(T, [1, 2, 3, 4], weight=1)
|
|
874
|
+
T.add_edge(2, 4, weight=5)
|
|
875
|
+
cls.diamond_graph = T
|
|
876
|
+
|
|
877
|
+
def test_unweighted_diamond(self):
|
|
878
|
+
mcb = nx.minimum_cycle_basis(self.diamond_graph)
|
|
879
|
+
assert_basis_equal(mcb, [[2, 4, 1], [3, 4, 2]])
|
|
880
|
+
|
|
881
|
+
def test_weighted_diamond(self):
|
|
882
|
+
mcb = nx.minimum_cycle_basis(self.diamond_graph, weight="weight")
|
|
883
|
+
assert_basis_equal(mcb, [[2, 4, 1], [4, 3, 2, 1]])
|
|
884
|
+
|
|
885
|
+
def test_dimensionality(self):
|
|
886
|
+
# checks |MCB|=|E|-|V|+|NC|
|
|
887
|
+
ntrial = 10
|
|
888
|
+
for seed in range(1234, 1234 + ntrial):
|
|
889
|
+
rg = nx.erdos_renyi_graph(10, 0.3, seed=seed)
|
|
890
|
+
nnodes = rg.number_of_nodes()
|
|
891
|
+
nedges = rg.number_of_edges()
|
|
892
|
+
ncomp = nx.number_connected_components(rg)
|
|
893
|
+
|
|
894
|
+
mcb = nx.minimum_cycle_basis(rg)
|
|
895
|
+
assert len(mcb) == nedges - nnodes + ncomp
|
|
896
|
+
check_independent(mcb)
|
|
897
|
+
|
|
898
|
+
def test_complete_graph(self):
|
|
899
|
+
cg = nx.complete_graph(5)
|
|
900
|
+
mcb = nx.minimum_cycle_basis(cg)
|
|
901
|
+
assert all(len(cycle) == 3 for cycle in mcb)
|
|
902
|
+
check_independent(mcb)
|
|
903
|
+
|
|
904
|
+
def test_tree_graph(self):
|
|
905
|
+
tg = nx.balanced_tree(3, 3)
|
|
906
|
+
assert not nx.minimum_cycle_basis(tg)
|
|
907
|
+
|
|
908
|
+
def test_petersen_graph(self):
|
|
909
|
+
G = nx.petersen_graph()
|
|
910
|
+
mcb = list(nx.minimum_cycle_basis(G))
|
|
911
|
+
expected = [
|
|
912
|
+
[4, 9, 7, 5, 0],
|
|
913
|
+
[1, 2, 3, 4, 0],
|
|
914
|
+
[1, 6, 8, 5, 0],
|
|
915
|
+
[4, 3, 8, 5, 0],
|
|
916
|
+
[1, 6, 9, 4, 0],
|
|
917
|
+
[1, 2, 7, 5, 0],
|
|
918
|
+
]
|
|
919
|
+
assert len(mcb) == len(expected)
|
|
920
|
+
assert all(c in expected for c in mcb)
|
|
921
|
+
|
|
922
|
+
# check that order of the nodes is a path
|
|
923
|
+
for c in mcb:
|
|
924
|
+
assert all(G.has_edge(u, v) for u, v in nx.utils.pairwise(c, cyclic=True))
|
|
925
|
+
# check independence of the basis
|
|
926
|
+
check_independent(mcb)
|
|
927
|
+
|
|
928
|
+
def test_gh6787_variable_weighted_complete_graph(self):
|
|
929
|
+
N = 8
|
|
930
|
+
cg = nx.complete_graph(N)
|
|
931
|
+
cg.add_weighted_edges_from([(u, v, 9) for u, v in cg.edges])
|
|
932
|
+
cg.add_weighted_edges_from([(u, v, 1) for u, v in nx.cycle_graph(N).edges])
|
|
933
|
+
mcb = nx.minimum_cycle_basis(cg, weight="weight")
|
|
934
|
+
check_independent(mcb)
|
|
935
|
+
|
|
936
|
+
def test_gh6787_and_edge_attribute_names(self):
|
|
937
|
+
G = nx.cycle_graph(4)
|
|
938
|
+
G.add_weighted_edges_from([(0, 2, 10), (1, 3, 10)], weight="dist")
|
|
939
|
+
expected = [[1, 3, 0], [3, 2, 1, 0], [1, 2, 0]]
|
|
940
|
+
mcb = list(nx.minimum_cycle_basis(G, weight="dist"))
|
|
941
|
+
assert len(mcb) == len(expected)
|
|
942
|
+
assert all(c in expected for c in mcb)
|
|
943
|
+
|
|
944
|
+
# test not using a weight with weight attributes
|
|
945
|
+
expected = [[1, 3, 0], [1, 2, 0], [3, 2, 0]]
|
|
946
|
+
mcb = list(nx.minimum_cycle_basis(G))
|
|
947
|
+
assert len(mcb) == len(expected)
|
|
948
|
+
assert all(c in expected for c in mcb)
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
class TestGirth:
|
|
952
|
+
@pytest.mark.parametrize(
|
|
953
|
+
("G", "expected"),
|
|
954
|
+
(
|
|
955
|
+
(nx.chvatal_graph(), 4),
|
|
956
|
+
(nx.tutte_graph(), 4),
|
|
957
|
+
(nx.petersen_graph(), 5),
|
|
958
|
+
(nx.heawood_graph(), 6),
|
|
959
|
+
(nx.pappus_graph(), 6),
|
|
960
|
+
(nx.random_labeled_tree(10, seed=42), inf),
|
|
961
|
+
(nx.empty_graph(10), inf),
|
|
962
|
+
(nx.Graph(chain(cycle_edges(range(5)), cycle_edges(range(6, 10)))), 4),
|
|
963
|
+
(
|
|
964
|
+
nx.Graph(
|
|
965
|
+
[
|
|
966
|
+
(0, 6),
|
|
967
|
+
(0, 8),
|
|
968
|
+
(0, 9),
|
|
969
|
+
(1, 8),
|
|
970
|
+
(2, 8),
|
|
971
|
+
(2, 9),
|
|
972
|
+
(4, 9),
|
|
973
|
+
(5, 9),
|
|
974
|
+
(6, 8),
|
|
975
|
+
(6, 9),
|
|
976
|
+
(7, 8),
|
|
977
|
+
]
|
|
978
|
+
),
|
|
979
|
+
3,
|
|
980
|
+
),
|
|
981
|
+
),
|
|
982
|
+
)
|
|
983
|
+
def test_girth(self, G, expected):
|
|
984
|
+
assert nx.girth(G) == expected
|