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,219 @@
|
|
|
1
|
+
"""This module provides the functions for node classification problem.
|
|
2
|
+
|
|
3
|
+
The functions in this module are not imported
|
|
4
|
+
into the top level `networkx` namespace.
|
|
5
|
+
You can access these functions by importing
|
|
6
|
+
the `networkx.algorithms.node_classification` modules,
|
|
7
|
+
then accessing the functions as attributes of `node_classification`.
|
|
8
|
+
For example:
|
|
9
|
+
|
|
10
|
+
>>> from networkx.algorithms import node_classification
|
|
11
|
+
>>> G = nx.path_graph(4)
|
|
12
|
+
>>> G.edges()
|
|
13
|
+
EdgeView([(0, 1), (1, 2), (2, 3)])
|
|
14
|
+
>>> G.nodes[0]["label"] = "A"
|
|
15
|
+
>>> G.nodes[3]["label"] = "B"
|
|
16
|
+
>>> node_classification.harmonic_function(G)
|
|
17
|
+
['A', 'A', 'B', 'B']
|
|
18
|
+
|
|
19
|
+
References
|
|
20
|
+
----------
|
|
21
|
+
Zhu, X., Ghahramani, Z., & Lafferty, J. (2003, August).
|
|
22
|
+
Semi-supervised learning using gaussian fields and harmonic functions.
|
|
23
|
+
In ICML (Vol. 3, pp. 912-919).
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
import networkx as nx
|
|
27
|
+
|
|
28
|
+
__all__ = ["harmonic_function", "local_and_global_consistency"]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@nx.utils.not_implemented_for("directed")
|
|
32
|
+
@nx._dispatchable(node_attrs="label_name")
|
|
33
|
+
def harmonic_function(G, max_iter=30, label_name="label"):
|
|
34
|
+
"""Node classification by Harmonic function
|
|
35
|
+
|
|
36
|
+
Function for computing Harmonic function algorithm by Zhu et al.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
G : NetworkX Graph
|
|
41
|
+
max_iter : int
|
|
42
|
+
maximum number of iterations allowed
|
|
43
|
+
label_name : string
|
|
44
|
+
name of target labels to predict
|
|
45
|
+
|
|
46
|
+
Returns
|
|
47
|
+
-------
|
|
48
|
+
predicted : list
|
|
49
|
+
List of length ``len(G)`` with the predicted labels for each node.
|
|
50
|
+
|
|
51
|
+
Raises
|
|
52
|
+
------
|
|
53
|
+
NetworkXError
|
|
54
|
+
If no nodes in `G` have attribute `label_name`.
|
|
55
|
+
|
|
56
|
+
Examples
|
|
57
|
+
--------
|
|
58
|
+
>>> from networkx.algorithms import node_classification
|
|
59
|
+
>>> G = nx.path_graph(4)
|
|
60
|
+
>>> G.nodes[0]["label"] = "A"
|
|
61
|
+
>>> G.nodes[3]["label"] = "B"
|
|
62
|
+
>>> G.nodes(data=True)
|
|
63
|
+
NodeDataView({0: {'label': 'A'}, 1: {}, 2: {}, 3: {'label': 'B'}})
|
|
64
|
+
>>> G.edges()
|
|
65
|
+
EdgeView([(0, 1), (1, 2), (2, 3)])
|
|
66
|
+
>>> predicted = node_classification.harmonic_function(G)
|
|
67
|
+
>>> predicted
|
|
68
|
+
['A', 'A', 'B', 'B']
|
|
69
|
+
|
|
70
|
+
References
|
|
71
|
+
----------
|
|
72
|
+
Zhu, X., Ghahramani, Z., & Lafferty, J. (2003, August).
|
|
73
|
+
Semi-supervised learning using gaussian fields and harmonic functions.
|
|
74
|
+
In ICML (Vol. 3, pp. 912-919).
|
|
75
|
+
"""
|
|
76
|
+
import numpy as np
|
|
77
|
+
import scipy as sp
|
|
78
|
+
|
|
79
|
+
X = nx.to_scipy_sparse_array(G) # adjacency matrix
|
|
80
|
+
labels, label_dict = _get_label_info(G, label_name)
|
|
81
|
+
|
|
82
|
+
if labels.shape[0] == 0:
|
|
83
|
+
raise nx.NetworkXError(
|
|
84
|
+
f"No node on the input graph is labeled by '{label_name}'."
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
n_samples = X.shape[0]
|
|
88
|
+
n_classes = label_dict.shape[0]
|
|
89
|
+
F = np.zeros((n_samples, n_classes))
|
|
90
|
+
|
|
91
|
+
# Build propagation matrix
|
|
92
|
+
degrees = X.sum(axis=0)
|
|
93
|
+
degrees[degrees == 0] = 1 # Avoid division by 0
|
|
94
|
+
D = sp.sparse.dia_array((1.0 / degrees, 0), shape=(n_samples, n_samples)).tocsr()
|
|
95
|
+
P = (D @ X).tolil()
|
|
96
|
+
P[labels[:, 0]] = 0 # labels[:, 0] indicates IDs of labeled nodes
|
|
97
|
+
# Build base matrix
|
|
98
|
+
B = np.zeros((n_samples, n_classes))
|
|
99
|
+
B[labels[:, 0], labels[:, 1]] = 1
|
|
100
|
+
|
|
101
|
+
for _ in range(max_iter):
|
|
102
|
+
F = (P @ F) + B
|
|
103
|
+
|
|
104
|
+
return label_dict[np.argmax(F, axis=1)].tolist()
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@nx.utils.not_implemented_for("directed")
|
|
108
|
+
@nx._dispatchable(node_attrs="label_name")
|
|
109
|
+
def local_and_global_consistency(G, alpha=0.99, max_iter=30, label_name="label"):
|
|
110
|
+
"""Node classification by Local and Global Consistency
|
|
111
|
+
|
|
112
|
+
Function for computing Local and global consistency algorithm by Zhou et al.
|
|
113
|
+
|
|
114
|
+
Parameters
|
|
115
|
+
----------
|
|
116
|
+
G : NetworkX Graph
|
|
117
|
+
alpha : float
|
|
118
|
+
Clamping factor
|
|
119
|
+
max_iter : int
|
|
120
|
+
Maximum number of iterations allowed
|
|
121
|
+
label_name : string
|
|
122
|
+
Name of target labels to predict
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
predicted : list
|
|
127
|
+
List of length ``len(G)`` with the predicted labels for each node.
|
|
128
|
+
|
|
129
|
+
Raises
|
|
130
|
+
------
|
|
131
|
+
NetworkXError
|
|
132
|
+
If no nodes in `G` have attribute `label_name`.
|
|
133
|
+
|
|
134
|
+
Examples
|
|
135
|
+
--------
|
|
136
|
+
>>> from networkx.algorithms import node_classification
|
|
137
|
+
>>> G = nx.path_graph(4)
|
|
138
|
+
>>> G.nodes[0]["label"] = "A"
|
|
139
|
+
>>> G.nodes[3]["label"] = "B"
|
|
140
|
+
>>> G.nodes(data=True)
|
|
141
|
+
NodeDataView({0: {'label': 'A'}, 1: {}, 2: {}, 3: {'label': 'B'}})
|
|
142
|
+
>>> G.edges()
|
|
143
|
+
EdgeView([(0, 1), (1, 2), (2, 3)])
|
|
144
|
+
>>> predicted = node_classification.local_and_global_consistency(G)
|
|
145
|
+
>>> predicted
|
|
146
|
+
['A', 'A', 'B', 'B']
|
|
147
|
+
|
|
148
|
+
References
|
|
149
|
+
----------
|
|
150
|
+
Zhou, D., Bousquet, O., Lal, T. N., Weston, J., & Schölkopf, B. (2004).
|
|
151
|
+
Learning with local and global consistency.
|
|
152
|
+
Advances in neural information processing systems, 16(16), 321-328.
|
|
153
|
+
"""
|
|
154
|
+
import numpy as np
|
|
155
|
+
import scipy as sp
|
|
156
|
+
|
|
157
|
+
X = nx.to_scipy_sparse_array(G) # adjacency matrix
|
|
158
|
+
labels, label_dict = _get_label_info(G, label_name)
|
|
159
|
+
|
|
160
|
+
if labels.shape[0] == 0:
|
|
161
|
+
raise nx.NetworkXError(
|
|
162
|
+
f"No node on the input graph is labeled by '{label_name}'."
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
n_samples = X.shape[0]
|
|
166
|
+
n_classes = label_dict.shape[0]
|
|
167
|
+
F = np.zeros((n_samples, n_classes))
|
|
168
|
+
|
|
169
|
+
# Build propagation matrix
|
|
170
|
+
degrees = X.sum(axis=0)
|
|
171
|
+
degrees[degrees == 0] = 1 # Avoid division by 0
|
|
172
|
+
D2 = sp.sparse.dia_array(
|
|
173
|
+
(1.0 / np.sqrt(degrees), 0), shape=(n_samples, n_samples)
|
|
174
|
+
).tocsr()
|
|
175
|
+
P = alpha * ((D2 @ X) @ D2)
|
|
176
|
+
# Build base matrix
|
|
177
|
+
B = np.zeros((n_samples, n_classes))
|
|
178
|
+
B[labels[:, 0], labels[:, 1]] = 1 - alpha
|
|
179
|
+
|
|
180
|
+
for _ in range(max_iter):
|
|
181
|
+
F = (P @ F) + B
|
|
182
|
+
|
|
183
|
+
return label_dict[np.argmax(F, axis=1)].tolist()
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _get_label_info(G, label_name):
|
|
187
|
+
"""Get and return information of labels from the input graph
|
|
188
|
+
|
|
189
|
+
Parameters
|
|
190
|
+
----------
|
|
191
|
+
G : Network X graph
|
|
192
|
+
label_name : string
|
|
193
|
+
Name of the target label
|
|
194
|
+
|
|
195
|
+
Returns
|
|
196
|
+
-------
|
|
197
|
+
labels : numpy array, shape = [n_labeled_samples, 2]
|
|
198
|
+
Array of pairs of labeled node ID and label ID
|
|
199
|
+
label_dict : numpy array, shape = [n_classes]
|
|
200
|
+
Array of labels
|
|
201
|
+
i-th element contains the label corresponding label ID `i`
|
|
202
|
+
"""
|
|
203
|
+
import numpy as np
|
|
204
|
+
|
|
205
|
+
labels = []
|
|
206
|
+
label_to_id = {}
|
|
207
|
+
lid = 0
|
|
208
|
+
for i, n in enumerate(G.nodes(data=True)):
|
|
209
|
+
if label_name in n[1]:
|
|
210
|
+
label = n[1][label_name]
|
|
211
|
+
if label not in label_to_id:
|
|
212
|
+
label_to_id[label] = lid
|
|
213
|
+
lid += 1
|
|
214
|
+
labels.append([i, label_to_id[label]])
|
|
215
|
+
labels = np.array(labels)
|
|
216
|
+
label_dict = np.array(
|
|
217
|
+
[label for label, _ in sorted(label_to_id.items(), key=lambda x: x[1])]
|
|
218
|
+
)
|
|
219
|
+
return (labels, label_dict)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
r"""Computation of graph non-randomness."""
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
from networkx.utils import not_implemented_for
|
|
7
|
+
|
|
8
|
+
__all__ = ["non_randomness"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@not_implemented_for("directed")
|
|
12
|
+
@not_implemented_for("multigraph")
|
|
13
|
+
@nx._dispatchable(edge_attrs="weight")
|
|
14
|
+
def non_randomness(G, k=None, weight="weight"):
|
|
15
|
+
"""Compute the non-randomness of a graph.
|
|
16
|
+
|
|
17
|
+
The first value $R_G$ is the sum of non-randomness values of all
|
|
18
|
+
edges within the graph (where the non-randomness of an edge tends to be
|
|
19
|
+
small when the two nodes linked by that edge are from two different
|
|
20
|
+
communities).
|
|
21
|
+
|
|
22
|
+
The second value $R_G^*$ is a relative measure that indicates
|
|
23
|
+
to what extent `G` is different from a random graph in terms
|
|
24
|
+
of probability. The closer it is to 0, the higher the likelihood
|
|
25
|
+
the graph was generated by an Erdős--Rényi model.
|
|
26
|
+
|
|
27
|
+
Parameters
|
|
28
|
+
----------
|
|
29
|
+
G : NetworkX graph
|
|
30
|
+
Graph must be undirected, connected, and without self-loops.
|
|
31
|
+
|
|
32
|
+
k : int or None, optional (default=None)
|
|
33
|
+
The number of communities in `G`.
|
|
34
|
+
If `k` is not set, the function uses a default community detection
|
|
35
|
+
algorithm (:func:`~networkx.algorithms.community.label_propagation_communities`)
|
|
36
|
+
to set it.
|
|
37
|
+
|
|
38
|
+
weight : string or None, optional (default="weight")
|
|
39
|
+
The name of an edge attribute that holds the numerical value used
|
|
40
|
+
as a weight. If `None`, then each edge has weight 1, i.e., the graph is
|
|
41
|
+
binary.
|
|
42
|
+
|
|
43
|
+
Returns
|
|
44
|
+
-------
|
|
45
|
+
(float, float) tuple
|
|
46
|
+
The first value is $R_G$, the non-randomness of the graph,
|
|
47
|
+
the second is $R_G^*$, the relative non-randomness
|
|
48
|
+
w.r.t. the Erdős--Rényi model.
|
|
49
|
+
|
|
50
|
+
Raises
|
|
51
|
+
------
|
|
52
|
+
NetworkXNotImplemented
|
|
53
|
+
If the input graph is directed or a multigraph.
|
|
54
|
+
|
|
55
|
+
NetworkXException
|
|
56
|
+
If the input graph is not connected.
|
|
57
|
+
|
|
58
|
+
NetworkXError
|
|
59
|
+
If the input graph contains self-loops or has no edges.
|
|
60
|
+
|
|
61
|
+
ValueError
|
|
62
|
+
If `k` is not in $\\{1, \\dots, n-1\\}$, where $n$ is the number of nodes,
|
|
63
|
+
or if `k` is such that the computed edge probability
|
|
64
|
+
$p = \\frac{2km}{n(n-k)}$ does not satisfy $0 < p < 1$.
|
|
65
|
+
|
|
66
|
+
Examples
|
|
67
|
+
--------
|
|
68
|
+
>>> G = nx.karate_club_graph()
|
|
69
|
+
>>> nr, nr_rd = nx.non_randomness(G, 2)
|
|
70
|
+
>>> nr, nr_rd = nx.non_randomness(G, 2, "weight")
|
|
71
|
+
|
|
72
|
+
When the number of communities `k` is not specified,
|
|
73
|
+
:func:`~networkx.algorithms.community.label_propagation_communities`
|
|
74
|
+
is used to compute it.
|
|
75
|
+
This algorithm can give different results depending on
|
|
76
|
+
the order of nodes and edges in the graph.
|
|
77
|
+
For example, while the following graphs are identical,
|
|
78
|
+
computing the non-randomness of each of them yields different results:
|
|
79
|
+
|
|
80
|
+
>>> G1, G2 = nx.Graph(), nx.Graph()
|
|
81
|
+
>>> G1.add_edges_from([(0, 1), (1, 2), (1, 3), (3, 4)])
|
|
82
|
+
>>> G2.add_edges_from([(0, 1), (1, 3), (1, 2), (3, 4)])
|
|
83
|
+
>>> [round(r, 6) for r in nx.non_randomness(G1)]
|
|
84
|
+
[-1.847759, -5.842437]
|
|
85
|
+
>>> [round(r, 6) for r in nx.non_randomness(G2)]
|
|
86
|
+
Traceback (most recent call last):
|
|
87
|
+
...
|
|
88
|
+
ValueError: invalid number of communities for graph with 5 nodes and 4 edges: 2
|
|
89
|
+
|
|
90
|
+
This is because the community detection algorithm finds
|
|
91
|
+
1 community in `G1` and 2 communities in `G2`.
|
|
92
|
+
This can be resolved by specifying the number of communities `k`:
|
|
93
|
+
|
|
94
|
+
>>> [round(r, 6) for r in nx.non_randomness(G2, k=1)]
|
|
95
|
+
[-1.847759, -5.842437]
|
|
96
|
+
|
|
97
|
+
Notes
|
|
98
|
+
-----
|
|
99
|
+
If a `weight` argument is passed, this algorithm will use the eigenvalues
|
|
100
|
+
of the weighted adjacency matrix instead.
|
|
101
|
+
|
|
102
|
+
The output of this function corresponds to (4.4) and (4.5) in [1]_.
|
|
103
|
+
A lower value of $R^*_G$ indicates a more random graph;
|
|
104
|
+
one can think of $1 - \\Phi(R_G^*)$ as the similarity
|
|
105
|
+
between the graph and a random graph,
|
|
106
|
+
where $\\Phi(x)$ is the cumulative distribution function
|
|
107
|
+
of the standard normal distribution.
|
|
108
|
+
|
|
109
|
+
Theorem 2 in [2]_ states that for any graph $G$
|
|
110
|
+
with $n$ nodes, $m$ edges, and $k$ communities,
|
|
111
|
+
its non-randomness is bounded below by the non-randomness of an
|
|
112
|
+
$r$-regular graph (a graph where each node has degree $r$),
|
|
113
|
+
and bounded above by the non-randomness of an $l$-complete graph
|
|
114
|
+
(a graph where each community is a clique of $l$ nodes).
|
|
115
|
+
|
|
116
|
+
References
|
|
117
|
+
----------
|
|
118
|
+
.. [1] Xiaowei Ying and Xintao Wu,
|
|
119
|
+
On Randomness Measures for Social Networks,
|
|
120
|
+
SIAM International Conference on Data Mining. 2009
|
|
121
|
+
https://doi.org/10.1137/1.9781611972795.61
|
|
122
|
+
.. [2] Ying, Xiaowei & Wu, Leting & Wu, Xintao. (2012).
|
|
123
|
+
A Spectrum-Based Framework for Quantifying Randomness of Social Networks.
|
|
124
|
+
IEEE Transactions on Knowledge and Data Engineering 23(12):1842--1856.
|
|
125
|
+
https://dl.acm.org/doi/abs/10.1109/TKDE.2010.218
|
|
126
|
+
"""
|
|
127
|
+
import numpy as np
|
|
128
|
+
|
|
129
|
+
# corner case: graph has no edges
|
|
130
|
+
if nx.is_empty(G):
|
|
131
|
+
raise nx.NetworkXError("non_randomness not applicable to empty graphs")
|
|
132
|
+
if not nx.is_connected(G):
|
|
133
|
+
raise nx.NetworkXException("Non connected graph.")
|
|
134
|
+
if len(list(nx.selfloop_edges(G))) > 0:
|
|
135
|
+
raise nx.NetworkXError("Graph must not contain self-loops")
|
|
136
|
+
|
|
137
|
+
n = G.number_of_nodes()
|
|
138
|
+
m = G.number_of_edges()
|
|
139
|
+
|
|
140
|
+
if k is None:
|
|
141
|
+
k = len(tuple(nx.community.label_propagation_communities(G)))
|
|
142
|
+
if not 1 <= k < n or not 0 < (p := (2 * k * m) / (n * (n - k))) < 1:
|
|
143
|
+
err = (
|
|
144
|
+
f"invalid number of communities for graph with {n} nodes and {m} edges: {k}"
|
|
145
|
+
)
|
|
146
|
+
raise ValueError(err)
|
|
147
|
+
|
|
148
|
+
# eq. 4.4
|
|
149
|
+
eigenvalues = np.linalg.eigvals(nx.to_numpy_array(G, weight=weight))
|
|
150
|
+
nr = float(np.real(np.sum(eigenvalues[:k])))
|
|
151
|
+
|
|
152
|
+
# eq. 4.5
|
|
153
|
+
nr_rd = (nr - ((n - 2 * k) * p + k)) / math.sqrt(2 * k * p * (1 - p))
|
|
154
|
+
|
|
155
|
+
return nr, nr_rd
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"""Operations on many graphs."""
|
|
2
|
+
|
|
3
|
+
from itertools import chain, repeat
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
|
|
7
|
+
__all__ = ["union_all", "compose_all", "disjoint_union_all", "intersection_all"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@nx._dispatchable(graphs="[graphs]", preserve_all_attrs=True, returns_graph=True)
|
|
11
|
+
def union_all(graphs, rename=()):
|
|
12
|
+
"""Returns the union of all graphs.
|
|
13
|
+
|
|
14
|
+
The graphs must be disjoint, otherwise an exception is raised.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
graphs : iterable
|
|
19
|
+
Iterable of NetworkX graphs
|
|
20
|
+
|
|
21
|
+
rename : iterable , optional
|
|
22
|
+
Node names of graphs can be changed by specifying the tuple
|
|
23
|
+
rename=('G-','H-') (for example). Node "u" in G is then renamed
|
|
24
|
+
"G-u" and "v" in H is renamed "H-v". Infinite generators (like itertools.count)
|
|
25
|
+
are also supported.
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
U : a graph with the same type as the first graph in list
|
|
30
|
+
|
|
31
|
+
Raises
|
|
32
|
+
------
|
|
33
|
+
ValueError
|
|
34
|
+
If `graphs` is an empty list.
|
|
35
|
+
|
|
36
|
+
NetworkXError
|
|
37
|
+
In case of mixed type graphs, like MultiGraph and Graph, or directed and undirected graphs.
|
|
38
|
+
|
|
39
|
+
Notes
|
|
40
|
+
-----
|
|
41
|
+
For operating on mixed type graphs, they should be converted to the same type.
|
|
42
|
+
>>> G = nx.Graph()
|
|
43
|
+
>>> H = nx.DiGraph()
|
|
44
|
+
>>> GH = union_all([nx.DiGraph(G), H])
|
|
45
|
+
|
|
46
|
+
To force a disjoint union with node relabeling, use
|
|
47
|
+
disjoint_union_all(G,H) or convert_node_labels_to integers().
|
|
48
|
+
|
|
49
|
+
Graph, edge, and node attributes are propagated to the union graph.
|
|
50
|
+
If a graph attribute is present in multiple graphs, then the value
|
|
51
|
+
from the last graph in the list with that attribute is used.
|
|
52
|
+
|
|
53
|
+
Examples
|
|
54
|
+
--------
|
|
55
|
+
>>> G1 = nx.Graph([(1, 2), (2, 3)])
|
|
56
|
+
>>> G2 = nx.Graph([(4, 5), (5, 6)])
|
|
57
|
+
>>> result_graph = nx.union_all([G1, G2])
|
|
58
|
+
>>> result_graph.nodes()
|
|
59
|
+
NodeView((1, 2, 3, 4, 5, 6))
|
|
60
|
+
>>> result_graph.edges()
|
|
61
|
+
EdgeView([(1, 2), (2, 3), (4, 5), (5, 6)])
|
|
62
|
+
|
|
63
|
+
See Also
|
|
64
|
+
--------
|
|
65
|
+
union
|
|
66
|
+
disjoint_union_all
|
|
67
|
+
"""
|
|
68
|
+
R = None
|
|
69
|
+
seen_nodes = set()
|
|
70
|
+
|
|
71
|
+
# rename graph to obtain disjoint node labels
|
|
72
|
+
def add_prefix(graph, prefix):
|
|
73
|
+
if prefix is None:
|
|
74
|
+
return graph
|
|
75
|
+
|
|
76
|
+
def label(x):
|
|
77
|
+
return f"{prefix}{x}"
|
|
78
|
+
|
|
79
|
+
return nx.relabel_nodes(graph, label)
|
|
80
|
+
|
|
81
|
+
rename = chain(rename, repeat(None))
|
|
82
|
+
graphs = (add_prefix(G, name) for G, name in zip(graphs, rename))
|
|
83
|
+
|
|
84
|
+
for i, G in enumerate(graphs):
|
|
85
|
+
G_nodes_set = set(G.nodes)
|
|
86
|
+
if i == 0:
|
|
87
|
+
# Union is the same type as first graph
|
|
88
|
+
R = G.__class__()
|
|
89
|
+
elif G.is_directed() != R.is_directed():
|
|
90
|
+
raise nx.NetworkXError("All graphs must be directed or undirected.")
|
|
91
|
+
elif G.is_multigraph() != R.is_multigraph():
|
|
92
|
+
raise nx.NetworkXError("All graphs must be graphs or multigraphs.")
|
|
93
|
+
elif not seen_nodes.isdisjoint(G_nodes_set):
|
|
94
|
+
raise nx.NetworkXError(
|
|
95
|
+
"The node sets of the graphs are not disjoint.\n"
|
|
96
|
+
"Use `rename` to specify prefixes for the graphs or use\n"
|
|
97
|
+
"disjoint_union(G1, G2, ..., GN)."
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
seen_nodes |= G_nodes_set
|
|
101
|
+
R.graph.update(G.graph)
|
|
102
|
+
R.add_nodes_from(G.nodes(data=True))
|
|
103
|
+
R.add_edges_from(
|
|
104
|
+
G.edges(keys=True, data=True) if G.is_multigraph() else G.edges(data=True)
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
if R is None:
|
|
108
|
+
raise ValueError("cannot apply union_all to an empty list")
|
|
109
|
+
|
|
110
|
+
return R
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@nx._dispatchable(graphs="[graphs]", preserve_all_attrs=True, returns_graph=True)
|
|
114
|
+
def disjoint_union_all(graphs):
|
|
115
|
+
"""Returns the disjoint union of all graphs.
|
|
116
|
+
|
|
117
|
+
This operation forces distinct integer node labels starting with 0
|
|
118
|
+
for the first graph in the list and numbering consecutively.
|
|
119
|
+
|
|
120
|
+
Parameters
|
|
121
|
+
----------
|
|
122
|
+
graphs : iterable
|
|
123
|
+
Iterable of NetworkX graphs
|
|
124
|
+
|
|
125
|
+
Returns
|
|
126
|
+
-------
|
|
127
|
+
U : A graph with the same type as the first graph in list
|
|
128
|
+
|
|
129
|
+
Raises
|
|
130
|
+
------
|
|
131
|
+
ValueError
|
|
132
|
+
If `graphs` is an empty list.
|
|
133
|
+
|
|
134
|
+
NetworkXError
|
|
135
|
+
In case of mixed type graphs, like MultiGraph and Graph, or directed and undirected graphs.
|
|
136
|
+
|
|
137
|
+
Examples
|
|
138
|
+
--------
|
|
139
|
+
>>> G1 = nx.Graph([(1, 2), (2, 3)])
|
|
140
|
+
>>> G2 = nx.Graph([(4, 5), (5, 6)])
|
|
141
|
+
>>> U = nx.disjoint_union_all([G1, G2])
|
|
142
|
+
>>> list(U.nodes())
|
|
143
|
+
[0, 1, 2, 3, 4, 5]
|
|
144
|
+
>>> list(U.edges())
|
|
145
|
+
[(0, 1), (1, 2), (3, 4), (4, 5)]
|
|
146
|
+
|
|
147
|
+
Notes
|
|
148
|
+
-----
|
|
149
|
+
For operating on mixed type graphs, they should be converted to the same type.
|
|
150
|
+
|
|
151
|
+
Graph, edge, and node attributes are propagated to the union graph.
|
|
152
|
+
If a graph attribute is present in multiple graphs, then the value
|
|
153
|
+
from the last graph in the list with that attribute is used.
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
def yield_relabeled(graphs):
|
|
157
|
+
first_label = 0
|
|
158
|
+
for G in graphs:
|
|
159
|
+
yield nx.convert_node_labels_to_integers(G, first_label=first_label)
|
|
160
|
+
first_label += len(G)
|
|
161
|
+
|
|
162
|
+
R = union_all(yield_relabeled(graphs))
|
|
163
|
+
|
|
164
|
+
return R
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@nx._dispatchable(graphs="[graphs]", preserve_all_attrs=True, returns_graph=True)
|
|
168
|
+
def compose_all(graphs):
|
|
169
|
+
"""Returns the composition of all graphs.
|
|
170
|
+
|
|
171
|
+
Composition is the simple union of the node sets and edge sets.
|
|
172
|
+
The node sets of the supplied graphs need not be disjoint.
|
|
173
|
+
|
|
174
|
+
Parameters
|
|
175
|
+
----------
|
|
176
|
+
graphs : iterable
|
|
177
|
+
Iterable of NetworkX graphs
|
|
178
|
+
|
|
179
|
+
Returns
|
|
180
|
+
-------
|
|
181
|
+
C : A graph with the same type as the first graph in list
|
|
182
|
+
|
|
183
|
+
Raises
|
|
184
|
+
------
|
|
185
|
+
ValueError
|
|
186
|
+
If `graphs` is an empty list.
|
|
187
|
+
|
|
188
|
+
NetworkXError
|
|
189
|
+
In case of mixed type graphs, like MultiGraph and Graph, or directed and undirected graphs.
|
|
190
|
+
|
|
191
|
+
Examples
|
|
192
|
+
--------
|
|
193
|
+
>>> G1 = nx.Graph([(1, 2), (2, 3)])
|
|
194
|
+
>>> G2 = nx.Graph([(3, 4), (5, 6)])
|
|
195
|
+
>>> C = nx.compose_all([G1, G2])
|
|
196
|
+
>>> list(C.nodes())
|
|
197
|
+
[1, 2, 3, 4, 5, 6]
|
|
198
|
+
>>> list(C.edges())
|
|
199
|
+
[(1, 2), (2, 3), (3, 4), (5, 6)]
|
|
200
|
+
|
|
201
|
+
Notes
|
|
202
|
+
-----
|
|
203
|
+
For operating on mixed type graphs, they should be converted to the same type.
|
|
204
|
+
|
|
205
|
+
Graph, edge, and node attributes are propagated to the union graph.
|
|
206
|
+
If a graph attribute is present in multiple graphs, then the value
|
|
207
|
+
from the last graph in the list with that attribute is used.
|
|
208
|
+
"""
|
|
209
|
+
R = None
|
|
210
|
+
|
|
211
|
+
# add graph attributes, H attributes take precedent over G attributes
|
|
212
|
+
for i, G in enumerate(graphs):
|
|
213
|
+
if i == 0:
|
|
214
|
+
# create new graph
|
|
215
|
+
R = G.__class__()
|
|
216
|
+
elif G.is_directed() != R.is_directed():
|
|
217
|
+
raise nx.NetworkXError("All graphs must be directed or undirected.")
|
|
218
|
+
elif G.is_multigraph() != R.is_multigraph():
|
|
219
|
+
raise nx.NetworkXError("All graphs must be graphs or multigraphs.")
|
|
220
|
+
|
|
221
|
+
R.graph.update(G.graph)
|
|
222
|
+
R.add_nodes_from(G.nodes(data=True))
|
|
223
|
+
R.add_edges_from(
|
|
224
|
+
G.edges(keys=True, data=True) if G.is_multigraph() else G.edges(data=True)
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
if R is None:
|
|
228
|
+
raise ValueError("cannot apply compose_all to an empty list")
|
|
229
|
+
|
|
230
|
+
return R
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@nx._dispatchable(graphs="[graphs]", returns_graph=True)
|
|
234
|
+
def intersection_all(graphs):
|
|
235
|
+
"""Returns a new graph that contains only the nodes and the edges that exist in
|
|
236
|
+
all graphs.
|
|
237
|
+
|
|
238
|
+
Parameters
|
|
239
|
+
----------
|
|
240
|
+
graphs : iterable
|
|
241
|
+
Iterable of NetworkX graphs
|
|
242
|
+
|
|
243
|
+
Returns
|
|
244
|
+
-------
|
|
245
|
+
R : A new graph with the same type as the first graph in list
|
|
246
|
+
|
|
247
|
+
Raises
|
|
248
|
+
------
|
|
249
|
+
ValueError
|
|
250
|
+
If `graphs` is an empty list.
|
|
251
|
+
|
|
252
|
+
NetworkXError
|
|
253
|
+
In case of mixed type graphs, like MultiGraph and Graph, or directed and undirected graphs.
|
|
254
|
+
|
|
255
|
+
Notes
|
|
256
|
+
-----
|
|
257
|
+
For operating on mixed type graphs, they should be converted to the same type.
|
|
258
|
+
|
|
259
|
+
Attributes from the graph, nodes, and edges are not copied to the new
|
|
260
|
+
graph.
|
|
261
|
+
|
|
262
|
+
The resulting graph can be updated with attributes if desired.
|
|
263
|
+
For example, code which adds the minimum attribute for each node across all
|
|
264
|
+
graphs could work::
|
|
265
|
+
|
|
266
|
+
>>> g = nx.Graph()
|
|
267
|
+
>>> g.add_node(0, capacity=4)
|
|
268
|
+
>>> g.add_node(1, capacity=3)
|
|
269
|
+
>>> g.add_edge(0, 1)
|
|
270
|
+
|
|
271
|
+
>>> h = g.copy()
|
|
272
|
+
>>> h.nodes[0]["capacity"] = 2
|
|
273
|
+
|
|
274
|
+
>>> gh = nx.intersection_all([g, h])
|
|
275
|
+
|
|
276
|
+
>>> new_node_attr = {
|
|
277
|
+
... n: min(*(anyG.nodes[n].get("capacity", float("inf")) for anyG in [g, h]))
|
|
278
|
+
... for n in gh
|
|
279
|
+
... }
|
|
280
|
+
>>> nx.set_node_attributes(gh, new_node_attr, "new_capacity")
|
|
281
|
+
>>> gh.nodes(data=True)
|
|
282
|
+
NodeDataView({0: {'new_capacity': 2}, 1: {'new_capacity': 3}})
|
|
283
|
+
|
|
284
|
+
Examples
|
|
285
|
+
--------
|
|
286
|
+
>>> G1 = nx.Graph([(1, 2), (2, 3)])
|
|
287
|
+
>>> G2 = nx.Graph([(2, 3), (3, 4)])
|
|
288
|
+
>>> R = nx.intersection_all([G1, G2])
|
|
289
|
+
>>> list(R.nodes())
|
|
290
|
+
[2, 3]
|
|
291
|
+
>>> list(R.edges())
|
|
292
|
+
[(2, 3)]
|
|
293
|
+
|
|
294
|
+
"""
|
|
295
|
+
R = None
|
|
296
|
+
|
|
297
|
+
for i, G in enumerate(graphs):
|
|
298
|
+
G_nodes_set = set(G.nodes)
|
|
299
|
+
G_edges_set = set(G.edges)
|
|
300
|
+
if not G.is_directed():
|
|
301
|
+
if G.is_multigraph():
|
|
302
|
+
G_edges_set.update((v, u, k) for u, v, k in list(G_edges_set))
|
|
303
|
+
else:
|
|
304
|
+
G_edges_set.update((v, u) for u, v in list(G_edges_set))
|
|
305
|
+
if i == 0:
|
|
306
|
+
# create new graph
|
|
307
|
+
R = G.__class__()
|
|
308
|
+
node_intersection = G_nodes_set
|
|
309
|
+
edge_intersection = G_edges_set
|
|
310
|
+
elif G.is_directed() != R.is_directed():
|
|
311
|
+
raise nx.NetworkXError("All graphs must be directed or undirected.")
|
|
312
|
+
elif G.is_multigraph() != R.is_multigraph():
|
|
313
|
+
raise nx.NetworkXError("All graphs must be graphs or multigraphs.")
|
|
314
|
+
else:
|
|
315
|
+
node_intersection &= G_nodes_set
|
|
316
|
+
edge_intersection &= G_edges_set
|
|
317
|
+
|
|
318
|
+
if R is None:
|
|
319
|
+
raise ValueError("cannot apply intersection_all to an empty list")
|
|
320
|
+
|
|
321
|
+
R.add_nodes_from(node_intersection)
|
|
322
|
+
R.add_edges_from(edge_intersection)
|
|
323
|
+
|
|
324
|
+
return R
|