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,526 @@
|
|
|
1
|
+
"""One-mode (unipartite) projections of bipartite graphs."""
|
|
2
|
+
|
|
3
|
+
import networkx as nx
|
|
4
|
+
from networkx.exception import NetworkXAlgorithmError
|
|
5
|
+
from networkx.utils import not_implemented_for
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"projected_graph",
|
|
9
|
+
"weighted_projected_graph",
|
|
10
|
+
"collaboration_weighted_projected_graph",
|
|
11
|
+
"overlap_weighted_projected_graph",
|
|
12
|
+
"generic_weighted_projected_graph",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@nx._dispatchable(
|
|
17
|
+
graphs="B", preserve_node_attrs=True, preserve_graph_attrs=True, returns_graph=True
|
|
18
|
+
)
|
|
19
|
+
def projected_graph(B, nodes, multigraph=False):
|
|
20
|
+
r"""Returns the projection of B onto one of its node sets.
|
|
21
|
+
|
|
22
|
+
Returns the graph G that is the projection of the bipartite graph B
|
|
23
|
+
onto the specified nodes. They retain their attributes and are connected
|
|
24
|
+
in G if they have a common neighbor in B.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
B : NetworkX graph
|
|
29
|
+
The input graph should be bipartite.
|
|
30
|
+
|
|
31
|
+
nodes : list or iterable
|
|
32
|
+
Nodes to project onto (the "bottom" nodes).
|
|
33
|
+
|
|
34
|
+
multigraph: bool (default=False)
|
|
35
|
+
If True return a multigraph where the multiple edges represent multiple
|
|
36
|
+
shared neighbors. They edge key in the multigraph is assigned to the
|
|
37
|
+
label of the neighbor.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
Graph : NetworkX graph or multigraph
|
|
42
|
+
A graph that is the projection onto the given nodes.
|
|
43
|
+
|
|
44
|
+
Examples
|
|
45
|
+
--------
|
|
46
|
+
>>> from networkx.algorithms import bipartite
|
|
47
|
+
>>> B = nx.path_graph(4)
|
|
48
|
+
>>> G = bipartite.projected_graph(B, [1, 3])
|
|
49
|
+
>>> list(G)
|
|
50
|
+
[1, 3]
|
|
51
|
+
>>> list(G.edges())
|
|
52
|
+
[(1, 3)]
|
|
53
|
+
|
|
54
|
+
If nodes `a`, and `b` are connected through both nodes 1 and 2 then
|
|
55
|
+
building a multigraph results in two edges in the projection onto
|
|
56
|
+
[`a`, `b`]:
|
|
57
|
+
|
|
58
|
+
>>> B = nx.Graph()
|
|
59
|
+
>>> B.add_edges_from([("a", 1), ("b", 1), ("a", 2), ("b", 2)])
|
|
60
|
+
>>> G = bipartite.projected_graph(B, ["a", "b"], multigraph=True)
|
|
61
|
+
>>> print([sorted((u, v)) for u, v in G.edges()])
|
|
62
|
+
[['a', 'b'], ['a', 'b']]
|
|
63
|
+
|
|
64
|
+
Notes
|
|
65
|
+
-----
|
|
66
|
+
No attempt is made to verify that the input graph B is bipartite.
|
|
67
|
+
Returns a simple graph that is the projection of the bipartite graph B
|
|
68
|
+
onto the set of nodes given in list nodes. If multigraph=True then
|
|
69
|
+
a multigraph is returned with an edge for every shared neighbor.
|
|
70
|
+
|
|
71
|
+
Directed graphs are allowed as input. The output will also then
|
|
72
|
+
be a directed graph with edges if there is a directed path between
|
|
73
|
+
the nodes.
|
|
74
|
+
|
|
75
|
+
The graph and node properties are (shallow) copied to the projected graph.
|
|
76
|
+
|
|
77
|
+
See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
|
|
78
|
+
for further details on how bipartite graphs are handled in NetworkX.
|
|
79
|
+
|
|
80
|
+
See Also
|
|
81
|
+
--------
|
|
82
|
+
is_bipartite,
|
|
83
|
+
is_bipartite_node_set,
|
|
84
|
+
sets,
|
|
85
|
+
weighted_projected_graph,
|
|
86
|
+
collaboration_weighted_projected_graph,
|
|
87
|
+
overlap_weighted_projected_graph,
|
|
88
|
+
generic_weighted_projected_graph
|
|
89
|
+
"""
|
|
90
|
+
if B.is_multigraph():
|
|
91
|
+
raise nx.NetworkXError("not defined for multigraphs")
|
|
92
|
+
if B.is_directed():
|
|
93
|
+
directed = True
|
|
94
|
+
if multigraph:
|
|
95
|
+
G = nx.MultiDiGraph()
|
|
96
|
+
else:
|
|
97
|
+
G = nx.DiGraph()
|
|
98
|
+
else:
|
|
99
|
+
directed = False
|
|
100
|
+
if multigraph:
|
|
101
|
+
G = nx.MultiGraph()
|
|
102
|
+
else:
|
|
103
|
+
G = nx.Graph()
|
|
104
|
+
G.graph.update(B.graph)
|
|
105
|
+
G.add_nodes_from((n, B.nodes[n]) for n in nodes)
|
|
106
|
+
for u in nodes:
|
|
107
|
+
nbrs2 = {v for nbr in B[u] for v in B[nbr] if v != u}
|
|
108
|
+
if multigraph:
|
|
109
|
+
for n in nbrs2:
|
|
110
|
+
if directed:
|
|
111
|
+
links = set(B[u]) & set(B.pred[n])
|
|
112
|
+
else:
|
|
113
|
+
links = set(B[u]) & set(B[n])
|
|
114
|
+
for l in links:
|
|
115
|
+
if not G.has_edge(u, n, l):
|
|
116
|
+
G.add_edge(u, n, key=l)
|
|
117
|
+
else:
|
|
118
|
+
G.add_edges_from((u, n) for n in nbrs2)
|
|
119
|
+
return G
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@not_implemented_for("multigraph")
|
|
123
|
+
@nx._dispatchable(graphs="B", returns_graph=True)
|
|
124
|
+
def weighted_projected_graph(B, nodes, ratio=False):
|
|
125
|
+
r"""Returns a weighted projection of B onto one of its node sets.
|
|
126
|
+
|
|
127
|
+
The weighted projected graph is the projection of the bipartite
|
|
128
|
+
network B onto the specified nodes with weights representing the
|
|
129
|
+
number of shared neighbors or the ratio between actual shared
|
|
130
|
+
neighbors and possible shared neighbors if ``ratio is True`` [1]_.
|
|
131
|
+
The nodes retain their attributes and are connected in the resulting
|
|
132
|
+
graph if they have an edge to a common node in the original graph.
|
|
133
|
+
|
|
134
|
+
Parameters
|
|
135
|
+
----------
|
|
136
|
+
B : NetworkX graph
|
|
137
|
+
The input graph should be bipartite.
|
|
138
|
+
|
|
139
|
+
nodes : list or iterable
|
|
140
|
+
Distinct nodes to project onto (the "bottom" nodes).
|
|
141
|
+
|
|
142
|
+
ratio: Bool (default=False)
|
|
143
|
+
If True, edge weight is the ratio between actual shared neighbors
|
|
144
|
+
and maximum possible shared neighbors (i.e., the size of the other
|
|
145
|
+
node set). If False, edges weight is the number of shared neighbors.
|
|
146
|
+
|
|
147
|
+
Returns
|
|
148
|
+
-------
|
|
149
|
+
Graph : NetworkX graph
|
|
150
|
+
A graph that is the projection onto the given nodes.
|
|
151
|
+
|
|
152
|
+
Examples
|
|
153
|
+
--------
|
|
154
|
+
>>> from networkx.algorithms import bipartite
|
|
155
|
+
>>> B = nx.path_graph(4)
|
|
156
|
+
>>> G = bipartite.weighted_projected_graph(B, [1, 3])
|
|
157
|
+
>>> list(G)
|
|
158
|
+
[1, 3]
|
|
159
|
+
>>> list(G.edges(data=True))
|
|
160
|
+
[(1, 3, {'weight': 1})]
|
|
161
|
+
>>> G = bipartite.weighted_projected_graph(B, [1, 3], ratio=True)
|
|
162
|
+
>>> list(G.edges(data=True))
|
|
163
|
+
[(1, 3, {'weight': 0.5})]
|
|
164
|
+
|
|
165
|
+
Notes
|
|
166
|
+
-----
|
|
167
|
+
No attempt is made to verify that the input graph B is bipartite, or that
|
|
168
|
+
the input nodes are distinct. However, if the length of the input nodes is
|
|
169
|
+
greater than or equal to the nodes in the graph B, an exception is raised.
|
|
170
|
+
If the nodes are not distinct but don't raise this error, the output weights
|
|
171
|
+
will be incorrect.
|
|
172
|
+
The graph and node properties are (shallow) copied to the projected graph.
|
|
173
|
+
|
|
174
|
+
See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
|
|
175
|
+
for further details on how bipartite graphs are handled in NetworkX.
|
|
176
|
+
|
|
177
|
+
See Also
|
|
178
|
+
--------
|
|
179
|
+
is_bipartite,
|
|
180
|
+
is_bipartite_node_set,
|
|
181
|
+
sets,
|
|
182
|
+
collaboration_weighted_projected_graph,
|
|
183
|
+
overlap_weighted_projected_graph,
|
|
184
|
+
generic_weighted_projected_graph
|
|
185
|
+
projected_graph
|
|
186
|
+
|
|
187
|
+
References
|
|
188
|
+
----------
|
|
189
|
+
.. [1] Borgatti, S.P. and Halgin, D. In press. "Analyzing Affiliation
|
|
190
|
+
Networks". In Carrington, P. and Scott, J. (eds) The Sage Handbook
|
|
191
|
+
of Social Network Analysis. Sage Publications.
|
|
192
|
+
"""
|
|
193
|
+
if B.is_directed():
|
|
194
|
+
pred = B.pred
|
|
195
|
+
G = nx.DiGraph()
|
|
196
|
+
else:
|
|
197
|
+
pred = B.adj
|
|
198
|
+
G = nx.Graph()
|
|
199
|
+
G.graph.update(B.graph)
|
|
200
|
+
G.add_nodes_from((n, B.nodes[n]) for n in nodes)
|
|
201
|
+
n_top = len(B) - len(nodes)
|
|
202
|
+
|
|
203
|
+
if n_top < 1:
|
|
204
|
+
raise NetworkXAlgorithmError(
|
|
205
|
+
f"the size of the nodes to project onto ({len(nodes)}) is >= the graph size ({len(B)}).\n"
|
|
206
|
+
"They are either not a valid bipartite partition or contain duplicates"
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
for u in nodes:
|
|
210
|
+
unbrs = set(B[u])
|
|
211
|
+
nbrs2 = {n for nbr in unbrs for n in B[nbr]} - {u}
|
|
212
|
+
for v in nbrs2:
|
|
213
|
+
vnbrs = set(pred[v])
|
|
214
|
+
common = unbrs & vnbrs
|
|
215
|
+
if not ratio:
|
|
216
|
+
weight = len(common)
|
|
217
|
+
else:
|
|
218
|
+
weight = len(common) / n_top
|
|
219
|
+
G.add_edge(u, v, weight=weight)
|
|
220
|
+
return G
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@not_implemented_for("multigraph")
|
|
224
|
+
@nx._dispatchable(graphs="B", returns_graph=True)
|
|
225
|
+
def collaboration_weighted_projected_graph(B, nodes):
|
|
226
|
+
r"""Newman's weighted projection of B onto one of its node sets.
|
|
227
|
+
|
|
228
|
+
The collaboration weighted projection is the projection of the
|
|
229
|
+
bipartite network B onto the specified nodes with weights assigned
|
|
230
|
+
using Newman's collaboration model [1]_:
|
|
231
|
+
|
|
232
|
+
.. math::
|
|
233
|
+
|
|
234
|
+
w_{u, v} = \sum_k \frac{\delta_{u}^{k} \delta_{v}^{k}}{d_k - 1}
|
|
235
|
+
|
|
236
|
+
where `u` and `v` are nodes from the bottom bipartite node set,
|
|
237
|
+
and `k` is a node of the top node set.
|
|
238
|
+
The value `d_k` is the degree of node `k` in the bipartite
|
|
239
|
+
network and `\delta_{u}^{k}` is 1 if node `u` is
|
|
240
|
+
linked to node `k` in the original bipartite graph or 0 otherwise.
|
|
241
|
+
|
|
242
|
+
The nodes retain their attributes and are connected in the resulting
|
|
243
|
+
graph if have an edge to a common node in the original bipartite
|
|
244
|
+
graph.
|
|
245
|
+
|
|
246
|
+
Parameters
|
|
247
|
+
----------
|
|
248
|
+
B : NetworkX graph
|
|
249
|
+
The input graph should be bipartite.
|
|
250
|
+
|
|
251
|
+
nodes : list or iterable
|
|
252
|
+
Nodes to project onto (the "bottom" nodes).
|
|
253
|
+
|
|
254
|
+
Returns
|
|
255
|
+
-------
|
|
256
|
+
Graph : NetworkX graph
|
|
257
|
+
A graph that is the projection onto the given nodes.
|
|
258
|
+
|
|
259
|
+
Examples
|
|
260
|
+
--------
|
|
261
|
+
>>> from networkx.algorithms import bipartite
|
|
262
|
+
>>> B = nx.path_graph(5)
|
|
263
|
+
>>> B.add_edge(1, 5)
|
|
264
|
+
>>> G = bipartite.collaboration_weighted_projected_graph(B, [0, 2, 4, 5])
|
|
265
|
+
>>> list(G)
|
|
266
|
+
[0, 2, 4, 5]
|
|
267
|
+
>>> for edge in sorted(G.edges(data=True)):
|
|
268
|
+
... print(edge)
|
|
269
|
+
(0, 2, {'weight': 0.5})
|
|
270
|
+
(0, 5, {'weight': 0.5})
|
|
271
|
+
(2, 4, {'weight': 1.0})
|
|
272
|
+
(2, 5, {'weight': 0.5})
|
|
273
|
+
|
|
274
|
+
Notes
|
|
275
|
+
-----
|
|
276
|
+
No attempt is made to verify that the input graph B is bipartite.
|
|
277
|
+
The graph and node properties are (shallow) copied to the projected graph.
|
|
278
|
+
|
|
279
|
+
See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
|
|
280
|
+
for further details on how bipartite graphs are handled in NetworkX.
|
|
281
|
+
|
|
282
|
+
See Also
|
|
283
|
+
--------
|
|
284
|
+
is_bipartite,
|
|
285
|
+
is_bipartite_node_set,
|
|
286
|
+
sets,
|
|
287
|
+
weighted_projected_graph,
|
|
288
|
+
overlap_weighted_projected_graph,
|
|
289
|
+
generic_weighted_projected_graph,
|
|
290
|
+
projected_graph
|
|
291
|
+
|
|
292
|
+
References
|
|
293
|
+
----------
|
|
294
|
+
.. [1] Scientific collaboration networks: II.
|
|
295
|
+
Shortest paths, weighted networks, and centrality,
|
|
296
|
+
M. E. J. Newman, Phys. Rev. E 64, 016132 (2001).
|
|
297
|
+
"""
|
|
298
|
+
if B.is_directed():
|
|
299
|
+
pred = B.pred
|
|
300
|
+
G = nx.DiGraph()
|
|
301
|
+
else:
|
|
302
|
+
pred = B.adj
|
|
303
|
+
G = nx.Graph()
|
|
304
|
+
G.graph.update(B.graph)
|
|
305
|
+
G.add_nodes_from((n, B.nodes[n]) for n in nodes)
|
|
306
|
+
for u in nodes:
|
|
307
|
+
unbrs = set(B[u])
|
|
308
|
+
nbrs2 = {n for nbr in unbrs for n in B[nbr] if n != u}
|
|
309
|
+
for v in nbrs2:
|
|
310
|
+
vnbrs = set(pred[v])
|
|
311
|
+
common_degree = (len(B[n]) for n in unbrs & vnbrs)
|
|
312
|
+
weight = sum(1.0 / (deg - 1) for deg in common_degree if deg > 1)
|
|
313
|
+
G.add_edge(u, v, weight=weight)
|
|
314
|
+
return G
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
@not_implemented_for("multigraph")
|
|
318
|
+
@nx._dispatchable(graphs="B", returns_graph=True)
|
|
319
|
+
def overlap_weighted_projected_graph(B, nodes, jaccard=True):
|
|
320
|
+
r"""Overlap weighted projection of B onto one of its node sets.
|
|
321
|
+
|
|
322
|
+
The overlap weighted projection is the projection of the bipartite
|
|
323
|
+
network B onto the specified nodes with weights representing
|
|
324
|
+
the Jaccard index between the neighborhoods of the two nodes in the
|
|
325
|
+
original bipartite network [1]_:
|
|
326
|
+
|
|
327
|
+
.. math::
|
|
328
|
+
|
|
329
|
+
w_{v, u} = \frac{|N(u) \cap N(v)|}{|N(u) \cup N(v)|}
|
|
330
|
+
|
|
331
|
+
or if the parameter 'jaccard' is False, the fraction of common
|
|
332
|
+
neighbors by minimum of both nodes degree in the original
|
|
333
|
+
bipartite graph [1]_:
|
|
334
|
+
|
|
335
|
+
.. math::
|
|
336
|
+
|
|
337
|
+
w_{v, u} = \frac{|N(u) \cap N(v)|}{min(|N(u)|, |N(v)|)}
|
|
338
|
+
|
|
339
|
+
The nodes retain their attributes and are connected in the resulting
|
|
340
|
+
graph if have an edge to a common node in the original bipartite graph.
|
|
341
|
+
|
|
342
|
+
Parameters
|
|
343
|
+
----------
|
|
344
|
+
B : NetworkX graph
|
|
345
|
+
The input graph should be bipartite.
|
|
346
|
+
|
|
347
|
+
nodes : list or iterable
|
|
348
|
+
Nodes to project onto (the "bottom" nodes).
|
|
349
|
+
|
|
350
|
+
jaccard: Bool (default=True)
|
|
351
|
+
|
|
352
|
+
Returns
|
|
353
|
+
-------
|
|
354
|
+
Graph : NetworkX graph
|
|
355
|
+
A graph that is the projection onto the given nodes.
|
|
356
|
+
|
|
357
|
+
Examples
|
|
358
|
+
--------
|
|
359
|
+
>>> from networkx.algorithms import bipartite
|
|
360
|
+
>>> B = nx.path_graph(5)
|
|
361
|
+
>>> nodes = [0, 2, 4]
|
|
362
|
+
>>> G = bipartite.overlap_weighted_projected_graph(B, nodes)
|
|
363
|
+
>>> list(G)
|
|
364
|
+
[0, 2, 4]
|
|
365
|
+
>>> list(G.edges(data=True))
|
|
366
|
+
[(0, 2, {'weight': 0.5}), (2, 4, {'weight': 0.5})]
|
|
367
|
+
>>> G = bipartite.overlap_weighted_projected_graph(B, nodes, jaccard=False)
|
|
368
|
+
>>> list(G.edges(data=True))
|
|
369
|
+
[(0, 2, {'weight': 1.0}), (2, 4, {'weight': 1.0})]
|
|
370
|
+
|
|
371
|
+
Notes
|
|
372
|
+
-----
|
|
373
|
+
No attempt is made to verify that the input graph B is bipartite.
|
|
374
|
+
The graph and node properties are (shallow) copied to the projected graph.
|
|
375
|
+
|
|
376
|
+
See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
|
|
377
|
+
for further details on how bipartite graphs are handled in NetworkX.
|
|
378
|
+
|
|
379
|
+
See Also
|
|
380
|
+
--------
|
|
381
|
+
is_bipartite,
|
|
382
|
+
is_bipartite_node_set,
|
|
383
|
+
sets,
|
|
384
|
+
weighted_projected_graph,
|
|
385
|
+
collaboration_weighted_projected_graph,
|
|
386
|
+
generic_weighted_projected_graph,
|
|
387
|
+
projected_graph
|
|
388
|
+
|
|
389
|
+
References
|
|
390
|
+
----------
|
|
391
|
+
.. [1] Borgatti, S.P. and Halgin, D. In press. Analyzing Affiliation
|
|
392
|
+
Networks. In Carrington, P. and Scott, J. (eds) The Sage Handbook
|
|
393
|
+
of Social Network Analysis. Sage Publications.
|
|
394
|
+
|
|
395
|
+
"""
|
|
396
|
+
if B.is_directed():
|
|
397
|
+
pred = B.pred
|
|
398
|
+
G = nx.DiGraph()
|
|
399
|
+
else:
|
|
400
|
+
pred = B.adj
|
|
401
|
+
G = nx.Graph()
|
|
402
|
+
G.graph.update(B.graph)
|
|
403
|
+
G.add_nodes_from((n, B.nodes[n]) for n in nodes)
|
|
404
|
+
for u in nodes:
|
|
405
|
+
unbrs = set(B[u])
|
|
406
|
+
nbrs2 = {n for nbr in unbrs for n in B[nbr]} - {u}
|
|
407
|
+
for v in nbrs2:
|
|
408
|
+
vnbrs = set(pred[v])
|
|
409
|
+
if jaccard:
|
|
410
|
+
wt = len(unbrs & vnbrs) / len(unbrs | vnbrs)
|
|
411
|
+
else:
|
|
412
|
+
wt = len(unbrs & vnbrs) / min(len(unbrs), len(vnbrs))
|
|
413
|
+
G.add_edge(u, v, weight=wt)
|
|
414
|
+
return G
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
@not_implemented_for("multigraph")
|
|
418
|
+
@nx._dispatchable(graphs="B", preserve_all_attrs=True, returns_graph=True)
|
|
419
|
+
def generic_weighted_projected_graph(B, nodes, weight_function=None):
|
|
420
|
+
r"""Weighted projection of B with a user-specified weight function.
|
|
421
|
+
|
|
422
|
+
The bipartite network B is projected on to the specified nodes
|
|
423
|
+
with weights computed by a user-specified function. This function
|
|
424
|
+
must accept as a parameter the neighborhood sets of two nodes and
|
|
425
|
+
return an integer or a float.
|
|
426
|
+
|
|
427
|
+
The nodes retain their attributes and are connected in the resulting graph
|
|
428
|
+
if they have an edge to a common node in the original graph.
|
|
429
|
+
|
|
430
|
+
Parameters
|
|
431
|
+
----------
|
|
432
|
+
B : NetworkX graph
|
|
433
|
+
The input graph should be bipartite.
|
|
434
|
+
|
|
435
|
+
nodes : list or iterable
|
|
436
|
+
Nodes to project onto (the "bottom" nodes).
|
|
437
|
+
|
|
438
|
+
weight_function : function
|
|
439
|
+
This function must accept as parameters the same input graph
|
|
440
|
+
that this function, and two nodes; and return an integer or a float.
|
|
441
|
+
The default function computes the number of shared neighbors.
|
|
442
|
+
|
|
443
|
+
Returns
|
|
444
|
+
-------
|
|
445
|
+
Graph : NetworkX graph
|
|
446
|
+
A graph that is the projection onto the given nodes.
|
|
447
|
+
|
|
448
|
+
Examples
|
|
449
|
+
--------
|
|
450
|
+
>>> from networkx.algorithms import bipartite
|
|
451
|
+
>>> # Define some custom weight functions
|
|
452
|
+
>>> def jaccard(G, u, v):
|
|
453
|
+
... unbrs = set(G[u])
|
|
454
|
+
... vnbrs = set(G[v])
|
|
455
|
+
... return float(len(unbrs & vnbrs)) / len(unbrs | vnbrs)
|
|
456
|
+
>>> def my_weight(G, u, v, weight="weight"):
|
|
457
|
+
... w = 0
|
|
458
|
+
... for nbr in set(G[u]) & set(G[v]):
|
|
459
|
+
... w += G[u][nbr].get(weight, 1) + G[v][nbr].get(weight, 1)
|
|
460
|
+
... return w
|
|
461
|
+
>>> # A complete bipartite graph with 4 nodes and 4 edges
|
|
462
|
+
>>> B = nx.complete_bipartite_graph(2, 2)
|
|
463
|
+
>>> # Add some arbitrary weight to the edges
|
|
464
|
+
>>> for i, (u, v) in enumerate(B.edges()):
|
|
465
|
+
... B.edges[u, v]["weight"] = i + 1
|
|
466
|
+
>>> for edge in B.edges(data=True):
|
|
467
|
+
... print(edge)
|
|
468
|
+
(0, 2, {'weight': 1})
|
|
469
|
+
(0, 3, {'weight': 2})
|
|
470
|
+
(1, 2, {'weight': 3})
|
|
471
|
+
(1, 3, {'weight': 4})
|
|
472
|
+
>>> # By default, the weight is the number of shared neighbors
|
|
473
|
+
>>> G = bipartite.generic_weighted_projected_graph(B, [0, 1])
|
|
474
|
+
>>> print(list(G.edges(data=True)))
|
|
475
|
+
[(0, 1, {'weight': 2})]
|
|
476
|
+
>>> # To specify a custom weight function use the weight_function parameter
|
|
477
|
+
>>> G = bipartite.generic_weighted_projected_graph(
|
|
478
|
+
... B, [0, 1], weight_function=jaccard
|
|
479
|
+
... )
|
|
480
|
+
>>> print(list(G.edges(data=True)))
|
|
481
|
+
[(0, 1, {'weight': 1.0})]
|
|
482
|
+
>>> G = bipartite.generic_weighted_projected_graph(
|
|
483
|
+
... B, [0, 1], weight_function=my_weight
|
|
484
|
+
... )
|
|
485
|
+
>>> print(list(G.edges(data=True)))
|
|
486
|
+
[(0, 1, {'weight': 10})]
|
|
487
|
+
|
|
488
|
+
Notes
|
|
489
|
+
-----
|
|
490
|
+
No attempt is made to verify that the input graph B is bipartite.
|
|
491
|
+
The graph and node properties are (shallow) copied to the projected graph.
|
|
492
|
+
|
|
493
|
+
See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
|
|
494
|
+
for further details on how bipartite graphs are handled in NetworkX.
|
|
495
|
+
|
|
496
|
+
See Also
|
|
497
|
+
--------
|
|
498
|
+
is_bipartite,
|
|
499
|
+
is_bipartite_node_set,
|
|
500
|
+
sets,
|
|
501
|
+
weighted_projected_graph,
|
|
502
|
+
collaboration_weighted_projected_graph,
|
|
503
|
+
overlap_weighted_projected_graph,
|
|
504
|
+
projected_graph
|
|
505
|
+
|
|
506
|
+
"""
|
|
507
|
+
if B.is_directed():
|
|
508
|
+
pred = B.pred
|
|
509
|
+
G = nx.DiGraph()
|
|
510
|
+
else:
|
|
511
|
+
pred = B.adj
|
|
512
|
+
G = nx.Graph()
|
|
513
|
+
if weight_function is None:
|
|
514
|
+
|
|
515
|
+
def weight_function(G, u, v):
|
|
516
|
+
# Notice that we use set(pred[v]) for handling the directed case.
|
|
517
|
+
return len(set(G[u]) & set(pred[v]))
|
|
518
|
+
|
|
519
|
+
G.graph.update(B.graph)
|
|
520
|
+
G.add_nodes_from((n, B.nodes[n]) for n in nodes)
|
|
521
|
+
for u in nodes:
|
|
522
|
+
nbrs2 = {n for nbr in set(B[u]) for n in B[nbr]} - {u}
|
|
523
|
+
for v in nbrs2:
|
|
524
|
+
weight = weight_function(B, u, v)
|
|
525
|
+
G.add_edge(u, v, weight=weight)
|
|
526
|
+
return G
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""Node redundancy for bipartite graphs."""
|
|
2
|
+
|
|
3
|
+
from itertools import combinations
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
from networkx import NetworkXError
|
|
7
|
+
|
|
8
|
+
__all__ = ["node_redundancy"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@nx._dispatchable
|
|
12
|
+
def node_redundancy(G, nodes=None):
|
|
13
|
+
r"""Computes the node redundancy coefficients for the nodes in the bipartite
|
|
14
|
+
graph `G`.
|
|
15
|
+
|
|
16
|
+
The redundancy coefficient of a node `v` is the fraction of pairs of
|
|
17
|
+
neighbors of `v` that are both linked to other nodes. In a one-mode
|
|
18
|
+
projection these nodes would be linked together even if `v` were
|
|
19
|
+
not there.
|
|
20
|
+
|
|
21
|
+
More formally, for any vertex `v`, the *redundancy coefficient of `v`* is
|
|
22
|
+
defined by
|
|
23
|
+
|
|
24
|
+
.. math::
|
|
25
|
+
|
|
26
|
+
rc(v) = \frac{|\{\{u, w\} \subseteq N(v),
|
|
27
|
+
\: \exists v' \neq v,\: (v',u) \in E\:
|
|
28
|
+
\mathrm{and}\: (v',w) \in E\}|}{ \frac{|N(v)|(|N(v)|-1)}{2}},
|
|
29
|
+
|
|
30
|
+
where `N(v)` is the set of neighbors of `v` in `G` [1]_.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
G : graph
|
|
35
|
+
A bipartite graph
|
|
36
|
+
|
|
37
|
+
nodes : list or iterable (optional)
|
|
38
|
+
Compute redundancy for these nodes. The default is all nodes in G.
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
redundancy : dictionary
|
|
43
|
+
A dictionary keyed by node with the node redundancy value.
|
|
44
|
+
|
|
45
|
+
Examples
|
|
46
|
+
--------
|
|
47
|
+
Compute the redundancy coefficient of each node in a graph:
|
|
48
|
+
|
|
49
|
+
>>> from networkx.algorithms import bipartite
|
|
50
|
+
>>> G = nx.cycle_graph(4)
|
|
51
|
+
>>> rc = bipartite.node_redundancy(G)
|
|
52
|
+
>>> rc[0]
|
|
53
|
+
1.0
|
|
54
|
+
|
|
55
|
+
Compute the average redundancy for the graph:
|
|
56
|
+
|
|
57
|
+
>>> from networkx.algorithms import bipartite
|
|
58
|
+
>>> G = nx.cycle_graph(4)
|
|
59
|
+
>>> rc = bipartite.node_redundancy(G)
|
|
60
|
+
>>> sum(rc.values()) / len(G)
|
|
61
|
+
1.0
|
|
62
|
+
|
|
63
|
+
Compute the average redundancy for a set of nodes:
|
|
64
|
+
|
|
65
|
+
>>> from networkx.algorithms import bipartite
|
|
66
|
+
>>> G = nx.cycle_graph(4)
|
|
67
|
+
>>> rc = bipartite.node_redundancy(G)
|
|
68
|
+
>>> nodes = [0, 2]
|
|
69
|
+
>>> sum(rc[n] for n in nodes) / len(nodes)
|
|
70
|
+
1.0
|
|
71
|
+
|
|
72
|
+
Raises
|
|
73
|
+
------
|
|
74
|
+
NetworkXError
|
|
75
|
+
If any of the nodes in the graph (or in `nodes`, if specified) has
|
|
76
|
+
(out-)degree less than two (which would result in division by zero,
|
|
77
|
+
according to the definition of the redundancy coefficient).
|
|
78
|
+
|
|
79
|
+
References
|
|
80
|
+
----------
|
|
81
|
+
.. [1] Latapy, Matthieu, Clémence Magnien, and Nathalie Del Vecchio (2008).
|
|
82
|
+
Basic notions for the analysis of large two-mode networks.
|
|
83
|
+
Social Networks 30(1), 31--48.
|
|
84
|
+
|
|
85
|
+
"""
|
|
86
|
+
if nodes is None:
|
|
87
|
+
nodes = G
|
|
88
|
+
if any(len(G[v]) < 2 for v in nodes):
|
|
89
|
+
raise NetworkXError(
|
|
90
|
+
"Cannot compute redundancy coefficient for a node"
|
|
91
|
+
" that has fewer than two neighbors."
|
|
92
|
+
)
|
|
93
|
+
# TODO This can be trivially parallelized.
|
|
94
|
+
return {v: _node_redundancy(G, v) for v in nodes}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _node_redundancy(G, v):
|
|
98
|
+
"""Returns the redundancy of the node `v` in the bipartite graph `G`.
|
|
99
|
+
|
|
100
|
+
If `G` is a graph with `n` nodes, the redundancy of a node is the ratio
|
|
101
|
+
of the "overlap" of `v` to the maximum possible overlap of `v`
|
|
102
|
+
according to its degree. The overlap of `v` is the number of pairs of
|
|
103
|
+
neighbors that have mutual neighbors themselves, other than `v`.
|
|
104
|
+
|
|
105
|
+
`v` must have at least two neighbors in `G`.
|
|
106
|
+
|
|
107
|
+
"""
|
|
108
|
+
n = len(G[v])
|
|
109
|
+
overlap = sum(
|
|
110
|
+
1 for (u, w) in combinations(G[v], 2) if (set(G[u]) & set(G[w])) - {v}
|
|
111
|
+
)
|
|
112
|
+
return (2 * overlap) / (n * (n - 1))
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Spectral bipartivity measure.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
|
|
7
|
+
__all__ = ["spectral_bipartivity"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@nx._dispatchable(edge_attrs="weight")
|
|
11
|
+
def spectral_bipartivity(G, nodes=None, weight="weight"):
|
|
12
|
+
"""Returns the spectral bipartivity.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
G : NetworkX graph
|
|
17
|
+
|
|
18
|
+
nodes : list or container optional(default is all nodes)
|
|
19
|
+
Nodes to return value of spectral bipartivity contribution.
|
|
20
|
+
|
|
21
|
+
weight : string or None optional (default = 'weight')
|
|
22
|
+
Edge data key to use for edge weights. If None, weights set to 1.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
sb : float or dict
|
|
27
|
+
A single number if the keyword nodes is not specified, or
|
|
28
|
+
a dictionary keyed by node with the spectral bipartivity contribution
|
|
29
|
+
of that node as the value.
|
|
30
|
+
|
|
31
|
+
Examples
|
|
32
|
+
--------
|
|
33
|
+
>>> from networkx.algorithms import bipartite
|
|
34
|
+
>>> G = nx.path_graph(4)
|
|
35
|
+
>>> bipartite.spectral_bipartivity(G)
|
|
36
|
+
1.0
|
|
37
|
+
|
|
38
|
+
Notes
|
|
39
|
+
-----
|
|
40
|
+
This implementation uses Numpy (dense) matrices which are not efficient
|
|
41
|
+
for storing large sparse graphs.
|
|
42
|
+
|
|
43
|
+
See Also
|
|
44
|
+
--------
|
|
45
|
+
color
|
|
46
|
+
|
|
47
|
+
References
|
|
48
|
+
----------
|
|
49
|
+
.. [1] E. Estrada and J. A. Rodríguez-Velázquez, "Spectral measures of
|
|
50
|
+
bipartivity in complex networks", PhysRev E 72, 046105 (2005)
|
|
51
|
+
"""
|
|
52
|
+
import scipy as sp
|
|
53
|
+
|
|
54
|
+
nodelist = list(G) # ordering of nodes in matrix
|
|
55
|
+
A = nx.to_numpy_array(G, nodelist, weight=weight)
|
|
56
|
+
expA = sp.linalg.expm(A)
|
|
57
|
+
expmA = sp.linalg.expm(-A)
|
|
58
|
+
coshA = 0.5 * (expA + expmA)
|
|
59
|
+
if nodes is None:
|
|
60
|
+
# return single number for entire graph
|
|
61
|
+
return float(coshA.diagonal().sum() / expA.diagonal().sum())
|
|
62
|
+
else:
|
|
63
|
+
# contribution for individual nodes
|
|
64
|
+
index = dict(zip(nodelist, range(len(nodelist))))
|
|
65
|
+
sb = {}
|
|
66
|
+
for n in nodes:
|
|
67
|
+
i = index[n]
|
|
68
|
+
sb[n] = coshA.item(i, i) / expA.item(i, i)
|
|
69
|
+
return sb
|
|
File without changes
|