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,163 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Communicability.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
from networkx.utils import not_implemented_for
|
|
7
|
+
|
|
8
|
+
__all__ = ["communicability", "communicability_exp"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@not_implemented_for("directed")
|
|
12
|
+
@not_implemented_for("multigraph")
|
|
13
|
+
@nx._dispatchable
|
|
14
|
+
def communicability(G):
|
|
15
|
+
r"""Returns communicability between all pairs of nodes in G.
|
|
16
|
+
|
|
17
|
+
The communicability between pairs of nodes in G is the sum of
|
|
18
|
+
walks of different lengths starting at node u and ending at node v.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
G: graph
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
comm: dictionary of dictionaries
|
|
27
|
+
Dictionary of dictionaries keyed by nodes with communicability
|
|
28
|
+
as the value.
|
|
29
|
+
|
|
30
|
+
Raises
|
|
31
|
+
------
|
|
32
|
+
NetworkXError
|
|
33
|
+
If the graph is not undirected and simple.
|
|
34
|
+
|
|
35
|
+
See Also
|
|
36
|
+
--------
|
|
37
|
+
communicability_exp:
|
|
38
|
+
Communicability between all pairs of nodes in G using spectral
|
|
39
|
+
decomposition.
|
|
40
|
+
communicability_betweenness_centrality:
|
|
41
|
+
Communicability betweenness centrality for each node in G.
|
|
42
|
+
|
|
43
|
+
Notes
|
|
44
|
+
-----
|
|
45
|
+
This algorithm uses a spectral decomposition of the adjacency matrix.
|
|
46
|
+
Let G=(V,E) be a simple undirected graph. Using the connection between
|
|
47
|
+
the powers of the adjacency matrix and the number of walks in the graph,
|
|
48
|
+
the communicability between nodes `u` and `v` based on the graph spectrum
|
|
49
|
+
is [1]_
|
|
50
|
+
|
|
51
|
+
.. math::
|
|
52
|
+
C(u,v)=\sum_{j=1}^{n}\phi_{j}(u)\phi_{j}(v)e^{\lambda_{j}},
|
|
53
|
+
|
|
54
|
+
where `\phi_{j}(u)` is the `u\rm{th}` element of the `j\rm{th}` orthonormal
|
|
55
|
+
eigenvector of the adjacency matrix associated with the eigenvalue
|
|
56
|
+
`\lambda_{j}`.
|
|
57
|
+
|
|
58
|
+
References
|
|
59
|
+
----------
|
|
60
|
+
.. [1] Ernesto Estrada, Naomichi Hatano,
|
|
61
|
+
"Communicability in complex networks",
|
|
62
|
+
Phys. Rev. E 77, 036111 (2008).
|
|
63
|
+
https://arxiv.org/abs/0707.0756
|
|
64
|
+
|
|
65
|
+
Examples
|
|
66
|
+
--------
|
|
67
|
+
>>> G = nx.Graph([(0, 1), (1, 2), (1, 5), (5, 4), (2, 4), (2, 3), (4, 3), (3, 6)])
|
|
68
|
+
>>> c = nx.communicability(G)
|
|
69
|
+
"""
|
|
70
|
+
import numpy as np
|
|
71
|
+
|
|
72
|
+
nodelist = list(G) # ordering of nodes in matrix
|
|
73
|
+
A = nx.to_numpy_array(G, nodelist)
|
|
74
|
+
# convert to 0-1 matrix
|
|
75
|
+
A[A != 0.0] = 1
|
|
76
|
+
w, vec = np.linalg.eigh(A)
|
|
77
|
+
expw = np.exp(w)
|
|
78
|
+
mapping = dict(zip(nodelist, range(len(nodelist))))
|
|
79
|
+
c = {}
|
|
80
|
+
# computing communicabilities
|
|
81
|
+
for u in G:
|
|
82
|
+
c[u] = {}
|
|
83
|
+
for v in G:
|
|
84
|
+
s = 0
|
|
85
|
+
p = mapping[u]
|
|
86
|
+
q = mapping[v]
|
|
87
|
+
for j in range(len(nodelist)):
|
|
88
|
+
s += vec[:, j][p] * vec[:, j][q] * expw[j]
|
|
89
|
+
c[u][v] = float(s)
|
|
90
|
+
return c
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@not_implemented_for("directed")
|
|
94
|
+
@not_implemented_for("multigraph")
|
|
95
|
+
@nx._dispatchable
|
|
96
|
+
def communicability_exp(G):
|
|
97
|
+
r"""Returns communicability between all pairs of nodes in G.
|
|
98
|
+
|
|
99
|
+
Communicability between pair of node (u,v) of node in G is the sum of
|
|
100
|
+
walks of different lengths starting at node u and ending at node v.
|
|
101
|
+
|
|
102
|
+
Parameters
|
|
103
|
+
----------
|
|
104
|
+
G: graph
|
|
105
|
+
|
|
106
|
+
Returns
|
|
107
|
+
-------
|
|
108
|
+
comm: dictionary of dictionaries
|
|
109
|
+
Dictionary of dictionaries keyed by nodes with communicability
|
|
110
|
+
as the value.
|
|
111
|
+
|
|
112
|
+
Raises
|
|
113
|
+
------
|
|
114
|
+
NetworkXError
|
|
115
|
+
If the graph is not undirected and simple.
|
|
116
|
+
|
|
117
|
+
See Also
|
|
118
|
+
--------
|
|
119
|
+
communicability:
|
|
120
|
+
Communicability between pairs of nodes in G.
|
|
121
|
+
communicability_betweenness_centrality:
|
|
122
|
+
Communicability betweenness centrality for each node in G.
|
|
123
|
+
|
|
124
|
+
Notes
|
|
125
|
+
-----
|
|
126
|
+
This algorithm uses matrix exponentiation of the adjacency matrix.
|
|
127
|
+
|
|
128
|
+
Let G=(V,E) be a simple undirected graph. Using the connection between
|
|
129
|
+
the powers of the adjacency matrix and the number of walks in the graph,
|
|
130
|
+
the communicability between nodes u and v is [1]_,
|
|
131
|
+
|
|
132
|
+
.. math::
|
|
133
|
+
C(u,v) = (e^A)_{uv},
|
|
134
|
+
|
|
135
|
+
where `A` is the adjacency matrix of G.
|
|
136
|
+
|
|
137
|
+
References
|
|
138
|
+
----------
|
|
139
|
+
.. [1] Ernesto Estrada, Naomichi Hatano,
|
|
140
|
+
"Communicability in complex networks",
|
|
141
|
+
Phys. Rev. E 77, 036111 (2008).
|
|
142
|
+
https://arxiv.org/abs/0707.0756
|
|
143
|
+
|
|
144
|
+
Examples
|
|
145
|
+
--------
|
|
146
|
+
>>> G = nx.Graph([(0, 1), (1, 2), (1, 5), (5, 4), (2, 4), (2, 3), (4, 3), (3, 6)])
|
|
147
|
+
>>> c = nx.communicability_exp(G)
|
|
148
|
+
"""
|
|
149
|
+
import scipy as sp
|
|
150
|
+
|
|
151
|
+
nodelist = list(G) # ordering of nodes in matrix
|
|
152
|
+
A = nx.to_numpy_array(G, nodelist)
|
|
153
|
+
# convert to 0-1 matrix
|
|
154
|
+
A[A != 0.0] = 1
|
|
155
|
+
# communicability matrix
|
|
156
|
+
expA = sp.linalg.expm(A)
|
|
157
|
+
mapping = dict(zip(nodelist, range(len(nodelist))))
|
|
158
|
+
c = {}
|
|
159
|
+
for u in G:
|
|
160
|
+
c[u] = {}
|
|
161
|
+
for v in G:
|
|
162
|
+
c[u][v] = float(expA[mapping[u], mapping[v]])
|
|
163
|
+
return c
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Functions for computing and measuring community structure.
|
|
2
|
+
|
|
3
|
+
The ``community`` subpackage can be accessed by using :mod:`networkx.community`, then accessing the
|
|
4
|
+
functions as attributes of ``community``. For example::
|
|
5
|
+
|
|
6
|
+
>>> import networkx as nx
|
|
7
|
+
>>> G = nx.barbell_graph(5, 1)
|
|
8
|
+
>>> communities_generator = nx.community.girvan_newman(G)
|
|
9
|
+
>>> top_level_communities = next(communities_generator)
|
|
10
|
+
>>> next_level_communities = next(communities_generator)
|
|
11
|
+
>>> sorted(map(sorted, next_level_communities))
|
|
12
|
+
[[0, 1, 2, 3, 4], [5], [6, 7, 8, 9, 10]]
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from networkx.algorithms.community.asyn_fluid import *
|
|
17
|
+
from networkx.algorithms.community.bipartitions import *
|
|
18
|
+
from networkx.algorithms.community.centrality import *
|
|
19
|
+
from networkx.algorithms.community.divisive import *
|
|
20
|
+
from networkx.algorithms.community.kclique import *
|
|
21
|
+
from networkx.algorithms.community.label_propagation import *
|
|
22
|
+
from networkx.algorithms.community.lukes import *
|
|
23
|
+
from networkx.algorithms.community.modularity_max import *
|
|
24
|
+
from networkx.algorithms.community.quality import *
|
|
25
|
+
from networkx.algorithms.community.community_utils import *
|
|
26
|
+
from networkx.algorithms.community.louvain import *
|
|
27
|
+
from networkx.algorithms.community.leiden import *
|
|
28
|
+
from networkx.algorithms.community.local import *
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""Asynchronous Fluid Communities algorithm for community detection."""
|
|
2
|
+
|
|
3
|
+
from collections import Counter
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
from networkx.algorithms.components import is_connected
|
|
7
|
+
from networkx.exception import NetworkXError
|
|
8
|
+
from networkx.utils import groups, not_implemented_for, py_random_state
|
|
9
|
+
|
|
10
|
+
__all__ = ["asyn_fluidc"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@not_implemented_for("directed")
|
|
14
|
+
@not_implemented_for("multigraph")
|
|
15
|
+
@py_random_state(3)
|
|
16
|
+
@nx._dispatchable
|
|
17
|
+
def asyn_fluidc(G, k, max_iter=100, seed=None):
|
|
18
|
+
"""Returns communities in `G` as detected by Fluid Communities algorithm.
|
|
19
|
+
|
|
20
|
+
The asynchronous fluid communities algorithm is described in
|
|
21
|
+
[1]_. The algorithm is based on the simple idea of fluids interacting
|
|
22
|
+
in an environment, expanding and pushing each other. Its initialization is
|
|
23
|
+
random, so found communities may vary on different executions.
|
|
24
|
+
|
|
25
|
+
The algorithm proceeds as follows. First each of the initial k communities
|
|
26
|
+
is initialized in a random vertex in the graph. Then the algorithm iterates
|
|
27
|
+
over all vertices in a random order, updating the community of each vertex
|
|
28
|
+
based on its own community and the communities of its neighbors. This
|
|
29
|
+
process is performed several times until convergence.
|
|
30
|
+
At all times, each community has a total density of 1, which is equally
|
|
31
|
+
distributed among the vertices it contains. If a vertex changes of
|
|
32
|
+
community, vertex densities of affected communities are adjusted
|
|
33
|
+
immediately. When a complete iteration over all vertices is done, such that
|
|
34
|
+
no vertex changes the community it belongs to, the algorithm has converged
|
|
35
|
+
and returns.
|
|
36
|
+
|
|
37
|
+
This is the original version of the algorithm described in [1]_.
|
|
38
|
+
Unfortunately, it does not support weighted graphs yet.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
G : NetworkX graph
|
|
43
|
+
Graph must be simple and undirected.
|
|
44
|
+
|
|
45
|
+
k : integer
|
|
46
|
+
The number of communities to be found.
|
|
47
|
+
|
|
48
|
+
max_iter : integer
|
|
49
|
+
The number of maximum iterations allowed. By default 100.
|
|
50
|
+
|
|
51
|
+
seed : integer, random_state, or None (default)
|
|
52
|
+
Indicator of random number generation state.
|
|
53
|
+
See :ref:`Randomness<randomness>`.
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
57
|
+
communities : iterable
|
|
58
|
+
Iterable of communities given as sets of nodes.
|
|
59
|
+
|
|
60
|
+
Notes
|
|
61
|
+
-----
|
|
62
|
+
k variable is not an optional argument.
|
|
63
|
+
|
|
64
|
+
References
|
|
65
|
+
----------
|
|
66
|
+
.. [1] Parés F., Garcia-Gasulla D. et al. "Fluid Communities: A
|
|
67
|
+
Competitive and Highly Scalable Community Detection Algorithm".
|
|
68
|
+
[https://arxiv.org/pdf/1703.09307.pdf].
|
|
69
|
+
"""
|
|
70
|
+
# Initial checks
|
|
71
|
+
if not isinstance(k, int):
|
|
72
|
+
raise NetworkXError("k must be an integer.")
|
|
73
|
+
if not k > 0:
|
|
74
|
+
raise NetworkXError("k must be greater than 0.")
|
|
75
|
+
if not is_connected(G):
|
|
76
|
+
raise NetworkXError("Fluid Communities require connected Graphs.")
|
|
77
|
+
if len(G) < k:
|
|
78
|
+
raise NetworkXError("k cannot be bigger than the number of nodes.")
|
|
79
|
+
if max_iter <= 0:
|
|
80
|
+
msg = f"{max_iter=} must be greater than 0"
|
|
81
|
+
raise ValueError(msg)
|
|
82
|
+
# Initialization
|
|
83
|
+
max_density = 1.0
|
|
84
|
+
vertices = list(G)
|
|
85
|
+
seed.shuffle(vertices)
|
|
86
|
+
communities = {n: i for i, n in enumerate(vertices[:k])}
|
|
87
|
+
density = {}
|
|
88
|
+
com_to_numvertices = {}
|
|
89
|
+
for vertex in communities:
|
|
90
|
+
com_to_numvertices[communities[vertex]] = 1
|
|
91
|
+
density[communities[vertex]] = max_density
|
|
92
|
+
# Set up control variables and start iterating
|
|
93
|
+
iter_count = 0
|
|
94
|
+
cont = True
|
|
95
|
+
while cont and iter_count < max_iter:
|
|
96
|
+
cont = False
|
|
97
|
+
iter_count += 1
|
|
98
|
+
# Loop over all vertices in graph in a random order
|
|
99
|
+
vertices = list(G)
|
|
100
|
+
seed.shuffle(vertices)
|
|
101
|
+
for vertex in vertices:
|
|
102
|
+
# Updating rule
|
|
103
|
+
com_counter = Counter()
|
|
104
|
+
# Take into account self vertex community
|
|
105
|
+
try:
|
|
106
|
+
com_counter.update({communities[vertex]: density[communities[vertex]]})
|
|
107
|
+
except KeyError:
|
|
108
|
+
pass
|
|
109
|
+
# Gather neighbor vertex communities
|
|
110
|
+
for v in G[vertex]:
|
|
111
|
+
try:
|
|
112
|
+
com_counter.update({communities[v]: density[communities[v]]})
|
|
113
|
+
except KeyError:
|
|
114
|
+
continue
|
|
115
|
+
# Check which is the community with highest density
|
|
116
|
+
new_com = -1
|
|
117
|
+
if len(com_counter.keys()) > 0:
|
|
118
|
+
max_freq = max(com_counter.values())
|
|
119
|
+
best_communities = [
|
|
120
|
+
com
|
|
121
|
+
for com, freq in com_counter.items()
|
|
122
|
+
if (max_freq - freq) < 0.0001
|
|
123
|
+
]
|
|
124
|
+
# If actual vertex com in best communities, it is preserved
|
|
125
|
+
try:
|
|
126
|
+
if communities[vertex] in best_communities:
|
|
127
|
+
new_com = communities[vertex]
|
|
128
|
+
except KeyError:
|
|
129
|
+
pass
|
|
130
|
+
|
|
131
|
+
# If vertex community changes...
|
|
132
|
+
if new_com == -1:
|
|
133
|
+
# Set flag of non-convergence
|
|
134
|
+
cont = True
|
|
135
|
+
# Randomly chose a new community from candidates
|
|
136
|
+
new_com = seed.choice(best_communities)
|
|
137
|
+
# Update previous community status
|
|
138
|
+
try:
|
|
139
|
+
com_to_numvertices[communities[vertex]] -= 1
|
|
140
|
+
density[communities[vertex]] = (
|
|
141
|
+
max_density / com_to_numvertices[communities[vertex]]
|
|
142
|
+
)
|
|
143
|
+
except KeyError:
|
|
144
|
+
pass
|
|
145
|
+
# Update new community status
|
|
146
|
+
communities[vertex] = new_com
|
|
147
|
+
com_to_numvertices[communities[vertex]] += 1
|
|
148
|
+
density[communities[vertex]] = (
|
|
149
|
+
max_density / com_to_numvertices[communities[vertex]]
|
|
150
|
+
)
|
|
151
|
+
# If maximum iterations reached --> output actual results
|
|
152
|
+
# Return results by grouping communities as list of vertices
|
|
153
|
+
return iter(groups(communities).values())
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
"""Functions for splitting a network into two communities (finding a bipartition)."""
|
|
2
|
+
|
|
3
|
+
import random
|
|
4
|
+
from copy import deepcopy
|
|
5
|
+
from itertools import count
|
|
6
|
+
|
|
7
|
+
import networkx as nx
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"kernighan_lin_bisection",
|
|
11
|
+
"spectral_modularity_bipartition",
|
|
12
|
+
"greedy_node_swap_bipartition",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _kernighan_lin_sweep(edge_info, side):
|
|
17
|
+
"""
|
|
18
|
+
This is a modified form of Kernighan-Lin, which moves single nodes at a
|
|
19
|
+
time, alternating between sides to keep the bisection balanced. We keep
|
|
20
|
+
two min-heaps of swap costs to make optimal-next-move selection fast.
|
|
21
|
+
"""
|
|
22
|
+
heap0, heap1 = cost_heaps = nx.utils.BinaryHeap(), nx.utils.BinaryHeap()
|
|
23
|
+
# we use heap methods insert, pop, and get
|
|
24
|
+
for u, nbrs in edge_info.items():
|
|
25
|
+
cost_u = sum(wt if side[v] else -wt for v, wt in nbrs.items())
|
|
26
|
+
if side[u]:
|
|
27
|
+
heap1.insert(u, cost_u)
|
|
28
|
+
else:
|
|
29
|
+
heap0.insert(u, -cost_u)
|
|
30
|
+
|
|
31
|
+
def _update_heap_values(node):
|
|
32
|
+
side_node = side[node]
|
|
33
|
+
for nbr, wt in edge_info[node].items():
|
|
34
|
+
side_nbr = side[nbr]
|
|
35
|
+
if side_nbr == side_node:
|
|
36
|
+
wt = -wt
|
|
37
|
+
heap_nbr = cost_heaps[side_nbr]
|
|
38
|
+
if nbr in heap_nbr:
|
|
39
|
+
cost_nbr = heap_nbr.get(nbr) + 2 * wt
|
|
40
|
+
# allow_increase lets us update a value already on the heap
|
|
41
|
+
heap_nbr.insert(nbr, cost_nbr, allow_increase=True)
|
|
42
|
+
|
|
43
|
+
i = 0
|
|
44
|
+
totcost = 0
|
|
45
|
+
while heap0 and heap1:
|
|
46
|
+
u, cost_u = heap0.pop()
|
|
47
|
+
_update_heap_values(u)
|
|
48
|
+
v, cost_v = heap1.pop()
|
|
49
|
+
_update_heap_values(v)
|
|
50
|
+
totcost += cost_u + cost_v
|
|
51
|
+
i += 1
|
|
52
|
+
yield totcost, i, (u, v)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@nx.utils.not_implemented_for("directed")
|
|
56
|
+
@nx.utils.py_random_state(4)
|
|
57
|
+
@nx._dispatchable(edge_attrs="weight")
|
|
58
|
+
def kernighan_lin_bisection(G, partition=None, max_iter=10, weight="weight", seed=None):
|
|
59
|
+
"""Partition a graph into two blocks using the Kernighan–Lin algorithm.
|
|
60
|
+
|
|
61
|
+
This algorithm partitions a network into two sets by iteratively
|
|
62
|
+
swapping pairs of nodes to reduce the edge cut between the two sets. The
|
|
63
|
+
pairs are chosen according to a modified form of Kernighan-Lin [1]_, which
|
|
64
|
+
moves nodes individually, alternating between sides to keep the bisection
|
|
65
|
+
balanced.
|
|
66
|
+
|
|
67
|
+
Kernighan-Lin is an approximate algorithm for maximal modularity bisection.
|
|
68
|
+
In [2]_ they suggest that fine-tuned improvements can be made using
|
|
69
|
+
greedy node swapping, (see `greedy_node_swap_bipartition`).
|
|
70
|
+
The improvements are typically only a few percent of the modularity value.
|
|
71
|
+
But they claim that can make a difference between a good and excellent method.
|
|
72
|
+
This function does not perform any improvements. But you can do that yourself.
|
|
73
|
+
|
|
74
|
+
Parameters
|
|
75
|
+
----------
|
|
76
|
+
G : NetworkX graph
|
|
77
|
+
Graph must be undirected.
|
|
78
|
+
|
|
79
|
+
partition : tuple
|
|
80
|
+
Pair of iterables containing an initial partition. If not
|
|
81
|
+
specified, a random balanced partition is used.
|
|
82
|
+
|
|
83
|
+
max_iter : int
|
|
84
|
+
Maximum number of times to attempt swaps to find an
|
|
85
|
+
improvement before giving up.
|
|
86
|
+
|
|
87
|
+
weight : string or function (default: "weight")
|
|
88
|
+
If this is a string, then edge weights will be accessed via the
|
|
89
|
+
edge attribute with this key (that is, the weight of the edge
|
|
90
|
+
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
|
|
91
|
+
such edge attribute exists, the weight of the edge is assumed to
|
|
92
|
+
be one.
|
|
93
|
+
|
|
94
|
+
If this is a function, the weight of an edge is the value
|
|
95
|
+
returned by the function. The function must accept exactly three
|
|
96
|
+
positional arguments: the two endpoints of an edge and the
|
|
97
|
+
dictionary of edge attributes for that edge. The function must
|
|
98
|
+
return a number or None to indicate a hidden edge.
|
|
99
|
+
|
|
100
|
+
seed : integer, random_state, or None (default)
|
|
101
|
+
Indicator of random number generation state.
|
|
102
|
+
See :ref:`Randomness<randomness>`.
|
|
103
|
+
Only used if partition is None
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
partition : tuple
|
|
108
|
+
A pair of sets of nodes representing the bipartition.
|
|
109
|
+
|
|
110
|
+
Raises
|
|
111
|
+
------
|
|
112
|
+
NetworkXError
|
|
113
|
+
If `partition` is not a valid partition of the nodes of the graph.
|
|
114
|
+
|
|
115
|
+
References
|
|
116
|
+
----------
|
|
117
|
+
.. [1] Kernighan, B. W.; Lin, Shen (1970).
|
|
118
|
+
"An efficient heuristic procedure for partitioning graphs."
|
|
119
|
+
*Bell Systems Technical Journal* 49: 291--307.
|
|
120
|
+
Oxford University Press 2011.
|
|
121
|
+
.. [2] M. E. J. Newman,
|
|
122
|
+
"Modularity and community structure in networks",
|
|
123
|
+
PNAS, 103 (23), p. 8577-8582,
|
|
124
|
+
https://doi.org/10.1073/pnas.0601602103
|
|
125
|
+
|
|
126
|
+
"""
|
|
127
|
+
nodes = list(G)
|
|
128
|
+
|
|
129
|
+
if partition is None:
|
|
130
|
+
seed.shuffle(nodes)
|
|
131
|
+
mid = len(nodes) // 2
|
|
132
|
+
A, B = nodes[:mid], nodes[mid:]
|
|
133
|
+
else:
|
|
134
|
+
try:
|
|
135
|
+
A, B = partition
|
|
136
|
+
except (TypeError, ValueError) as err:
|
|
137
|
+
raise nx.NetworkXError("partition must be two sets") from err
|
|
138
|
+
if not nx.community.is_partition(G, [A, B]):
|
|
139
|
+
raise nx.NetworkXError("partition invalid")
|
|
140
|
+
|
|
141
|
+
side = {node: (node in A) for node in nodes}
|
|
142
|
+
|
|
143
|
+
# ruff: noqa: E731 skips check for no lambda functions
|
|
144
|
+
# Using shortest_paths _weight_function with sum instead of min on multiedges
|
|
145
|
+
if callable(weight):
|
|
146
|
+
sum_weight = weight
|
|
147
|
+
elif G.is_multigraph():
|
|
148
|
+
sum_weight = lambda u, v, d: sum(dd.get(weight, 1) for dd in d.values())
|
|
149
|
+
else:
|
|
150
|
+
sum_weight = lambda u, v, d: d.get(weight, 1)
|
|
151
|
+
|
|
152
|
+
edge_info = {
|
|
153
|
+
u: {v: wt for v, d in nbrs.items() if (wt := sum_weight(u, v, d)) is not None}
|
|
154
|
+
for u, nbrs in G._adj.items()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
for i in range(max_iter):
|
|
158
|
+
costs = list(_kernighan_lin_sweep(edge_info, side))
|
|
159
|
+
# find out how many edges to update: min_i
|
|
160
|
+
min_cost, min_i, _ = min(costs)
|
|
161
|
+
if min_cost >= 0:
|
|
162
|
+
break
|
|
163
|
+
|
|
164
|
+
for _, _, (u, v) in costs[:min_i]:
|
|
165
|
+
side[u] = 1
|
|
166
|
+
side[v] = 0
|
|
167
|
+
|
|
168
|
+
part1 = {u for u, s in side.items() if s == 0}
|
|
169
|
+
part2 = {u for u, s in side.items() if s == 1}
|
|
170
|
+
return part1, part2
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@nx.utils.not_implemented_for("directed")
|
|
174
|
+
@nx.utils.not_implemented_for("multigraph")
|
|
175
|
+
def spectral_modularity_bipartition(G):
|
|
176
|
+
r"""Return a bipartition of the nodes based on the spectrum of the
|
|
177
|
+
modularity matrix of the graph.
|
|
178
|
+
|
|
179
|
+
This method calculates the eigenvector associated with the second
|
|
180
|
+
largest eigenvalue of the modularity matrix, where the modularity
|
|
181
|
+
matrix *B* is defined by
|
|
182
|
+
|
|
183
|
+
..math::
|
|
184
|
+
|
|
185
|
+
B_{i j} = A_{i j} - \frac{k_i k_j}{2 m},
|
|
186
|
+
|
|
187
|
+
where *A* is the adjacency matrix, `k_i` is the degree of node *i*,
|
|
188
|
+
and *m* is the number of edges in the graph. Nodes whose
|
|
189
|
+
corresponding values in the eigenvector are negative are placed in
|
|
190
|
+
one block, nodes whose values are nonnegative are placed in another
|
|
191
|
+
block.
|
|
192
|
+
|
|
193
|
+
Parameters
|
|
194
|
+
----------
|
|
195
|
+
G : NetworkX graph
|
|
196
|
+
|
|
197
|
+
Returns
|
|
198
|
+
-------
|
|
199
|
+
C : tuple
|
|
200
|
+
Pair of communities as two sets of nodes of ``G``, partitioned
|
|
201
|
+
according to second largest eigenvalue of the modularity matrix.
|
|
202
|
+
|
|
203
|
+
Examples
|
|
204
|
+
--------
|
|
205
|
+
>>> G = nx.karate_club_graph()
|
|
206
|
+
>>> MrHi, Officer = nx.community.spectral_modularity_bipartition(G)
|
|
207
|
+
>>> MrHi, Officer = sorted([sorted(MrHi), sorted(Officer)])
|
|
208
|
+
>>> MrHi
|
|
209
|
+
[0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 16, 17, 19, 21]
|
|
210
|
+
>>> Officer
|
|
211
|
+
[8, 9, 14, 15, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
|
212
|
+
|
|
213
|
+
References
|
|
214
|
+
----------
|
|
215
|
+
.. [1] M. E. J. Newman *Networks: An Introduction*, pages 373--378
|
|
216
|
+
Oxford University Press 2011.
|
|
217
|
+
.. [2] M. E. J. Newman,
|
|
218
|
+
"Modularity and community structure in networks",
|
|
219
|
+
PNAS, 103 (23), p. 8577-8582,
|
|
220
|
+
https://doi.org/10.1073/pnas.0601602103
|
|
221
|
+
|
|
222
|
+
"""
|
|
223
|
+
import numpy as np
|
|
224
|
+
|
|
225
|
+
B = nx.linalg.modularity_matrix(G)
|
|
226
|
+
eigenvalues, eigenvectors = np.linalg.eig(B)
|
|
227
|
+
index = np.argsort(eigenvalues)[-1]
|
|
228
|
+
v2 = zip(np.real(eigenvectors[:, index]), G)
|
|
229
|
+
left, right = set(), set()
|
|
230
|
+
for u, n in v2:
|
|
231
|
+
if u < 0:
|
|
232
|
+
left.add(n)
|
|
233
|
+
else:
|
|
234
|
+
right.add(n)
|
|
235
|
+
return left, right
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
@nx.utils.not_implemented_for("multigraph")
|
|
239
|
+
def greedy_node_swap_bipartition(G, *, init_split=None, max_iter=10):
|
|
240
|
+
"""Split the nodes into two communities based on greedy
|
|
241
|
+
modularity maximization.
|
|
242
|
+
|
|
243
|
+
The algorithm works by selecting a node to change communities which
|
|
244
|
+
will maximize the modularity. The swap is made and the community
|
|
245
|
+
structure with the highest modularity is kept.
|
|
246
|
+
|
|
247
|
+
Parameters
|
|
248
|
+
----------
|
|
249
|
+
G : NetworkX graph
|
|
250
|
+
|
|
251
|
+
init_split : 2-tuple of sets of nodes
|
|
252
|
+
Pair of sets of nodes in ``G`` providing an initial bipartition
|
|
253
|
+
for the algorithm. If not specified, a random balanced partition
|
|
254
|
+
is used. If this pair of sets is not a partition of the nodes of `G`,
|
|
255
|
+
:exc:`NetworkXException` is raised.
|
|
256
|
+
|
|
257
|
+
max_iter : int
|
|
258
|
+
Maximum number of iterations of attempting swaps to find an improvement.
|
|
259
|
+
|
|
260
|
+
Returns
|
|
261
|
+
-------
|
|
262
|
+
max_split : 2-tuple of sets of nodes
|
|
263
|
+
Pair of sets of nodes of ``G``, partitioned according to a
|
|
264
|
+
node swap greedy modularity maximization algorithm.
|
|
265
|
+
|
|
266
|
+
Raises
|
|
267
|
+
------
|
|
268
|
+
NetworkXError
|
|
269
|
+
if init_split is not a valid partition of the
|
|
270
|
+
graph into two communities or if G is a MultiGraph
|
|
271
|
+
|
|
272
|
+
Examples
|
|
273
|
+
--------
|
|
274
|
+
>>> G = nx.barbell_graph(3, 0)
|
|
275
|
+
>>> left, right = nx.community.greedy_node_swap_bipartition(G)
|
|
276
|
+
>>> # Sort the communities so the nodes appear in increasing order.
|
|
277
|
+
>>> left, right = sorted([sorted(left), sorted(right)])
|
|
278
|
+
>>> sorted(left)
|
|
279
|
+
[0, 1, 2]
|
|
280
|
+
>>> sorted(right)
|
|
281
|
+
[3, 4, 5]
|
|
282
|
+
|
|
283
|
+
Notes
|
|
284
|
+
-----
|
|
285
|
+
This function is not implemented for multigraphs.
|
|
286
|
+
|
|
287
|
+
References
|
|
288
|
+
----------
|
|
289
|
+
.. [1] M. E. J. Newman "Networks: An Introduction", pages 373--375.
|
|
290
|
+
Oxford University Press 2011.
|
|
291
|
+
|
|
292
|
+
"""
|
|
293
|
+
if init_split is None:
|
|
294
|
+
m1 = len(G) // 2
|
|
295
|
+
m2 = len(G) - m1
|
|
296
|
+
some_nodes = set(random.sample(list(G), m1))
|
|
297
|
+
other_nodes = {n for n in G if n not in some_nodes}
|
|
298
|
+
best_split_so_far = (some_nodes, other_nodes)
|
|
299
|
+
else:
|
|
300
|
+
if not nx.community.is_partition(G, init_split):
|
|
301
|
+
raise nx.NetworkXError("init_split is not a partition of G")
|
|
302
|
+
if not len(init_split) == 2:
|
|
303
|
+
raise nx.NetworkXError("init_split must be a bipartition")
|
|
304
|
+
best_split_so_far = deepcopy(init_split)
|
|
305
|
+
|
|
306
|
+
best_mod = nx.community.modularity(G, best_split_so_far)
|
|
307
|
+
|
|
308
|
+
max_split, max_mod = best_split_so_far, best_mod
|
|
309
|
+
its = 0
|
|
310
|
+
m = G.number_of_edges()
|
|
311
|
+
G_degree = dict(G.degree)
|
|
312
|
+
|
|
313
|
+
while max_mod >= best_mod and its < max_iter:
|
|
314
|
+
best_split_so_far = max_split
|
|
315
|
+
best_mod = max_mod
|
|
316
|
+
next_split = deepcopy(max_split)
|
|
317
|
+
next_mod = max_mod
|
|
318
|
+
nodes = set(G)
|
|
319
|
+
while nodes:
|
|
320
|
+
max_swap = -1
|
|
321
|
+
max_node = None
|
|
322
|
+
max_node_comm = None
|
|
323
|
+
left, right = next_split
|
|
324
|
+
leftd = sum(G_degree[n] for n in left)
|
|
325
|
+
rightd = sum(G_degree[n] for n in right)
|
|
326
|
+
for n in nodes:
|
|
327
|
+
if n in left:
|
|
328
|
+
in_comm, out_comm = left, right
|
|
329
|
+
in_deg, out_deg = leftd, rightd
|
|
330
|
+
else:
|
|
331
|
+
in_comm, out_comm = right, left
|
|
332
|
+
in_deg, out_deg = rightd, leftd
|
|
333
|
+
|
|
334
|
+
d_eii = -len(G[n].keys() & in_comm) / m
|
|
335
|
+
d_ejj = len(G[n].keys() & out_comm) / m
|
|
336
|
+
deg = G_degree[n]
|
|
337
|
+
d_sum_ai = (deg / (2 * m**2)) * (in_deg - out_deg - deg)
|
|
338
|
+
swap_change = d_eii + d_ejj + d_sum_ai
|
|
339
|
+
|
|
340
|
+
if swap_change > max_swap:
|
|
341
|
+
max_swap = swap_change
|
|
342
|
+
max_node = n
|
|
343
|
+
max_node_comm = in_comm
|
|
344
|
+
non_max_node_comm = out_comm
|
|
345
|
+
# swap the node from one comm to the other
|
|
346
|
+
max_node_comm.remove(max_node)
|
|
347
|
+
non_max_node_comm.add(max_node)
|
|
348
|
+
next_mod += max_swap
|
|
349
|
+
# deepcopy next_split each time it reaches a high (might go lower later)
|
|
350
|
+
if next_mod > max_mod:
|
|
351
|
+
max_split, max_mod = deepcopy(next_split), next_mod
|
|
352
|
+
nodes.remove(max_node)
|
|
353
|
+
its += 1
|
|
354
|
+
return best_split_so_far
|