okstra 0.108.0 → 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/profiles/_common-contract.md +1 -1
- 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_project/__init__.py +2 -0
- package/runtime/python/okstra_project/state.py +36 -0
- 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/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,396 @@
|
|
|
1
|
+
"""Fast algorithms for the densest subgraph problem"""
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
|
|
7
|
+
__all__ = ["densest_subgraph"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _greedy_plus_plus(G, iterations):
|
|
11
|
+
if G.number_of_edges() == 0:
|
|
12
|
+
return 0.0, set()
|
|
13
|
+
if iterations < 1:
|
|
14
|
+
raise ValueError(
|
|
15
|
+
f"The number of iterations must be an integer >= 1. Provided: {iterations}"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
loads = {node: 0 for node in G.nodes} # Load vector for Greedy++.
|
|
19
|
+
best_density = 0.0 # Highest density encountered.
|
|
20
|
+
best_subgraph = set() # Nodes of the best subgraph found.
|
|
21
|
+
|
|
22
|
+
for _ in range(iterations):
|
|
23
|
+
# Initialize heap for fast access to minimum weighted degree.
|
|
24
|
+
heap = nx.utils.BinaryHeap()
|
|
25
|
+
|
|
26
|
+
# Compute initial weighted degrees and add nodes to the heap.
|
|
27
|
+
for node, degree in G.degree:
|
|
28
|
+
heap.insert(node, loads[node] + degree)
|
|
29
|
+
# Set up tracking for current graph state.
|
|
30
|
+
remaining_nodes = set(G.nodes)
|
|
31
|
+
num_edges = G.number_of_edges()
|
|
32
|
+
current_degrees = dict(G.degree)
|
|
33
|
+
|
|
34
|
+
while remaining_nodes:
|
|
35
|
+
num_nodes = len(remaining_nodes)
|
|
36
|
+
|
|
37
|
+
# Current density of the (implicit) graph
|
|
38
|
+
current_density = num_edges / num_nodes
|
|
39
|
+
|
|
40
|
+
# Update the best density.
|
|
41
|
+
if current_density > best_density:
|
|
42
|
+
best_density = current_density
|
|
43
|
+
best_subgraph = set(remaining_nodes)
|
|
44
|
+
|
|
45
|
+
# Pop the node with the smallest weighted degree.
|
|
46
|
+
node, _ = heap.pop()
|
|
47
|
+
if node not in remaining_nodes:
|
|
48
|
+
continue # Skip nodes already removed.
|
|
49
|
+
|
|
50
|
+
# Update the load of the popped node.
|
|
51
|
+
loads[node] += current_degrees[node]
|
|
52
|
+
|
|
53
|
+
# Update neighbors' degrees and the heap.
|
|
54
|
+
for neighbor in G.neighbors(node):
|
|
55
|
+
if neighbor in remaining_nodes:
|
|
56
|
+
current_degrees[neighbor] -= 1
|
|
57
|
+
num_edges -= 1
|
|
58
|
+
heap.insert(neighbor, loads[neighbor] + current_degrees[neighbor])
|
|
59
|
+
|
|
60
|
+
# Remove the node from the remaining nodes.
|
|
61
|
+
remaining_nodes.remove(node)
|
|
62
|
+
|
|
63
|
+
return best_density, best_subgraph
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _fractional_peeling(G, b, x, node_to_idx, edge_to_idx):
|
|
67
|
+
"""
|
|
68
|
+
Optimized fractional peeling using NumPy arrays.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
G : networkx.Graph
|
|
73
|
+
The input graph.
|
|
74
|
+
b : numpy.ndarray
|
|
75
|
+
Induced load vector.
|
|
76
|
+
x : numpy.ndarray
|
|
77
|
+
Fractional edge values.
|
|
78
|
+
node_to_idx : dict
|
|
79
|
+
Mapping from node to index.
|
|
80
|
+
edge_to_idx : dict
|
|
81
|
+
Mapping from edge to index.
|
|
82
|
+
|
|
83
|
+
Returns
|
|
84
|
+
-------
|
|
85
|
+
best_density : float
|
|
86
|
+
The best density found.
|
|
87
|
+
best_subgraph : set
|
|
88
|
+
The subset of nodes defining the densest subgraph.
|
|
89
|
+
"""
|
|
90
|
+
heap = nx.utils.BinaryHeap()
|
|
91
|
+
|
|
92
|
+
remaining_nodes = set(G.nodes)
|
|
93
|
+
|
|
94
|
+
# Initialize heap with b values
|
|
95
|
+
for idx, node in enumerate(G):
|
|
96
|
+
heap.insert(node, b[idx])
|
|
97
|
+
|
|
98
|
+
num_edges = G.number_of_edges()
|
|
99
|
+
|
|
100
|
+
best_density = 0.0
|
|
101
|
+
best_subgraph = set()
|
|
102
|
+
|
|
103
|
+
while remaining_nodes:
|
|
104
|
+
num_nodes = len(remaining_nodes)
|
|
105
|
+
current_density = num_edges / num_nodes
|
|
106
|
+
|
|
107
|
+
if current_density > best_density:
|
|
108
|
+
best_density = current_density
|
|
109
|
+
best_subgraph = set(remaining_nodes)
|
|
110
|
+
|
|
111
|
+
# Pop the node with the smallest b
|
|
112
|
+
node, _ = heap.pop()
|
|
113
|
+
while node not in remaining_nodes:
|
|
114
|
+
node, _ = heap.pop() # Clean the heap from stale values
|
|
115
|
+
|
|
116
|
+
# Update neighbors b values by subtracting fractional x value
|
|
117
|
+
for neighbor in G.neighbors(node):
|
|
118
|
+
if neighbor in remaining_nodes:
|
|
119
|
+
neighbor_idx = node_to_idx[neighbor]
|
|
120
|
+
# Take off fractional value
|
|
121
|
+
b[neighbor_idx] -= x[edge_to_idx[(neighbor, node)]]
|
|
122
|
+
num_edges -= 1
|
|
123
|
+
heap.insert(neighbor, b[neighbor_idx])
|
|
124
|
+
|
|
125
|
+
remaining_nodes.remove(node) # peel off node
|
|
126
|
+
|
|
127
|
+
return best_density, best_subgraph
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _fista(G, iterations):
|
|
131
|
+
if G.number_of_edges() == 0:
|
|
132
|
+
return 0.0, set()
|
|
133
|
+
if iterations < 1:
|
|
134
|
+
raise ValueError(
|
|
135
|
+
f"The number of iterations must be an integer >= 1. Provided: {iterations}"
|
|
136
|
+
)
|
|
137
|
+
import numpy as np
|
|
138
|
+
|
|
139
|
+
# 1. Node Mapping: Assign a unique index to each node and edge
|
|
140
|
+
node_to_idx = {node: idx for idx, node in enumerate(G)}
|
|
141
|
+
num_nodes = G.number_of_nodes()
|
|
142
|
+
num_undirected_edges = G.number_of_edges()
|
|
143
|
+
|
|
144
|
+
# 2. Edge Mapping: Assign a unique index to each bidirectional edge
|
|
145
|
+
bidirectional_edges = [(u, v) for u, v in G.edges] + [(v, u) for u, v in G.edges]
|
|
146
|
+
edge_to_idx = {edge: idx for idx, edge in enumerate(bidirectional_edges)}
|
|
147
|
+
|
|
148
|
+
num_edges = len(bidirectional_edges)
|
|
149
|
+
|
|
150
|
+
# 3. Reverse Edge Mapping: Map each (bidirectional) edge to its reverse edge index
|
|
151
|
+
reverse_edge_idx = np.empty(num_edges, dtype=np.int32)
|
|
152
|
+
for idx in range(num_undirected_edges):
|
|
153
|
+
reverse_edge_idx[idx] = num_undirected_edges + idx
|
|
154
|
+
for idx in range(num_undirected_edges, 2 * num_undirected_edges):
|
|
155
|
+
reverse_edge_idx[idx] = idx - num_undirected_edges
|
|
156
|
+
|
|
157
|
+
# 4. Initialize Variables as NumPy Arrays
|
|
158
|
+
x = np.full(num_edges, 0.5, dtype=np.float32)
|
|
159
|
+
y = x.copy()
|
|
160
|
+
z = np.zeros(num_edges, dtype=np.float32)
|
|
161
|
+
b = np.zeros(num_nodes, dtype=np.float32) # Induced load vector
|
|
162
|
+
tk = 1.0 # Momentum term
|
|
163
|
+
|
|
164
|
+
# 5. Precompute Edge Source Indices
|
|
165
|
+
edge_src_indices = np.array(
|
|
166
|
+
[node_to_idx[u] for u, _ in bidirectional_edges], dtype=np.int32
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
# 6. Compute Learning Rate
|
|
170
|
+
max_degree = max(deg for _, deg in G.degree)
|
|
171
|
+
# 0.9 for floating point errs when max_degree is very large
|
|
172
|
+
learning_rate = 0.9 / max_degree
|
|
173
|
+
|
|
174
|
+
# 7. Iterative Updates
|
|
175
|
+
for _ in range(iterations):
|
|
176
|
+
# 7a. Update b: sum y over outgoing edges for each node
|
|
177
|
+
b[:] = 0.0 # Reset b to zero
|
|
178
|
+
np.add.at(b, edge_src_indices, y) # b_u = \sum_{v : (u,v) \in E(G)} y_{uv}
|
|
179
|
+
|
|
180
|
+
# 7b. Compute z, z_{uv} = y_{uv} - 2 * learning_rate * b_u
|
|
181
|
+
z = y - 2.0 * learning_rate * b[edge_src_indices]
|
|
182
|
+
|
|
183
|
+
# 7c. Update Momentum Term
|
|
184
|
+
tknew = (1.0 + math.sqrt(1 + 4.0 * tk**2)) / 2.0
|
|
185
|
+
|
|
186
|
+
# 7d. Update x in a vectorized manner, x_{uv} = (z_{uv} - z_{vu} + 1.0) / 2.0
|
|
187
|
+
new_xuv = (z - z[reverse_edge_idx] + 1.0) / 2.0
|
|
188
|
+
clamped_x = np.clip(new_xuv, 0.0, 1.0) # Clamp x_{uv} between 0 and 1
|
|
189
|
+
|
|
190
|
+
# Update y using the FISTA update formula (similar to gradient descent)
|
|
191
|
+
y = (
|
|
192
|
+
clamped_x
|
|
193
|
+
+ ((tk - 1.0) / tknew) * (clamped_x - x)
|
|
194
|
+
+ (tk / tknew) * (clamped_x - y)
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
# Update x
|
|
198
|
+
x = clamped_x
|
|
199
|
+
|
|
200
|
+
# Update tk, the momemntum term
|
|
201
|
+
tk = tknew
|
|
202
|
+
|
|
203
|
+
# Rebalance the b values! Otherwise performance is a bit suboptimal.
|
|
204
|
+
b[:] = 0.0
|
|
205
|
+
np.add.at(b, edge_src_indices, x) # b_u = \sum_{v : (u,v) \in E(G)} x_{uv}
|
|
206
|
+
|
|
207
|
+
# Extract the actual (approximate) dense subgraph.
|
|
208
|
+
return _fractional_peeling(G, b, x, node_to_idx, edge_to_idx)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
ALGORITHMS = {"greedy++": _greedy_plus_plus, "fista": _fista}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@nx.utils.not_implemented_for("directed")
|
|
215
|
+
@nx.utils.not_implemented_for("multigraph")
|
|
216
|
+
@nx._dispatchable
|
|
217
|
+
def densest_subgraph(G, iterations=1, *, method="fista"):
|
|
218
|
+
r"""Returns an approximate densest subgraph for a graph `G`.
|
|
219
|
+
|
|
220
|
+
This function runs an iterative algorithm to find the densest subgraph,
|
|
221
|
+
and returns both the density and the subgraph. For a discussion on the
|
|
222
|
+
notion of density used and the different algorithms available on
|
|
223
|
+
networkx, please see the Notes section below.
|
|
224
|
+
|
|
225
|
+
Parameters
|
|
226
|
+
----------
|
|
227
|
+
G : NetworkX graph
|
|
228
|
+
Undirected graph.
|
|
229
|
+
|
|
230
|
+
iterations : int, optional (default=1)
|
|
231
|
+
Number of iterations to use for the iterative algorithm. Can be
|
|
232
|
+
specified positionally or as a keyword argument.
|
|
233
|
+
|
|
234
|
+
method : string, optional (default='fista')
|
|
235
|
+
The algorithm to use to approximate the densest subgraph. Supported
|
|
236
|
+
options: 'greedy++' by Boob et al. [2]_ and 'fista' by Harb et al. [3]_.
|
|
237
|
+
Must be specified as a keyword argument. Other inputs produce a
|
|
238
|
+
ValueError.
|
|
239
|
+
|
|
240
|
+
Returns
|
|
241
|
+
-------
|
|
242
|
+
d : float
|
|
243
|
+
The density of the approximate subgraph found.
|
|
244
|
+
|
|
245
|
+
S : set
|
|
246
|
+
The subset of nodes defining the approximate densest subgraph.
|
|
247
|
+
|
|
248
|
+
Examples
|
|
249
|
+
--------
|
|
250
|
+
>>> G = nx.star_graph(4)
|
|
251
|
+
>>> nx.approximation.densest_subgraph(G, iterations=1)
|
|
252
|
+
(0.8, {0, 1, 2, 3, 4})
|
|
253
|
+
|
|
254
|
+
Notes
|
|
255
|
+
-----
|
|
256
|
+
**Problem Definition:**
|
|
257
|
+
The densest subgraph problem (DSG) asks to find the subgraph
|
|
258
|
+
$S \subseteq V(G)$ with maximum density. For a subset of the nodes of
|
|
259
|
+
$G$, $S \subseteq V(G)$, define $E(S) = \{ (u,v) : (u,v)\in E(G),
|
|
260
|
+
u\in S, v\in S \}$ as the set of edges with both endpoints in $S$.
|
|
261
|
+
The density of $S$ is defined as $|E(S)|/|S|$, the ratio between the
|
|
262
|
+
edges in the subgraph $G[S]$ and the number of nodes in that subgraph.
|
|
263
|
+
Note that this is different from the standard graph theoretic definition
|
|
264
|
+
of density, defined as $\frac{2|E(S)|}{|S|(|S|-1)}$, for historical
|
|
265
|
+
reasons.
|
|
266
|
+
|
|
267
|
+
**Exact Algorithms:**
|
|
268
|
+
The densest subgraph problem is polynomial time solvable using maximum
|
|
269
|
+
flow, commonly referred to as Goldberg's algorithm. However, the
|
|
270
|
+
algorithm is quite involved. It first binary searches on the optimal
|
|
271
|
+
density, $d^\ast$. For a guess of the density $d$, it sets up a flow
|
|
272
|
+
network $G'$ with size $O(m)$. The maximum flow solution either
|
|
273
|
+
informs the algorithm that no subgraph with density $d$ exists, or it
|
|
274
|
+
provides a subgraph with density at least $d$. However, this is
|
|
275
|
+
inherently bottlenecked by the maximum flow algorithm. For example, [2]_
|
|
276
|
+
notes that Goldberg’s algorithm was not feasible on many large graphs
|
|
277
|
+
even though they used a highly optimized maximum flow library.
|
|
278
|
+
|
|
279
|
+
**Charikar's Greedy Peeling:**
|
|
280
|
+
While exact solution algorithms are quite involved, there are several
|
|
281
|
+
known approximation algorithms for the densest subgraph problem.
|
|
282
|
+
|
|
283
|
+
Charikar [1]_ described a very simple 1/2-approximation algorithm for DSG
|
|
284
|
+
known as the greedy "peeling" algorithm. The algorithm creates an
|
|
285
|
+
ordering of the nodes as follows. The first node $v_1$ is the one with
|
|
286
|
+
the smallest degree in $G$ (ties broken arbitrarily). It selects
|
|
287
|
+
$v_2$ to be the smallest degree node in $G \setminus v_1$. Letting
|
|
288
|
+
$G_i$ be the graph after removing $v_1, ..., v_i$ (with $G_0=G$),
|
|
289
|
+
the algorithm returns the graph among $G_0, ..., G_n$ with the highest
|
|
290
|
+
density.
|
|
291
|
+
|
|
292
|
+
**Greedy++:**
|
|
293
|
+
Boob et al. [2]_ generalized this algorithm into Greedy++, an iterative
|
|
294
|
+
algorithm that runs several rounds of "peeling". In fact, Greedy++ with 1
|
|
295
|
+
iteration is precisely Charikar's algorithm. The algorithm converges to a
|
|
296
|
+
$(1-\epsilon)$ approximate densest subgraph in $O(\Delta(G)\log
|
|
297
|
+
n/\epsilon^2)$ iterations, where $\Delta(G)$ is the maximum degree,
|
|
298
|
+
and $n$ is the number of nodes in $G$. The algorithm also has other
|
|
299
|
+
desirable properties as shown by [4]_ and [5]_.
|
|
300
|
+
|
|
301
|
+
**FISTA Algorithm:**
|
|
302
|
+
Harb et al. [3]_ gave a faster and more scalable algorithm using ideas
|
|
303
|
+
from quadratic programming for the densest subgraph, which is based on a
|
|
304
|
+
fast iterative shrinkage-thresholding algorithm (FISTA) algorithm. It is
|
|
305
|
+
known that computing the densest subgraph can be formulated as the
|
|
306
|
+
following convex optimization problem:
|
|
307
|
+
|
|
308
|
+
Minimize $\sum_{u \in V(G)} b_u^2$
|
|
309
|
+
|
|
310
|
+
Subject to:
|
|
311
|
+
|
|
312
|
+
$b_u = \sum_{v: \{u,v\} \in E(G)} x_{uv}$ for all $u \in V(G)$
|
|
313
|
+
|
|
314
|
+
$x_{uv} + x_{vu} = 1.0$ for all $\{u,v\} \in E(G)$
|
|
315
|
+
|
|
316
|
+
$x_{uv} \geq 0, x_{vu} \geq 0$ for all $\{u,v\} \in E(G)$
|
|
317
|
+
|
|
318
|
+
Here, $x_{uv}$ represents the fraction of edge $\{u,v\}$ assigned to
|
|
319
|
+
$u$, and $x_{vu}$ to $v$.
|
|
320
|
+
|
|
321
|
+
The FISTA algorithm efficiently solves this convex program using gradient
|
|
322
|
+
descent with projections. For a learning rate $\alpha$, the algorithm
|
|
323
|
+
does:
|
|
324
|
+
|
|
325
|
+
1. **Initialization**: Set $x^{(0)}_{uv} = x^{(0)}_{vu} = 0.5$ for all
|
|
326
|
+
edges as a feasible solution.
|
|
327
|
+
|
|
328
|
+
2. **Gradient Update**: For iteration $k\geq 1$, set
|
|
329
|
+
$x^{(k+1)}_{uv} = x^{(k)}_{uv} - 2 \alpha \sum_{v: \{u,v\} \in E(G)}
|
|
330
|
+
x^{(k)}_{uv}$. However, now $x^{(k+1)}_{uv}$ might be infeasible!
|
|
331
|
+
To ensure feasibility, we project $x^{(k+1)}_{uv}$.
|
|
332
|
+
|
|
333
|
+
3. **Projection to the Feasible Set**: Compute
|
|
334
|
+
$b^{(k+1)}_u = \sum_{v: \{u,v\} \in E(G)} x^{(k)}_{uv}$ for all
|
|
335
|
+
nodes $u$. Define $z^{(k+1)}_{uv} = x^{(k+1)}_{uv} - 2 \alpha
|
|
336
|
+
b^{(k+1)}_u$. Update $x^{(k+1)}_{uv} =
|
|
337
|
+
CLAMP((z^{(k+1)}_{uv} - z^{(k+1)}_{vu} + 1.0) / 2.0)$, where
|
|
338
|
+
$CLAMP(x) = \max(0, \min(1, x))$.
|
|
339
|
+
|
|
340
|
+
With a learning rate of $\alpha=1/\Delta(G)$, where $\Delta(G)$ is
|
|
341
|
+
the maximum degree, the algorithm converges to the optimum solution of
|
|
342
|
+
the convex program.
|
|
343
|
+
|
|
344
|
+
**Fractional Peeling:**
|
|
345
|
+
To obtain a **discrete** subgraph, we use fractional peeling, an
|
|
346
|
+
adaptation of the standard peeling algorithm which peels the minimum
|
|
347
|
+
degree vertex in each iteration, and returns the densest subgraph found
|
|
348
|
+
along the way. Here, we instead peel the vertex with the smallest
|
|
349
|
+
induced load $b_u$:
|
|
350
|
+
|
|
351
|
+
1. Compute $b_u$ and $x_{uv}$.
|
|
352
|
+
|
|
353
|
+
2. Iteratively remove the vertex with the smallest $b_u$, updating its
|
|
354
|
+
neighbors' load by $x_{vu}$.
|
|
355
|
+
|
|
356
|
+
Fractional peeling transforms the approximately optimal fractional
|
|
357
|
+
values $b_u, x_{uv}$ into a discrete subgraph. Unlike traditional
|
|
358
|
+
peeling, which removes the lowest-degree node, this method accounts for
|
|
359
|
+
fractional edge contributions from the convex program.
|
|
360
|
+
|
|
361
|
+
This approach is both scalable and theoretically sound, ensuring a quick
|
|
362
|
+
approximation of the densest subgraph while leveraging fractional load
|
|
363
|
+
balancing.
|
|
364
|
+
|
|
365
|
+
References
|
|
366
|
+
----------
|
|
367
|
+
.. [1] Charikar, Moses. "Greedy approximation algorithms for finding dense
|
|
368
|
+
components in a graph." In International workshop on approximation
|
|
369
|
+
algorithms for combinatorial optimization, pp. 84-95. Berlin, Heidelberg:
|
|
370
|
+
Springer Berlin Heidelberg, 2000.
|
|
371
|
+
|
|
372
|
+
.. [2] Boob, Digvijay, Yu Gao, Richard Peng, Saurabh Sawlani, Charalampos
|
|
373
|
+
Tsourakakis, Di Wang, and Junxing Wang. "Flowless: Extracting densest
|
|
374
|
+
subgraphs without flow computations." In Proceedings of The Web Conference
|
|
375
|
+
2020, pp. 573-583. 2020.
|
|
376
|
+
|
|
377
|
+
.. [3] Harb, Elfarouk, Kent Quanrud, and Chandra Chekuri. "Faster and scalable
|
|
378
|
+
algorithms for densest subgraph and decomposition." Advances in Neural
|
|
379
|
+
Information Processing Systems 35 (2022): 26966-26979.
|
|
380
|
+
|
|
381
|
+
.. [4] Harb, Elfarouk, Kent Quanrud, and Chandra Chekuri. "Convergence to
|
|
382
|
+
lexicographically optimal base in a (contra) polymatroid and applications
|
|
383
|
+
to densest subgraph and tree packing." arXiv preprint arXiv:2305.02987
|
|
384
|
+
(2023).
|
|
385
|
+
|
|
386
|
+
.. [5] Chekuri, Chandra, Kent Quanrud, and Manuel R. Torres. "Densest
|
|
387
|
+
subgraph: Supermodularity, iterative peeling, and flow." In Proceedings of
|
|
388
|
+
the 2022 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp.
|
|
389
|
+
1531-1555. Society for Industrial and Applied Mathematics, 2022.
|
|
390
|
+
"""
|
|
391
|
+
try:
|
|
392
|
+
algo = ALGORITHMS[method]
|
|
393
|
+
except KeyError as e:
|
|
394
|
+
raise ValueError(f"{method} is not a valid choice for an algorithm.") from e
|
|
395
|
+
|
|
396
|
+
return algo(G, iterations)
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""Distance measures approximated metrics."""
|
|
2
|
+
|
|
3
|
+
import networkx as nx
|
|
4
|
+
from networkx.utils.decorators import py_random_state
|
|
5
|
+
|
|
6
|
+
__all__ = ["diameter"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@py_random_state(1)
|
|
10
|
+
@nx._dispatchable(name="approximate_diameter")
|
|
11
|
+
def diameter(G, seed=None):
|
|
12
|
+
"""Returns a lower bound on the diameter of the graph G.
|
|
13
|
+
|
|
14
|
+
The function computes a lower bound on the diameter (i.e., the maximum eccentricity)
|
|
15
|
+
of a directed or undirected graph G. The procedure used varies depending on the graph
|
|
16
|
+
being directed or not.
|
|
17
|
+
|
|
18
|
+
If G is an `undirected` graph, then the function uses the `2-sweep` algorithm [1]_.
|
|
19
|
+
The main idea is to pick the farthest node from a random node and return its eccentricity.
|
|
20
|
+
|
|
21
|
+
Otherwise, if G is a `directed` graph, the function uses the `2-dSweep` algorithm [2]_,
|
|
22
|
+
The procedure starts by selecting a random source node $s$ from which it performs a
|
|
23
|
+
forward and a backward BFS. Let $a_1$ and $a_2$ be the farthest nodes in the forward and
|
|
24
|
+
backward cases, respectively. Then, it computes the backward eccentricity of $a_1$ using
|
|
25
|
+
a backward BFS and the forward eccentricity of $a_2$ using a forward BFS.
|
|
26
|
+
Finally, it returns the best lower bound between the two.
|
|
27
|
+
|
|
28
|
+
In both cases, the time complexity is linear with respect to the size of G.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
G : NetworkX graph
|
|
33
|
+
|
|
34
|
+
seed : integer, random_state, or None (default)
|
|
35
|
+
Indicator of random number generation state.
|
|
36
|
+
See :ref:`Randomness<randomness>`.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
d : integer
|
|
41
|
+
Lower Bound on the Diameter of G
|
|
42
|
+
|
|
43
|
+
Examples
|
|
44
|
+
--------
|
|
45
|
+
>>> G = nx.path_graph(10) # undirected graph
|
|
46
|
+
>>> nx.diameter(G)
|
|
47
|
+
9
|
|
48
|
+
>>> G = nx.cycle_graph(3, create_using=nx.DiGraph) # directed graph
|
|
49
|
+
>>> nx.diameter(G)
|
|
50
|
+
2
|
|
51
|
+
|
|
52
|
+
Raises
|
|
53
|
+
------
|
|
54
|
+
NetworkXError
|
|
55
|
+
If the graph is empty or
|
|
56
|
+
If the graph is undirected and not connected or
|
|
57
|
+
If the graph is directed and not strongly connected.
|
|
58
|
+
|
|
59
|
+
See Also
|
|
60
|
+
--------
|
|
61
|
+
networkx.algorithms.distance_measures.diameter
|
|
62
|
+
|
|
63
|
+
References
|
|
64
|
+
----------
|
|
65
|
+
.. [1] Magnien, Clémence, Matthieu Latapy, and Michel Habib.
|
|
66
|
+
*Fast computation of empirically tight bounds for the diameter of massive graphs.*
|
|
67
|
+
Journal of Experimental Algorithmics (JEA), 2009.
|
|
68
|
+
https://arxiv.org/pdf/0904.2728.pdf
|
|
69
|
+
.. [2] Crescenzi, Pierluigi, Roberto Grossi, Leonardo Lanzi, and Andrea Marino.
|
|
70
|
+
*On computing the diameter of real-world directed (weighted) graphs.*
|
|
71
|
+
International Symposium on Experimental Algorithms. Springer, Berlin, Heidelberg, 2012.
|
|
72
|
+
https://courses.cs.ut.ee/MTAT.03.238/2014_fall/uploads/Main/diameter.pdf
|
|
73
|
+
"""
|
|
74
|
+
# if G is empty
|
|
75
|
+
if not G:
|
|
76
|
+
raise nx.NetworkXError("Expected non-empty NetworkX graph!")
|
|
77
|
+
# if there's only a node
|
|
78
|
+
if G.number_of_nodes() == 1:
|
|
79
|
+
return 0
|
|
80
|
+
# if G is directed
|
|
81
|
+
if G.is_directed():
|
|
82
|
+
return _two_sweep_directed(G, seed)
|
|
83
|
+
# else if G is undirected
|
|
84
|
+
return _two_sweep_undirected(G, seed)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _two_sweep_undirected(G, seed):
|
|
88
|
+
"""Helper function for finding a lower bound on the diameter
|
|
89
|
+
for undirected Graphs.
|
|
90
|
+
|
|
91
|
+
The idea is to pick the farthest node from a random node
|
|
92
|
+
and return its eccentricity.
|
|
93
|
+
|
|
94
|
+
``G`` is a NetworkX undirected graph.
|
|
95
|
+
|
|
96
|
+
.. note::
|
|
97
|
+
|
|
98
|
+
``seed`` is a random.Random or numpy.random.RandomState instance
|
|
99
|
+
"""
|
|
100
|
+
# select a random source node
|
|
101
|
+
source = seed.choice(list(G))
|
|
102
|
+
# get the distances to the other nodes
|
|
103
|
+
distances = nx.shortest_path_length(G, source)
|
|
104
|
+
# if some nodes have not been visited, then the graph is not connected
|
|
105
|
+
if len(distances) != len(G):
|
|
106
|
+
raise nx.NetworkXError("Graph not connected.")
|
|
107
|
+
# take a node that is (one of) the farthest nodes from the source
|
|
108
|
+
*_, node = distances
|
|
109
|
+
# return the eccentricity of the node
|
|
110
|
+
return nx.eccentricity(G, node)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _two_sweep_directed(G, seed):
|
|
114
|
+
"""Helper function for finding a lower bound on the diameter
|
|
115
|
+
for directed Graphs.
|
|
116
|
+
|
|
117
|
+
It implements 2-dSweep, the directed version of the 2-sweep algorithm.
|
|
118
|
+
The algorithm follows the following steps.
|
|
119
|
+
1. Select a source node $s$ at random.
|
|
120
|
+
2. Perform a forward BFS from $s$ to select a node $a_1$ at the maximum
|
|
121
|
+
distance from the source, and compute $LB_1$, the backward eccentricity of $a_1$.
|
|
122
|
+
3. Perform a backward BFS from $s$ to select a node $a_2$ at the maximum
|
|
123
|
+
distance from the source, and compute $LB_2$, the forward eccentricity of $a_2$.
|
|
124
|
+
4. Return the maximum between $LB_1$ and $LB_2$.
|
|
125
|
+
|
|
126
|
+
``G`` is a NetworkX directed graph.
|
|
127
|
+
|
|
128
|
+
.. note::
|
|
129
|
+
|
|
130
|
+
``seed`` is a random.Random or numpy.random.RandomState instance
|
|
131
|
+
"""
|
|
132
|
+
# get a new digraph G' with the edges reversed in the opposite direction
|
|
133
|
+
G_reversed = G.reverse()
|
|
134
|
+
# select a random source node
|
|
135
|
+
source = seed.choice(list(G))
|
|
136
|
+
# compute forward distances from source
|
|
137
|
+
forward_distances = nx.shortest_path_length(G, source)
|
|
138
|
+
# compute backward distances from source
|
|
139
|
+
backward_distances = nx.shortest_path_length(G_reversed, source)
|
|
140
|
+
# if either the source can't reach every node or not every node
|
|
141
|
+
# can reach the source, then the graph is not strongly connected
|
|
142
|
+
n = len(G)
|
|
143
|
+
if len(forward_distances) != n or len(backward_distances) != n:
|
|
144
|
+
raise nx.NetworkXError("DiGraph not strongly connected.")
|
|
145
|
+
# take a node a_1 at the maximum distance from the source in G
|
|
146
|
+
*_, a_1 = forward_distances
|
|
147
|
+
# take a node a_2 at the maximum distance from the source in G_reversed
|
|
148
|
+
*_, a_2 = backward_distances
|
|
149
|
+
# return the max between the backward eccentricity of a_1 and the forward eccentricity of a_2
|
|
150
|
+
return max(nx.eccentricity(G_reversed, a_1), nx.eccentricity(G, a_2))
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""Functions for finding node and edge dominating sets.
|
|
2
|
+
|
|
3
|
+
A `dominating set`_ for an undirected graph *G* with vertex set *V*
|
|
4
|
+
and edge set *E* is a subset *D* of *V* such that every vertex not in
|
|
5
|
+
*D* is adjacent to at least one member of *D*. An `edge dominating set`_
|
|
6
|
+
is a subset *F* of *E* such that every edge not in *F* is
|
|
7
|
+
incident to an endpoint of at least one edge in *F*.
|
|
8
|
+
|
|
9
|
+
.. _dominating set: https://en.wikipedia.org/wiki/Dominating_set
|
|
10
|
+
.. _edge dominating set: https://en.wikipedia.org/wiki/Edge_dominating_set
|
|
11
|
+
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import networkx as nx
|
|
15
|
+
|
|
16
|
+
from ...utils import not_implemented_for
|
|
17
|
+
from ..matching import maximal_matching
|
|
18
|
+
|
|
19
|
+
__all__ = ["min_weighted_dominating_set", "min_edge_dominating_set"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# TODO Why doesn't this algorithm work for directed graphs?
|
|
23
|
+
@not_implemented_for("directed")
|
|
24
|
+
@nx._dispatchable(node_attrs="weight")
|
|
25
|
+
def min_weighted_dominating_set(G, weight=None):
|
|
26
|
+
r"""Returns a dominating set that approximates the minimum weight node
|
|
27
|
+
dominating set.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
G : NetworkX graph
|
|
32
|
+
Undirected graph.
|
|
33
|
+
|
|
34
|
+
weight : string
|
|
35
|
+
The node attribute storing the weight of an node. If provided,
|
|
36
|
+
the node attribute with this key must be a number for each
|
|
37
|
+
node. If not provided, each node is assumed to have weight one.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
min_weight_dominating_set : set
|
|
42
|
+
A set of nodes, the sum of whose weights is no more than `(\log
|
|
43
|
+
w(V)) w(V^*)`, where `w(V)` denotes the sum of the weights of
|
|
44
|
+
each node in the graph and `w(V^*)` denotes the sum of the
|
|
45
|
+
weights of each node in the minimum weight dominating set.
|
|
46
|
+
|
|
47
|
+
Examples
|
|
48
|
+
--------
|
|
49
|
+
>>> G = nx.Graph([(0, 1), (0, 4), (1, 4), (1, 2), (2, 3), (3, 4), (2, 5)])
|
|
50
|
+
>>> nx.approximation.min_weighted_dominating_set(G)
|
|
51
|
+
{1, 2, 4}
|
|
52
|
+
|
|
53
|
+
Raises
|
|
54
|
+
------
|
|
55
|
+
NetworkXNotImplemented
|
|
56
|
+
If G is directed.
|
|
57
|
+
|
|
58
|
+
Notes
|
|
59
|
+
-----
|
|
60
|
+
This algorithm computes an approximate minimum weighted dominating
|
|
61
|
+
set for the graph `G`. The returned solution has weight `(\log
|
|
62
|
+
w(V)) w(V^*)`, where `w(V)` denotes the sum of the weights of each
|
|
63
|
+
node in the graph and `w(V^*)` denotes the sum of the weights of
|
|
64
|
+
each node in the minimum weight dominating set for the graph.
|
|
65
|
+
|
|
66
|
+
This implementation of the algorithm runs in $O(m)$ time, where $m$
|
|
67
|
+
is the number of edges in the graph.
|
|
68
|
+
|
|
69
|
+
References
|
|
70
|
+
----------
|
|
71
|
+
.. [1] Vazirani, Vijay V.
|
|
72
|
+
*Approximation Algorithms*.
|
|
73
|
+
Springer Science & Business Media, 2001.
|
|
74
|
+
|
|
75
|
+
"""
|
|
76
|
+
# The unique dominating set for the null graph is the empty set.
|
|
77
|
+
if len(G) == 0:
|
|
78
|
+
return set()
|
|
79
|
+
|
|
80
|
+
# This is the dominating set that will eventually be returned.
|
|
81
|
+
dom_set = set()
|
|
82
|
+
|
|
83
|
+
def _cost(node_and_neighborhood):
|
|
84
|
+
"""Returns the cost-effectiveness of greedily choosing the given
|
|
85
|
+
node.
|
|
86
|
+
|
|
87
|
+
`node_and_neighborhood` is a two-tuple comprising a node and its
|
|
88
|
+
closed neighborhood.
|
|
89
|
+
|
|
90
|
+
"""
|
|
91
|
+
v, neighborhood = node_and_neighborhood
|
|
92
|
+
return G.nodes[v].get(weight, 1) / len(neighborhood - dom_set)
|
|
93
|
+
|
|
94
|
+
# This is a set of all vertices not already covered by the
|
|
95
|
+
# dominating set.
|
|
96
|
+
vertices = set(G)
|
|
97
|
+
# This is a dictionary mapping each node to the closed neighborhood
|
|
98
|
+
# of that node.
|
|
99
|
+
neighborhoods = {v: {v} | set(G[v]) for v in G}
|
|
100
|
+
|
|
101
|
+
# Continue until all vertices are adjacent to some node in the
|
|
102
|
+
# dominating set.
|
|
103
|
+
while vertices:
|
|
104
|
+
# Find the most cost-effective node to add, along with its
|
|
105
|
+
# closed neighborhood.
|
|
106
|
+
dom_node, min_set = min(neighborhoods.items(), key=_cost)
|
|
107
|
+
# Add the node to the dominating set and reduce the remaining
|
|
108
|
+
# set of nodes to cover.
|
|
109
|
+
dom_set.add(dom_node)
|
|
110
|
+
del neighborhoods[dom_node]
|
|
111
|
+
vertices -= min_set
|
|
112
|
+
|
|
113
|
+
return dom_set
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@nx._dispatchable
|
|
117
|
+
def min_edge_dominating_set(G):
|
|
118
|
+
r"""Returns minimum cardinality edge dominating set.
|
|
119
|
+
|
|
120
|
+
Parameters
|
|
121
|
+
----------
|
|
122
|
+
G : NetworkX graph
|
|
123
|
+
Undirected graph
|
|
124
|
+
|
|
125
|
+
Returns
|
|
126
|
+
-------
|
|
127
|
+
min_edge_dominating_set : set
|
|
128
|
+
Returns a set of dominating edges whose size is no more than 2 * OPT.
|
|
129
|
+
|
|
130
|
+
Examples
|
|
131
|
+
--------
|
|
132
|
+
>>> G = nx.petersen_graph()
|
|
133
|
+
>>> nx.approximation.min_edge_dominating_set(G)
|
|
134
|
+
{(0, 1), (4, 9), (6, 8), (5, 7), (2, 3)}
|
|
135
|
+
|
|
136
|
+
Raises
|
|
137
|
+
------
|
|
138
|
+
ValueError
|
|
139
|
+
If the input graph `G` is empty.
|
|
140
|
+
|
|
141
|
+
Notes
|
|
142
|
+
-----
|
|
143
|
+
The algorithm computes an approximate solution to the edge dominating set
|
|
144
|
+
problem. The result is no more than 2 * OPT in terms of size of the set.
|
|
145
|
+
Runtime of the algorithm is $O(|E|)$.
|
|
146
|
+
"""
|
|
147
|
+
if not G:
|
|
148
|
+
raise ValueError("Expected non-empty NetworkX graph!")
|
|
149
|
+
return maximal_matching(G)
|