okstra 0.107.2 → 0.109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/prompts/lead/okstra-lead-contract.md +1 -1
- package/runtime/prompts/profiles/_common-contract.md +3 -2
- package/runtime/python/okstra_ctl/graphify_cmd.py +225 -0
- package/runtime/python/okstra_ctl/resolve_task_key.py +15 -9
- package/runtime/python/okstra_ctl/session.py +44 -0
- package/runtime/python/okstra_project/__init__.py +2 -0
- package/runtime/python/okstra_project/state.py +36 -0
- package/runtime/python/okstra_token_usage/claude.py +15 -9
- package/runtime/python/okstra_token_usage/cli.py +23 -0
- package/runtime/python/okstra_token_usage/collect.py +163 -4
- package/runtime/python/okstra_vendor/__init__.py +41 -0
- package/runtime/python/okstra_vendor/graphify/.vendored-version +1 -0
- package/runtime/python/okstra_vendor/graphify/__init__.py +28 -0
- package/runtime/python/okstra_vendor/graphify/__main__.py +1371 -0
- package/runtime/python/okstra_vendor/graphify/analyze.py +540 -0
- package/runtime/python/okstra_vendor/graphify/benchmark.py +129 -0
- package/runtime/python/okstra_vendor/graphify/build.py +107 -0
- package/runtime/python/okstra_vendor/graphify/cache.py +169 -0
- package/runtime/python/okstra_vendor/graphify/cluster.py +137 -0
- package/runtime/python/okstra_vendor/graphify/detect.py +510 -0
- package/runtime/python/okstra_vendor/graphify/export.py +1014 -0
- package/runtime/python/okstra_vendor/graphify/extract.py +3277 -0
- package/runtime/python/okstra_vendor/graphify/hooks.py +220 -0
- package/runtime/python/okstra_vendor/graphify/ingest.py +297 -0
- package/runtime/python/okstra_vendor/graphify/manifest.py +4 -0
- package/runtime/python/okstra_vendor/graphify/report.py +175 -0
- package/runtime/python/okstra_vendor/graphify/security.py +203 -0
- package/runtime/python/okstra_vendor/graphify/serve.py +373 -0
- package/runtime/python/okstra_vendor/graphify/skill-aider.md +1184 -0
- package/runtime/python/okstra_vendor/graphify/skill-claw.md +1184 -0
- package/runtime/python/okstra_vendor/graphify/skill-codex.md +1242 -0
- package/runtime/python/okstra_vendor/graphify/skill-copilot.md +1268 -0
- package/runtime/python/okstra_vendor/graphify/skill-droid.md +1239 -0
- package/runtime/python/okstra_vendor/graphify/skill-kiro.md +1183 -0
- package/runtime/python/okstra_vendor/graphify/skill-opencode.md +1238 -0
- package/runtime/python/okstra_vendor/graphify/skill-trae.md +1208 -0
- package/runtime/python/okstra_vendor/graphify/skill-vscode.md +253 -0
- package/runtime/python/okstra_vendor/graphify/skill-windows.md +1245 -0
- package/runtime/python/okstra_vendor/graphify/skill.md +1319 -0
- package/runtime/python/okstra_vendor/graphify/transcribe.py +182 -0
- package/runtime/python/okstra_vendor/graphify/validate.py +72 -0
- package/runtime/python/okstra_vendor/graphify/watch.py +188 -0
- package/runtime/python/okstra_vendor/graphify/wiki.py +214 -0
- package/runtime/python/okstra_vendor/networkx/__init__.py +62 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +134 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +26 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +259 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +71 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +412 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +396 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +150 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +149 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +369 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +44 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +143 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +53 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +265 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py +41 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_clique.py +112 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_connectivity.py +199 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_density.py +146 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_distance_measures.py +59 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_dominating_set.py +78 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_kcomponents.py +303 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_matching.py +8 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_maxcut.py +94 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_ramsey.py +31 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_steinertree.py +306 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_traveling_salesman.py +1014 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_treewidth.py +274 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_vertex_cover.py +68 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +1508 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +255 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +83 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +5 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +122 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +302 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +255 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +160 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +127 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/base_test.py +81 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_connectivity.py +143 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_correlation.py +122 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_mixing.py +174 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_neighbor_degree.py +107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_pairs.py +87 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +164 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +322 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +290 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +289 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +57 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +360 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +105 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +603 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +316 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +590 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +232 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +526 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +112 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +69 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_basic.py +125 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_centrality.py +192 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_cluster.py +84 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_covering.py +33 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_edgelist.py +240 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_extendability.py +334 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_generators.py +407 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_link_analysis.py +218 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matching.py +327 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matrix.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_project.py +409 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_redundancy.py +35 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py +80 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +168 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +205 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +164 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +20 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +591 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +236 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +282 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +364 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +227 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +96 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +150 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +357 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +130 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +787 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +331 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +150 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +200 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +128 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +209 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +141 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +361 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality.py +923 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py +354 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_closeness_centrality.py +274 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality.py +259 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality_subset.py +147 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_closeness.py +43 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_degree_centrality.py +144 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_dispersion.py +73 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py +186 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_group.py +277 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_harmonic_centrality.py +122 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_katz_centrality.py +345 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_laplacian_centrality.py +220 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_load_centrality.py +344 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_percolation_centrality.py +87 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_reaching.py +140 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_second_order_centrality.py +82 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_subgraph.py +110 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_trophic.py +302 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_voterank.py +64 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +181 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +95 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +172 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +443 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +818 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +732 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +4 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +505 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +565 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/test_coloring.py +863 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +163 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +28 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +153 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +354 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +171 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +30 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +216 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +79 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +338 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +162 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +220 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +384 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +227 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +452 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +347 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_asyn_fluid.py +147 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_bipartitions.py +157 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_centrality.py +85 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_divisive.py +106 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_kclique.py +91 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_label_propagation.py +241 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_leiden.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_local.py +76 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_louvain.py +264 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_lukes.py +152 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_modularity_max.py +340 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_quality.py +139 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_utils.py +26 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +6 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +115 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +394 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +282 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +71 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +359 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_attracting.py +70 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_biconnected.py +248 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_connected.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_semiconnected.py +55 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_strongly_connected.py +193 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_weakly_connected.py +96 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +196 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +11 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +811 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +616 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +408 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +1270 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +592 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +220 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +235 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +152 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_connectivity.py +421 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_cuts.py +309 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_disjoint_paths.py +249 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_augmentation.py +502 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_kcomponents.py +488 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcomponents.py +323 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcutsets.py +280 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_stoer_wagner.py +102 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/core.py +588 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +142 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +416 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +1234 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +677 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +1392 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +1095 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +272 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +142 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +268 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +167 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +470 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +11 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +370 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +407 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +238 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +241 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +178 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +611 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +356 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +662 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +425 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +300 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gl1.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gw1.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/netgen-2.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_gomory_hu.py +128 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow.py +573 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow_large_graph.py +155 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_mincost.py +475 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_networksimplex.py +481 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/wlm3.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +194 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +435 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +483 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +57 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +196 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +7 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +1306 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +336 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +1262 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +352 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +308 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.A99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.B99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.A99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.B99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_ismags.py +719 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphism.py +103 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py +490 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_match_helpers.py +64 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_temporalisomorphvf2.py +212 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_tree_isomorphism.py +202 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp.py +1655 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp_helpers.py +3118 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py +196 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +264 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +1102 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +192 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +2 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +337 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +498 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_hits.py +77 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_pagerank.py +213 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +687 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +280 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +1148 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +27 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +738 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/tests/test_contraction.py +544 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +78 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +59 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +219 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +155 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +4 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +324 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +468 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +633 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_all.py +328 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_binary.py +451 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_product.py +491 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_unary.py +55 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +77 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +73 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +464 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +1463 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +306 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +98 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +167 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +5 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +239 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +264 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +716 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_astar.py +254 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense.py +212 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense_numpy.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_generic.py +511 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_unweighted.py +149 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_weighted.py +983 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +625 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +2542 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +2107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +966 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +404 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +30 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +296 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +374 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +564 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +406 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_asteroidal.py +23 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_boundary.py +154 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_bridges.py +144 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_broadcasting.py +109 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chains.py +136 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chordal.py +129 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_clique.py +300 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cluster.py +678 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_communicability.py +80 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_core.py +266 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_covering.py +85 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cuts.py +171 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cycles.py +984 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_d_separation.py +340 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dag.py +835 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_measures.py +831 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_regular.py +85 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominance.py +299 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominating.py +115 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_efficiency.py +58 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_euler.py +314 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graph_hashing.py +872 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graphical.py +163 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hierarchy.py +46 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hybrid.py +24 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_isolate.py +26 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_link_prediction.py +615 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_lowest_common_ancestors.py +459 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_matching.py +556 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_max_weight_clique.py +179 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_mis.py +62 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_moral.py +15 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_node_classification.py +140 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_non_randomness.py +60 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_perfect_graph.py +27 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planar_drawing.py +274 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planarity.py +556 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_polynomials.py +57 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_reciprocity.py +37 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_regular.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_richclub.py +149 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_similarity.py +1158 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_simple_paths.py +803 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smallworld.py +76 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smetric.py +8 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_sparsifiers.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_structuralholes.py +191 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_summarization.py +642 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_swap.py +179 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_threshold.py +270 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_time_dependent.py +431 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_tournament.py +161 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_triads.py +248 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_vitality.py +41 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_voronoi.py +103 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_walks.py +54 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_wiener.py +157 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +981 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +142 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +406 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +5 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +90 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +576 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +529 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +185 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +182 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_beamsearch.py +25 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_bfs.py +203 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_dfs.py +307 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgebfs.py +147 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgedfs.py +131 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +7 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +1042 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +413 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +219 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +1281 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +106 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +273 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_branchings.py +624 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_coding.py +114 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_decomposition.py +79 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_distance_measures.py +99 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_mst.py +934 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_operations.py +53 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_recognition.py +174 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +500 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +76 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +86 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +77 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +278 -0
- package/runtime/python/okstra_vendor/networkx/classes/__init__.py +13 -0
- package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +435 -0
- package/runtime/python/okstra_vendor/networkx/classes/digraph.py +1363 -0
- package/runtime/python/okstra_vendor/networkx/classes/filters.py +95 -0
- package/runtime/python/okstra_vendor/networkx/classes/function.py +1549 -0
- package/runtime/python/okstra_vendor/networkx/classes/graph.py +2082 -0
- package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +269 -0
- package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +977 -0
- package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +1294 -0
- package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +1447 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/dispatch_interface.py +192 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/historical_tests.py +476 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_coreviews.py +362 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph.py +331 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph_historical.py +110 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_filters.py +177 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_function.py +1045 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph.py +950 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph_historical.py +12 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graphviews.py +349 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_multidigraph.py +459 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_multigraph.py +528 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_reportviews.py +1421 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_special.py +131 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_subgraphviews.py +371 -0
- package/runtime/python/okstra_vendor/networkx/conftest.py +261 -0
- package/runtime/python/okstra_vendor/networkx/convert.py +502 -0
- package/runtime/python/okstra_vendor/networkx/convert_matrix.py +1314 -0
- package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +7 -0
- package/runtime/python/okstra_vendor/networkx/drawing/layout.py +2036 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +470 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +570 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +361 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +2978 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_complex.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_empty_graph.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_house_with_colors.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_labels_and_colors.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_shortest_path.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_house_with_colors.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_agraph.py +237 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_image_comparison_pylab_mpl.py +229 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_latex.py +285 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_layout.py +631 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pydot.py +146 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pylab.py +1582 -0
- package/runtime/python/okstra_vendor/networkx/exception.py +131 -0
- package/runtime/python/okstra_vendor/networkx/generators/__init__.py +34 -0
- package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
- package/runtime/python/okstra_vendor/networkx/generators/atlas.py +227 -0
- package/runtime/python/okstra_vendor/networkx/generators/classic.py +1091 -0
- package/runtime/python/okstra_vendor/networkx/generators/cographs.py +68 -0
- package/runtime/python/okstra_vendor/networkx/generators/community.py +1070 -0
- package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +886 -0
- package/runtime/python/okstra_vendor/networkx/generators/directed.py +572 -0
- package/runtime/python/okstra_vendor/networkx/generators/duplication.py +174 -0
- package/runtime/python/okstra_vendor/networkx/generators/ego.py +66 -0
- package/runtime/python/okstra_vendor/networkx/generators/expanders.py +499 -0
- package/runtime/python/okstra_vendor/networkx/generators/geometric.py +1037 -0
- package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +163 -0
- package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +443 -0
- package/runtime/python/okstra_vendor/networkx/generators/intersection.py +125 -0
- package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +70 -0
- package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +664 -0
- package/runtime/python/okstra_vendor/networkx/generators/lattice.py +405 -0
- package/runtime/python/okstra_vendor/networkx/generators/line.py +501 -0
- package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +110 -0
- package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +259 -0
- package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +117 -0
- package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +1416 -0
- package/runtime/python/okstra_vendor/networkx/generators/small.py +1070 -0
- package/runtime/python/okstra_vendor/networkx/generators/social.py +554 -0
- package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +120 -0
- package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +54 -0
- package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +131 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_atlas.py +75 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_classic.py +642 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_cographs.py +20 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_community.py +362 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_degree_seq.py +224 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_directed.py +189 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_duplication.py +103 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_ego.py +39 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_expanders.py +182 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_geometric.py +488 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_harary_graph.py +133 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_internet_as_graphs.py +221 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_intersection.py +28 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_interval_graph.py +144 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_joint_degree_seq.py +125 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_lattice.py +264 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_line.py +316 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_mycielski.py +30 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_nonisomorphic_trees.py +82 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_clustered.py +33 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_graphs.py +495 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_small.py +220 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_spectral_graph_forge.py +49 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_stochastic.py +72 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_sudoku.py +92 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_time_series.py +64 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_trees.py +195 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_triads.py +15 -0
- package/runtime/python/okstra_vendor/networkx/generators/time_series.py +74 -0
- package/runtime/python/okstra_vendor/networkx/generators/trees.py +1070 -0
- package/runtime/python/okstra_vendor/networkx/generators/triads.py +94 -0
- package/runtime/python/okstra_vendor/networkx/lazy_imports.py +188 -0
- package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +13 -0
- package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +650 -0
- package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +466 -0
- package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +77 -0
- package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +168 -0
- package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +512 -0
- package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +166 -0
- package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +186 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_algebraic_connectivity.py +400 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_attrmatrix.py +108 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_bethehessian.py +40 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_graphmatrix.py +275 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_laplacian.py +334 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_modularity.py +86 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_spectrum.py +70 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +17 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +330 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +489 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +1084 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +879 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +427 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +1053 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +19 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +156 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +190 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +261 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_adjacency.py +78 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_cytoscape.py +78 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_node_link.py +109 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_tree.py +48 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +137 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +108 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +393 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +113 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +286 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +379 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_adjlist.py +354 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_edgelist.py +318 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gexf.py +612 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gml.py +744 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graph6.py +181 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graphml.py +1531 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_leda.py +30 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_p2g.py +63 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_pajek.py +128 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_sparse6.py +166 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_text.py +1742 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/text.py +851 -0
- package/runtime/python/okstra_vendor/networkx/relabel.py +285 -0
- package/runtime/python/okstra_vendor/networkx/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_all_random_functions.py +248 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert.py +321 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_numpy.py +531 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_pandas.py +349 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_scipy.py +281 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_exceptions.py +40 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_import.py +11 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_lazy_imports.py +96 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_relabel.py +349 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_removed_functions_exception_messages.py +8 -0
- package/runtime/python/okstra_vendor/networkx/utils/__init__.py +8 -0
- package/runtime/python/okstra_vendor/networkx/utils/backends.py +2171 -0
- package/runtime/python/okstra_vendor/networkx/utils/configs.py +396 -0
- package/runtime/python/okstra_vendor/networkx/utils/decorators.py +1233 -0
- package/runtime/python/okstra_vendor/networkx/utils/heaps.py +338 -0
- package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +297 -0
- package/runtime/python/okstra_vendor/networkx/utils/misc.py +703 -0
- package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +198 -0
- package/runtime/python/okstra_vendor/networkx/utils/rcm.py +159 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test__init.py +11 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_backends.py +225 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_config.py +263 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_decorators.py +510 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_heaps.py +131 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_mapped_queue.py +268 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_misc.py +393 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_random_sequence.py +53 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_rcm.py +63 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_unionfind.py +55 -0
- package/runtime/python/okstra_vendor/networkx/utils/union_find.py +106 -0
- package/runtime/skills/okstra-graphify/SKILL.md +161 -0
- package/runtime/skills/okstra-inspect/SKILL.md +17 -9
- package/runtime/templates/reports/settings.template.json +4 -0
- package/runtime/validators/forbidden_actions.py +8 -2
- package/runtime/validators/validate_session_conformance.py +26 -5
- package/src/cli-registry.mjs +7 -0
- package/src/commands/graphify.mjs +32 -0
- package/src/commands/lifecycle/doctor.mjs +9 -0
- package/src/lib/skill-catalog.mjs +1 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"""Load centrality."""
|
|
2
|
+
|
|
3
|
+
from operator import itemgetter
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
|
|
7
|
+
__all__ = ["load_centrality", "edge_load_centrality"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@nx._dispatchable(edge_attrs="weight")
|
|
11
|
+
def newman_betweenness_centrality(G, v=None, cutoff=None, normalized=True, weight=None):
|
|
12
|
+
"""Compute load centrality for nodes.
|
|
13
|
+
|
|
14
|
+
The load centrality of a node is the fraction of all shortest
|
|
15
|
+
paths that pass through that node.
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
G : graph
|
|
20
|
+
A networkx graph.
|
|
21
|
+
|
|
22
|
+
normalized : bool, optional (default=True)
|
|
23
|
+
If True the betweenness values are normalized by b=b/(n-1)(n-2) where
|
|
24
|
+
n is the number of nodes in G.
|
|
25
|
+
|
|
26
|
+
weight : None or string, optional (default=None)
|
|
27
|
+
If None, edge weights are ignored.
|
|
28
|
+
Otherwise holds the name of the edge attribute used as weight.
|
|
29
|
+
The weight of an edge is treated as the length or distance between the two sides.
|
|
30
|
+
|
|
31
|
+
cutoff : bool, optional (default=None)
|
|
32
|
+
If specified, only consider paths of length <= cutoff.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
nodes : dictionary
|
|
37
|
+
Dictionary of nodes with centrality as the value.
|
|
38
|
+
|
|
39
|
+
See Also
|
|
40
|
+
--------
|
|
41
|
+
betweenness_centrality
|
|
42
|
+
|
|
43
|
+
Notes
|
|
44
|
+
-----
|
|
45
|
+
Load centrality is slightly different than betweenness. It was originally
|
|
46
|
+
introduced by [2]_. For this load algorithm see [1]_.
|
|
47
|
+
|
|
48
|
+
References
|
|
49
|
+
----------
|
|
50
|
+
.. [1] Mark E. J. Newman:
|
|
51
|
+
Scientific collaboration networks. II.
|
|
52
|
+
Shortest paths, weighted networks, and centrality.
|
|
53
|
+
Physical Review E 64, 016132, 2001.
|
|
54
|
+
http://journals.aps.org/pre/abstract/10.1103/PhysRevE.64.016132
|
|
55
|
+
.. [2] Kwang-Il Goh, Byungnam Kahng and Doochul Kim
|
|
56
|
+
Universal behavior of Load Distribution in Scale-Free Networks.
|
|
57
|
+
Physical Review Letters 87(27):1–4, 2001.
|
|
58
|
+
https://doi.org/10.1103/PhysRevLett.87.278701
|
|
59
|
+
"""
|
|
60
|
+
if v is not None: # only one node
|
|
61
|
+
betweenness = 0.0
|
|
62
|
+
for source in G:
|
|
63
|
+
ubetween = _node_betweenness(G, source, cutoff, False, weight)
|
|
64
|
+
betweenness += ubetween[v] if v in ubetween else 0
|
|
65
|
+
if normalized:
|
|
66
|
+
order = G.order()
|
|
67
|
+
if order <= 2:
|
|
68
|
+
return betweenness # no normalization b=0 for all nodes
|
|
69
|
+
betweenness *= 1.0 / ((order - 1) * (order - 2))
|
|
70
|
+
else:
|
|
71
|
+
betweenness = {}.fromkeys(G, 0.0)
|
|
72
|
+
for source in betweenness:
|
|
73
|
+
ubetween = _node_betweenness(G, source, cutoff, False, weight)
|
|
74
|
+
for vk in ubetween:
|
|
75
|
+
betweenness[vk] += ubetween[vk]
|
|
76
|
+
if normalized:
|
|
77
|
+
order = G.order()
|
|
78
|
+
if order <= 2:
|
|
79
|
+
return betweenness # no normalization b=0 for all nodes
|
|
80
|
+
scale = 1.0 / ((order - 1) * (order - 2))
|
|
81
|
+
for v in betweenness:
|
|
82
|
+
betweenness[v] *= scale
|
|
83
|
+
return betweenness # all nodes
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _node_betweenness(G, source, cutoff=False, normalized=True, weight=None):
|
|
87
|
+
"""Node betweenness_centrality helper:
|
|
88
|
+
|
|
89
|
+
See betweenness_centrality for what you probably want.
|
|
90
|
+
This actually computes "load" and not betweenness.
|
|
91
|
+
See https://networkx.lanl.gov/ticket/103
|
|
92
|
+
|
|
93
|
+
This calculates the load of each node for paths from a single source.
|
|
94
|
+
(The fraction of number of shortests paths from source that go
|
|
95
|
+
through each node.)
|
|
96
|
+
|
|
97
|
+
To get the load for a node you need to do all-pairs shortest paths.
|
|
98
|
+
|
|
99
|
+
If weight is not None then use Dijkstra for finding shortest paths.
|
|
100
|
+
"""
|
|
101
|
+
# get the predecessor and path length data
|
|
102
|
+
if weight is None:
|
|
103
|
+
(pred, length) = nx.predecessor(G, source, cutoff=cutoff, return_seen=True)
|
|
104
|
+
else:
|
|
105
|
+
(pred, length) = nx.dijkstra_predecessor_and_distance(G, source, cutoff, weight)
|
|
106
|
+
|
|
107
|
+
# order the nodes by path length
|
|
108
|
+
onodes = [(l, vert) for (vert, l) in length.items()]
|
|
109
|
+
onodes.sort()
|
|
110
|
+
onodes[:] = [vert for (l, vert) in onodes if l > 0]
|
|
111
|
+
|
|
112
|
+
# initialize betweenness
|
|
113
|
+
between = {}.fromkeys(length, 1.0)
|
|
114
|
+
|
|
115
|
+
while onodes:
|
|
116
|
+
v = onodes.pop()
|
|
117
|
+
if v in pred:
|
|
118
|
+
num_paths = len(pred[v]) # Discount betweenness if more than
|
|
119
|
+
for x in pred[v]: # one shortest path.
|
|
120
|
+
if x == source: # stop if hit source because all remaining v
|
|
121
|
+
break # also have pred[v]==[source]
|
|
122
|
+
between[x] += between[v] / num_paths
|
|
123
|
+
# remove source
|
|
124
|
+
for v in between:
|
|
125
|
+
between[v] -= 1
|
|
126
|
+
# rescale to be between 0 and 1
|
|
127
|
+
if normalized:
|
|
128
|
+
l = len(between)
|
|
129
|
+
if l > 2:
|
|
130
|
+
# scale by 1/the number of possible paths
|
|
131
|
+
scale = 1 / ((l - 1) * (l - 2))
|
|
132
|
+
for v in between:
|
|
133
|
+
between[v] *= scale
|
|
134
|
+
return between
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
load_centrality = newman_betweenness_centrality
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@nx._dispatchable
|
|
141
|
+
def edge_load_centrality(G, cutoff=False):
|
|
142
|
+
"""Compute edge load.
|
|
143
|
+
|
|
144
|
+
WARNING: This concept of edge load has not been analysed
|
|
145
|
+
or discussed outside of NetworkX that we know of.
|
|
146
|
+
It is based loosely on load_centrality in the sense that
|
|
147
|
+
it counts the number of shortest paths which cross each edge.
|
|
148
|
+
This function is for demonstration and testing purposes.
|
|
149
|
+
|
|
150
|
+
Parameters
|
|
151
|
+
----------
|
|
152
|
+
G : graph
|
|
153
|
+
A networkx graph
|
|
154
|
+
|
|
155
|
+
cutoff : bool, optional (default=False)
|
|
156
|
+
If specified, only consider paths of length <= cutoff.
|
|
157
|
+
|
|
158
|
+
Returns
|
|
159
|
+
-------
|
|
160
|
+
A dict keyed by edge 2-tuple to the number of shortest paths
|
|
161
|
+
which use that edge. Where more than one path is shortest
|
|
162
|
+
the count is divided equally among paths.
|
|
163
|
+
"""
|
|
164
|
+
betweenness = {}
|
|
165
|
+
for u, v in G.edges():
|
|
166
|
+
betweenness[(u, v)] = 0.0
|
|
167
|
+
betweenness[(v, u)] = 0.0
|
|
168
|
+
|
|
169
|
+
for source in G:
|
|
170
|
+
ubetween = _edge_betweenness(G, source, cutoff=cutoff)
|
|
171
|
+
for e, ubetweenv in ubetween.items():
|
|
172
|
+
betweenness[e] += ubetweenv # cumulative total
|
|
173
|
+
return betweenness
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _edge_betweenness(G, source, nodes=None, cutoff=False):
|
|
177
|
+
"""Edge betweenness helper."""
|
|
178
|
+
# get the predecessor data
|
|
179
|
+
(pred, length) = nx.predecessor(G, source, cutoff=cutoff, return_seen=True)
|
|
180
|
+
# order the nodes by path length
|
|
181
|
+
onodes = [n for n, d in sorted(length.items(), key=itemgetter(1))]
|
|
182
|
+
# initialize betweenness, doesn't account for any edge weights
|
|
183
|
+
between = {}
|
|
184
|
+
for u, v in G.edges(nodes):
|
|
185
|
+
between[(u, v)] = 1.0
|
|
186
|
+
between[(v, u)] = 1.0
|
|
187
|
+
|
|
188
|
+
while onodes: # work through all paths
|
|
189
|
+
v = onodes.pop()
|
|
190
|
+
if v in pred:
|
|
191
|
+
# Discount betweenness if more than one shortest path.
|
|
192
|
+
num_paths = len(pred[v])
|
|
193
|
+
for w in pred[v]:
|
|
194
|
+
if w in pred:
|
|
195
|
+
# Discount betweenness, mult path
|
|
196
|
+
num_paths = len(pred[w])
|
|
197
|
+
for x in pred[w]:
|
|
198
|
+
between[(w, x)] += between[(v, w)] / num_paths
|
|
199
|
+
between[(x, w)] += between[(w, v)] / num_paths
|
|
200
|
+
return between
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Percolation centrality measures."""
|
|
2
|
+
|
|
3
|
+
import networkx as nx
|
|
4
|
+
from networkx.algorithms.centrality.betweenness import (
|
|
5
|
+
_single_source_dijkstra_path_basic as dijkstra,
|
|
6
|
+
)
|
|
7
|
+
from networkx.algorithms.centrality.betweenness import (
|
|
8
|
+
_single_source_shortest_path_basic as shortest_path,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = ["percolation_centrality"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@nx._dispatchable(node_attrs="attribute", edge_attrs="weight")
|
|
15
|
+
def percolation_centrality(G, attribute="percolation", states=None, weight=None):
|
|
16
|
+
r"""Compute the percolation centrality for nodes.
|
|
17
|
+
|
|
18
|
+
Percolation centrality of a node $v$, at a given time, is defined
|
|
19
|
+
as the proportion of ‘percolated paths’ that go through that node.
|
|
20
|
+
|
|
21
|
+
This measure quantifies relative impact of nodes based on their
|
|
22
|
+
topological connectivity, as well as their percolation states.
|
|
23
|
+
|
|
24
|
+
Percolation states of nodes are used to depict network percolation
|
|
25
|
+
scenarios (such as during infection transmission in a social network
|
|
26
|
+
of individuals, spreading of computer viruses on computer networks, or
|
|
27
|
+
transmission of disease over a network of towns) over time. In this
|
|
28
|
+
measure usually the percolation state is expressed as a decimal
|
|
29
|
+
between 0.0 and 1.0.
|
|
30
|
+
|
|
31
|
+
When all nodes are in the same percolated state this measure is
|
|
32
|
+
equivalent to betweenness centrality.
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
G : graph
|
|
37
|
+
A NetworkX graph.
|
|
38
|
+
|
|
39
|
+
attribute : None or string, optional (default='percolation')
|
|
40
|
+
Name of the node attribute to use for percolation state, used
|
|
41
|
+
if `states` is None. If a node does not set the attribute the
|
|
42
|
+
state of that node will be set to the default value of 1.
|
|
43
|
+
If all nodes do not have the attribute all nodes will be set to
|
|
44
|
+
1 and the centrality measure will be equivalent to betweenness centrality.
|
|
45
|
+
|
|
46
|
+
states : None or dict, optional (default=None)
|
|
47
|
+
Specify percolation states for the nodes, nodes as keys states
|
|
48
|
+
as values.
|
|
49
|
+
|
|
50
|
+
weight : None or string, optional (default=None)
|
|
51
|
+
If None, all edge weights are considered equal.
|
|
52
|
+
Otherwise holds the name of the edge attribute used as weight.
|
|
53
|
+
The weight of an edge is treated as the length or distance between the two sides.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
nodes : dictionary
|
|
59
|
+
Dictionary of nodes with percolation centrality as the value.
|
|
60
|
+
|
|
61
|
+
See Also
|
|
62
|
+
--------
|
|
63
|
+
betweenness_centrality
|
|
64
|
+
|
|
65
|
+
Notes
|
|
66
|
+
-----
|
|
67
|
+
The algorithm is from Mahendra Piraveenan, Mikhail Prokopenko, and
|
|
68
|
+
Liaquat Hossain [1]_
|
|
69
|
+
Pair dependencies are calculated and accumulated using [2]_
|
|
70
|
+
|
|
71
|
+
For weighted graphs the edge weights must be greater than zero.
|
|
72
|
+
Zero edge weights can produce an infinite number of equal length
|
|
73
|
+
paths between pairs of nodes.
|
|
74
|
+
|
|
75
|
+
References
|
|
76
|
+
----------
|
|
77
|
+
.. [1] Mahendra Piraveenan, Mikhail Prokopenko, Liaquat Hossain
|
|
78
|
+
Percolation Centrality: Quantifying Graph-Theoretic Impact of Nodes
|
|
79
|
+
during Percolation in Networks
|
|
80
|
+
http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0053095
|
|
81
|
+
.. [2] Ulrik Brandes:
|
|
82
|
+
A Faster Algorithm for Betweenness Centrality.
|
|
83
|
+
Journal of Mathematical Sociology 25(2):163-177, 2001.
|
|
84
|
+
https://doi.org/10.1080/0022250X.2001.9990249
|
|
85
|
+
"""
|
|
86
|
+
percolation = dict.fromkeys(G, 0.0) # b[v]=0 for v in G
|
|
87
|
+
|
|
88
|
+
nodes = G
|
|
89
|
+
|
|
90
|
+
if states is None:
|
|
91
|
+
states = nx.get_node_attributes(nodes, attribute, default=1)
|
|
92
|
+
|
|
93
|
+
# sum of all percolation states
|
|
94
|
+
p_sigma_x_t = 0.0
|
|
95
|
+
for v in states.values():
|
|
96
|
+
p_sigma_x_t += v
|
|
97
|
+
|
|
98
|
+
for s in nodes:
|
|
99
|
+
# single source shortest paths
|
|
100
|
+
if weight is None: # use BFS
|
|
101
|
+
S, P, sigma, _ = shortest_path(G, s)
|
|
102
|
+
else: # use Dijkstra's algorithm
|
|
103
|
+
S, P, sigma, _ = dijkstra(G, s, weight)
|
|
104
|
+
# accumulation
|
|
105
|
+
percolation = _accumulate_percolation(
|
|
106
|
+
percolation, S, P, sigma, s, states, p_sigma_x_t
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
n = len(G)
|
|
110
|
+
|
|
111
|
+
for v in percolation:
|
|
112
|
+
percolation[v] *= 1 / (n - 2)
|
|
113
|
+
|
|
114
|
+
return percolation
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _accumulate_percolation(percolation, S, P, sigma, s, states, p_sigma_x_t):
|
|
118
|
+
delta = dict.fromkeys(S, 0)
|
|
119
|
+
while S:
|
|
120
|
+
w = S.pop()
|
|
121
|
+
coeff = (1 + delta[w]) / sigma[w]
|
|
122
|
+
for v in P[w]:
|
|
123
|
+
delta[v] += sigma[v] * coeff
|
|
124
|
+
if w != s:
|
|
125
|
+
# percolation weight
|
|
126
|
+
pw_s_w = states[s] / (p_sigma_x_t - states[w])
|
|
127
|
+
percolation[w] += delta[w] * pw_s_w
|
|
128
|
+
return percolation
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"""Functions for computing reaching centrality of a node or a graph."""
|
|
2
|
+
|
|
3
|
+
import networkx as nx
|
|
4
|
+
from networkx.utils import pairwise
|
|
5
|
+
|
|
6
|
+
__all__ = ["global_reaching_centrality", "local_reaching_centrality"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _average_weight(G, path, weight=None):
|
|
10
|
+
"""Returns the average weight of an edge in a weighted path.
|
|
11
|
+
|
|
12
|
+
Parameters
|
|
13
|
+
----------
|
|
14
|
+
G : graph
|
|
15
|
+
A networkx graph.
|
|
16
|
+
|
|
17
|
+
path: list
|
|
18
|
+
A list of vertices that define the path.
|
|
19
|
+
|
|
20
|
+
weight : None or string, optional (default=None)
|
|
21
|
+
If None, edge weights are ignored. Then the average weight of an edge
|
|
22
|
+
is assumed to be the multiplicative inverse of the length of the path.
|
|
23
|
+
Otherwise holds the name of the edge attribute used as weight.
|
|
24
|
+
"""
|
|
25
|
+
path_length = len(path) - 1
|
|
26
|
+
if path_length <= 0:
|
|
27
|
+
return 0
|
|
28
|
+
if weight is None:
|
|
29
|
+
return 1 / path_length
|
|
30
|
+
total_weight = sum(G.edges[i, j][weight] for i, j in pairwise(path))
|
|
31
|
+
return total_weight / path_length
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@nx._dispatchable(edge_attrs="weight")
|
|
35
|
+
def global_reaching_centrality(G, weight=None, normalized=True):
|
|
36
|
+
"""Returns the global reaching centrality of a directed graph.
|
|
37
|
+
|
|
38
|
+
The *global reaching centrality* of a weighted directed graph is the
|
|
39
|
+
average over all nodes of the difference between the local reaching
|
|
40
|
+
centrality of the node and the greatest local reaching centrality of
|
|
41
|
+
any node in the graph [1]_. For more information on the local
|
|
42
|
+
reaching centrality, see :func:`local_reaching_centrality`.
|
|
43
|
+
Informally, the local reaching centrality is the proportion of the
|
|
44
|
+
graph that is reachable from the neighbors of the node.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
G : DiGraph
|
|
49
|
+
A networkx DiGraph.
|
|
50
|
+
|
|
51
|
+
weight : None or string, optional (default=None)
|
|
52
|
+
Attribute to use for edge weights. If ``None``, each edge weight
|
|
53
|
+
is assumed to be one. A higher weight implies a stronger
|
|
54
|
+
connection between nodes and a *shorter* path length.
|
|
55
|
+
|
|
56
|
+
normalized : bool, optional (default=True)
|
|
57
|
+
Whether to normalize the edge weights by the total sum of edge
|
|
58
|
+
weights.
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
h : float
|
|
63
|
+
The global reaching centrality of the graph.
|
|
64
|
+
|
|
65
|
+
Examples
|
|
66
|
+
--------
|
|
67
|
+
>>> G = nx.DiGraph()
|
|
68
|
+
>>> G.add_edge(1, 2)
|
|
69
|
+
>>> G.add_edge(1, 3)
|
|
70
|
+
>>> nx.global_reaching_centrality(G)
|
|
71
|
+
1.0
|
|
72
|
+
>>> G.add_edge(3, 2)
|
|
73
|
+
>>> nx.global_reaching_centrality(G)
|
|
74
|
+
0.75
|
|
75
|
+
|
|
76
|
+
See also
|
|
77
|
+
--------
|
|
78
|
+
local_reaching_centrality
|
|
79
|
+
|
|
80
|
+
References
|
|
81
|
+
----------
|
|
82
|
+
.. [1] Mones, Enys, Lilla Vicsek, and Tamás Vicsek.
|
|
83
|
+
"Hierarchy Measure for Complex Networks."
|
|
84
|
+
*PLoS ONE* 7.3 (2012): e33799.
|
|
85
|
+
https://doi.org/10.1371/journal.pone.0033799
|
|
86
|
+
"""
|
|
87
|
+
if nx.is_negatively_weighted(G, weight=weight):
|
|
88
|
+
raise nx.NetworkXError("edge weights must be positive")
|
|
89
|
+
total_weight = G.size(weight=weight)
|
|
90
|
+
if total_weight <= 0:
|
|
91
|
+
raise nx.NetworkXError("Size of G must be positive")
|
|
92
|
+
# If provided, weights must be interpreted as connection strength
|
|
93
|
+
# (so higher weights are more likely to be chosen). However, the
|
|
94
|
+
# shortest path algorithms in NetworkX assume the provided "weight"
|
|
95
|
+
# is actually a distance (so edges with higher weight are less
|
|
96
|
+
# likely to be chosen). Therefore we need to invert the weights when
|
|
97
|
+
# computing shortest paths.
|
|
98
|
+
#
|
|
99
|
+
# If weight is None, we leave it as-is so that the shortest path
|
|
100
|
+
# algorithm can use a faster, unweighted algorithm.
|
|
101
|
+
if weight is not None:
|
|
102
|
+
|
|
103
|
+
def as_distance(u, v, d):
|
|
104
|
+
return total_weight / d.get(weight, 1)
|
|
105
|
+
|
|
106
|
+
shortest_paths = dict(nx.shortest_path(G, weight=as_distance))
|
|
107
|
+
else:
|
|
108
|
+
shortest_paths = dict(nx.shortest_path(G))
|
|
109
|
+
|
|
110
|
+
centrality = local_reaching_centrality
|
|
111
|
+
# TODO This can be trivially parallelized.
|
|
112
|
+
lrc = [
|
|
113
|
+
centrality(G, node, paths=paths, weight=weight, normalized=normalized)
|
|
114
|
+
for node, paths in shortest_paths.items()
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
max_lrc = max(lrc)
|
|
118
|
+
return sum(max_lrc - c for c in lrc) / (len(G) - 1)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@nx._dispatchable(edge_attrs="weight")
|
|
122
|
+
def local_reaching_centrality(G, v, paths=None, weight=None, normalized=True):
|
|
123
|
+
"""Returns the local reaching centrality of a node in a directed
|
|
124
|
+
graph.
|
|
125
|
+
|
|
126
|
+
The *local reaching centrality* of a node in a directed graph is the
|
|
127
|
+
proportion of other nodes reachable from that node [1]_.
|
|
128
|
+
|
|
129
|
+
Parameters
|
|
130
|
+
----------
|
|
131
|
+
G : DiGraph
|
|
132
|
+
A NetworkX DiGraph.
|
|
133
|
+
|
|
134
|
+
v : node
|
|
135
|
+
A node in the directed graph `G`.
|
|
136
|
+
|
|
137
|
+
paths : dictionary (default=None)
|
|
138
|
+
If this is not `None` it must be a dictionary representation
|
|
139
|
+
of single-source shortest paths, as computed by, for example,
|
|
140
|
+
:func:`networkx.shortest_path` with source node `v`. Use this
|
|
141
|
+
keyword argument if you intend to invoke this function many
|
|
142
|
+
times but don't want the paths to be recomputed each time.
|
|
143
|
+
|
|
144
|
+
weight : None or string, optional (default=None)
|
|
145
|
+
Attribute to use for edge weights. If `None`, each edge weight
|
|
146
|
+
is assumed to be one. A higher weight implies a stronger
|
|
147
|
+
connection between nodes and a *shorter* path length.
|
|
148
|
+
|
|
149
|
+
normalized : bool, optional (default=True)
|
|
150
|
+
Whether to normalize the edge weights by the total sum of edge
|
|
151
|
+
weights.
|
|
152
|
+
|
|
153
|
+
Returns
|
|
154
|
+
-------
|
|
155
|
+
h : float
|
|
156
|
+
The local reaching centrality of the node ``v`` in the graph
|
|
157
|
+
``G``.
|
|
158
|
+
|
|
159
|
+
Examples
|
|
160
|
+
--------
|
|
161
|
+
>>> G = nx.DiGraph()
|
|
162
|
+
>>> G.add_edges_from([(1, 2), (1, 3)])
|
|
163
|
+
>>> nx.local_reaching_centrality(G, 3)
|
|
164
|
+
0.0
|
|
165
|
+
>>> G.add_edge(3, 2)
|
|
166
|
+
>>> nx.local_reaching_centrality(G, 3)
|
|
167
|
+
0.5
|
|
168
|
+
|
|
169
|
+
See also
|
|
170
|
+
--------
|
|
171
|
+
global_reaching_centrality
|
|
172
|
+
|
|
173
|
+
References
|
|
174
|
+
----------
|
|
175
|
+
.. [1] Mones, Enys, Lilla Vicsek, and Tamás Vicsek.
|
|
176
|
+
"Hierarchy Measure for Complex Networks."
|
|
177
|
+
*PLoS ONE* 7.3 (2012): e33799.
|
|
178
|
+
https://doi.org/10.1371/journal.pone.0033799
|
|
179
|
+
"""
|
|
180
|
+
# Corner case: graph with single node containing a self-loop
|
|
181
|
+
if (total_weight := G.size(weight=weight)) > 0 and len(G) == 1:
|
|
182
|
+
raise nx.NetworkXError(
|
|
183
|
+
"local_reaching_centrality of a single node with self-loop not well-defined"
|
|
184
|
+
)
|
|
185
|
+
if paths is None:
|
|
186
|
+
if nx.is_negatively_weighted(G, weight=weight):
|
|
187
|
+
raise nx.NetworkXError("edge weights must be positive")
|
|
188
|
+
if total_weight <= 0:
|
|
189
|
+
raise nx.NetworkXError("Size of G must be positive")
|
|
190
|
+
if weight is not None:
|
|
191
|
+
# Interpret weights as lengths.
|
|
192
|
+
def as_distance(u, v, d):
|
|
193
|
+
return total_weight / d.get(weight, 1)
|
|
194
|
+
|
|
195
|
+
paths = nx.shortest_path(G, source=v, weight=as_distance)
|
|
196
|
+
else:
|
|
197
|
+
paths = nx.shortest_path(G, source=v)
|
|
198
|
+
# If the graph is unweighted, simply return the proportion of nodes
|
|
199
|
+
# reachable from the source node ``v``.
|
|
200
|
+
if weight is None and G.is_directed():
|
|
201
|
+
return (len(paths) - 1) / (len(G) - 1)
|
|
202
|
+
if normalized and weight is not None:
|
|
203
|
+
norm = G.size(weight=weight) / G.size()
|
|
204
|
+
else:
|
|
205
|
+
norm = 1
|
|
206
|
+
# TODO This can be trivially parallelized.
|
|
207
|
+
avgw = (_average_weight(G, path, weight=weight) for path in paths.values())
|
|
208
|
+
sum_avg_weight = sum(avgw) / norm
|
|
209
|
+
return sum_avg_weight / (len(G) - 1)
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""Copyright (c) 2015 – Thomson Licensing, SAS
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted (subject to the limitations in the
|
|
5
|
+
disclaimer below) provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
documentation and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
* Neither the name of Thomson Licensing, or Technicolor, nor the names
|
|
15
|
+
of its contributors may be used to endorse or promote products derived
|
|
16
|
+
from this software without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
|
|
19
|
+
GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
|
|
20
|
+
HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
21
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
22
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
24
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
25
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
26
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
27
|
+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
28
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
29
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
30
|
+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
import networkx as nx
|
|
34
|
+
from networkx.utils import not_implemented_for
|
|
35
|
+
|
|
36
|
+
# Authors: Erwan Le Merrer (erwan.lemerrer@technicolor.com)
|
|
37
|
+
|
|
38
|
+
__all__ = ["second_order_centrality"]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@not_implemented_for("directed")
|
|
42
|
+
@nx._dispatchable(edge_attrs="weight")
|
|
43
|
+
def second_order_centrality(G, weight="weight"):
|
|
44
|
+
"""Compute the second order centrality for nodes of G.
|
|
45
|
+
|
|
46
|
+
The second order centrality of a given node is the standard deviation of
|
|
47
|
+
the return times to that node of a perpetual random walk on G:
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
G : graph
|
|
52
|
+
A NetworkX connected and undirected graph.
|
|
53
|
+
|
|
54
|
+
weight : string or None, optional (default="weight")
|
|
55
|
+
The name of an edge attribute that holds the numerical value
|
|
56
|
+
used as a weight. If None then each edge has weight 1.
|
|
57
|
+
|
|
58
|
+
Returns
|
|
59
|
+
-------
|
|
60
|
+
nodes : dictionary
|
|
61
|
+
Dictionary keyed by node with second order centrality as the value.
|
|
62
|
+
|
|
63
|
+
Examples
|
|
64
|
+
--------
|
|
65
|
+
>>> G = nx.star_graph(10)
|
|
66
|
+
>>> soc = nx.second_order_centrality(G)
|
|
67
|
+
>>> print(sorted(soc.items(), key=lambda x: x[1])[0][0]) # pick first id
|
|
68
|
+
0
|
|
69
|
+
|
|
70
|
+
Raises
|
|
71
|
+
------
|
|
72
|
+
NetworkXException
|
|
73
|
+
If the graph G is empty, non connected or has negative weights.
|
|
74
|
+
|
|
75
|
+
See Also
|
|
76
|
+
--------
|
|
77
|
+
betweenness_centrality
|
|
78
|
+
|
|
79
|
+
Notes
|
|
80
|
+
-----
|
|
81
|
+
Lower values of second order centrality indicate higher centrality.
|
|
82
|
+
|
|
83
|
+
The algorithm is from Kermarrec, Le Merrer, Sericola and Trédan [1]_.
|
|
84
|
+
|
|
85
|
+
This code implements the analytical version of the algorithm, i.e.,
|
|
86
|
+
there is no simulation of a random walk process involved. The random walk
|
|
87
|
+
is here unbiased (corresponding to eq 6 of the paper [1]_), thus the
|
|
88
|
+
centrality values are the standard deviations for random walk return times
|
|
89
|
+
on the transformed input graph G (equal in-degree at each nodes by adding
|
|
90
|
+
self-loops).
|
|
91
|
+
|
|
92
|
+
Complexity of this implementation, made to run locally on a single machine,
|
|
93
|
+
is O(n^3), with n the size of G, which makes it viable only for small
|
|
94
|
+
graphs.
|
|
95
|
+
|
|
96
|
+
References
|
|
97
|
+
----------
|
|
98
|
+
.. [1] Anne-Marie Kermarrec, Erwan Le Merrer, Bruno Sericola, Gilles Trédan
|
|
99
|
+
"Second order centrality: Distributed assessment of nodes criticity in
|
|
100
|
+
complex networks", Elsevier Computer Communications 34(5):619-628, 2011.
|
|
101
|
+
"""
|
|
102
|
+
import numpy as np
|
|
103
|
+
|
|
104
|
+
n = len(G)
|
|
105
|
+
|
|
106
|
+
if n == 0:
|
|
107
|
+
raise nx.NetworkXException("Empty graph.")
|
|
108
|
+
if not nx.is_connected(G):
|
|
109
|
+
raise nx.NetworkXException("Non connected graph.")
|
|
110
|
+
if any(d.get(weight, 0) < 0 for u, v, d in G.edges(data=True)):
|
|
111
|
+
raise nx.NetworkXException("Graph has negative edge weights.")
|
|
112
|
+
|
|
113
|
+
# balancing G for Metropolis-Hastings random walks
|
|
114
|
+
G = nx.DiGraph(G)
|
|
115
|
+
in_deg = dict(G.in_degree(weight=weight))
|
|
116
|
+
d_max = max(in_deg.values())
|
|
117
|
+
for i, deg in in_deg.items():
|
|
118
|
+
if deg < d_max:
|
|
119
|
+
G.add_edge(i, i, weight=d_max - deg)
|
|
120
|
+
|
|
121
|
+
P = nx.to_numpy_array(G)
|
|
122
|
+
P /= P.sum(axis=1)[:, np.newaxis] # to transition probability matrix
|
|
123
|
+
|
|
124
|
+
def _Qj(P, j):
|
|
125
|
+
P = P.copy()
|
|
126
|
+
P[:, j] = 0
|
|
127
|
+
return P
|
|
128
|
+
|
|
129
|
+
M = np.empty([n, n])
|
|
130
|
+
|
|
131
|
+
for i in range(n):
|
|
132
|
+
M[:, i] = np.linalg.solve(
|
|
133
|
+
np.identity(n) - _Qj(P, i), np.ones([n, 1])[:, 0]
|
|
134
|
+
) # eq 3
|
|
135
|
+
|
|
136
|
+
return dict(
|
|
137
|
+
zip(
|
|
138
|
+
G.nodes,
|
|
139
|
+
(float(np.sqrt(2 * np.sum(M[:, i]) - n * (n + 1))) for i in range(n)),
|
|
140
|
+
)
|
|
141
|
+
) # eq 6
|