okstra 0.108.0 → 0.109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/prompts/profiles/_common-contract.md +1 -1
- package/runtime/python/okstra_ctl/graphify_cmd.py +225 -0
- package/runtime/python/okstra_ctl/resolve_task_key.py +15 -9
- package/runtime/python/okstra_project/__init__.py +2 -0
- package/runtime/python/okstra_project/state.py +36 -0
- package/runtime/python/okstra_vendor/__init__.py +41 -0
- package/runtime/python/okstra_vendor/graphify/.vendored-version +1 -0
- package/runtime/python/okstra_vendor/graphify/__init__.py +28 -0
- package/runtime/python/okstra_vendor/graphify/__main__.py +1371 -0
- package/runtime/python/okstra_vendor/graphify/analyze.py +540 -0
- package/runtime/python/okstra_vendor/graphify/benchmark.py +129 -0
- package/runtime/python/okstra_vendor/graphify/build.py +107 -0
- package/runtime/python/okstra_vendor/graphify/cache.py +169 -0
- package/runtime/python/okstra_vendor/graphify/cluster.py +137 -0
- package/runtime/python/okstra_vendor/graphify/detect.py +510 -0
- package/runtime/python/okstra_vendor/graphify/export.py +1014 -0
- package/runtime/python/okstra_vendor/graphify/extract.py +3277 -0
- package/runtime/python/okstra_vendor/graphify/hooks.py +220 -0
- package/runtime/python/okstra_vendor/graphify/ingest.py +297 -0
- package/runtime/python/okstra_vendor/graphify/manifest.py +4 -0
- package/runtime/python/okstra_vendor/graphify/report.py +175 -0
- package/runtime/python/okstra_vendor/graphify/security.py +203 -0
- package/runtime/python/okstra_vendor/graphify/serve.py +373 -0
- package/runtime/python/okstra_vendor/graphify/skill-aider.md +1184 -0
- package/runtime/python/okstra_vendor/graphify/skill-claw.md +1184 -0
- package/runtime/python/okstra_vendor/graphify/skill-codex.md +1242 -0
- package/runtime/python/okstra_vendor/graphify/skill-copilot.md +1268 -0
- package/runtime/python/okstra_vendor/graphify/skill-droid.md +1239 -0
- package/runtime/python/okstra_vendor/graphify/skill-kiro.md +1183 -0
- package/runtime/python/okstra_vendor/graphify/skill-opencode.md +1238 -0
- package/runtime/python/okstra_vendor/graphify/skill-trae.md +1208 -0
- package/runtime/python/okstra_vendor/graphify/skill-vscode.md +253 -0
- package/runtime/python/okstra_vendor/graphify/skill-windows.md +1245 -0
- package/runtime/python/okstra_vendor/graphify/skill.md +1319 -0
- package/runtime/python/okstra_vendor/graphify/transcribe.py +182 -0
- package/runtime/python/okstra_vendor/graphify/validate.py +72 -0
- package/runtime/python/okstra_vendor/graphify/watch.py +188 -0
- package/runtime/python/okstra_vendor/graphify/wiki.py +214 -0
- package/runtime/python/okstra_vendor/networkx/__init__.py +62 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +134 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +26 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +259 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +71 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +412 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +396 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +150 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +149 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +369 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +44 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +143 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +53 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +265 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py +41 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_clique.py +112 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_connectivity.py +199 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_density.py +146 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_distance_measures.py +59 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_dominating_set.py +78 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_kcomponents.py +303 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_matching.py +8 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_maxcut.py +94 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_ramsey.py +31 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_steinertree.py +306 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_traveling_salesman.py +1014 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_treewidth.py +274 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/tests/test_vertex_cover.py +68 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +1508 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +255 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +83 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +5 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +122 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +302 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +255 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +160 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +127 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/base_test.py +81 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_connectivity.py +143 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_correlation.py +122 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_mixing.py +174 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_neighbor_degree.py +107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/tests/test_pairs.py +87 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +164 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +322 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +290 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +289 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +57 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +360 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +105 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +603 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +316 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +590 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +232 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +526 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +112 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +69 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_basic.py +125 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_centrality.py +192 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_cluster.py +84 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_covering.py +33 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_edgelist.py +240 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_extendability.py +334 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_generators.py +407 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_link_analysis.py +218 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matching.py +327 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_matrix.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_project.py +409 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_redundancy.py +35 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py +80 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +168 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +205 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +164 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +20 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +591 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +236 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +282 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +364 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +227 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +96 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +150 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +357 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +130 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +787 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +331 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +150 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +200 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +128 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +209 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +141 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +361 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality.py +923 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py +354 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_closeness_centrality.py +274 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality.py +259 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality_subset.py +147 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_current_flow_closeness.py +43 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_degree_centrality.py +144 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_dispersion.py +73 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py +186 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_group.py +277 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_harmonic_centrality.py +122 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_katz_centrality.py +345 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_laplacian_centrality.py +220 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_load_centrality.py +344 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_percolation_centrality.py +87 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_reaching.py +140 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_second_order_centrality.py +82 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_subgraph.py +110 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_trophic.py +302 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/tests/test_voterank.py +64 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +181 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +95 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +172 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +443 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +818 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +732 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +4 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +505 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +565 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/tests/test_coloring.py +863 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +163 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +28 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +153 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +354 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +171 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +30 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +216 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +79 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +338 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +162 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +220 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +384 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +227 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +452 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +347 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_asyn_fluid.py +147 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_bipartitions.py +157 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_centrality.py +85 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_divisive.py +106 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_kclique.py +91 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_label_propagation.py +241 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_leiden.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_local.py +76 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_louvain.py +264 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_lukes.py +152 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_modularity_max.py +340 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_quality.py +139 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/community/tests/test_utils.py +26 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +6 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +115 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +394 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +282 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +71 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +359 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_attracting.py +70 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_biconnected.py +248 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_connected.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_semiconnected.py +55 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_strongly_connected.py +193 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/tests/test_weakly_connected.py +96 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +196 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +11 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +811 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +616 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +408 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +1270 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +592 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +220 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +235 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +152 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_connectivity.py +421 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_cuts.py +309 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_disjoint_paths.py +249 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_augmentation.py +502 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_edge_kcomponents.py +488 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcomponents.py +323 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_kcutsets.py +280 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/tests/test_stoer_wagner.py +102 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/core.py +588 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +142 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +416 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +1234 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +677 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +1392 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +1095 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +272 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +142 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +268 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +167 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +470 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +11 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +370 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +407 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +238 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +241 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +178 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +611 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +356 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +662 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +425 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +300 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gl1.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/gw1.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/netgen-2.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_gomory_hu.py +128 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow.py +573 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_maxflow_large_graph.py +155 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_mincost.py +475 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/test_networksimplex.py +481 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/tests/wlm3.gpickle.bz2 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +194 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +435 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +483 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +57 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +196 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +7 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +1306 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +336 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +1262 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +352 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +308 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.A99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/iso_r01_s80.B99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.A99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/si2_b06_m200.B99 +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_ismags.py +719 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphism.py +103 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py +490 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_match_helpers.py +64 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_temporalisomorphvf2.py +212 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_tree_isomorphism.py +202 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp.py +1655 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2pp_helpers.py +3118 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py +196 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +264 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +1102 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +192 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +2 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +337 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +498 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_hits.py +77 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/tests/test_pagerank.py +213 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +687 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +280 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +1148 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +27 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +738 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/tests/test_contraction.py +544 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +78 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +59 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +219 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +155 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +4 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +324 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +468 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +633 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_all.py +328 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_binary.py +451 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_product.py +491 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/tests/test_unary.py +55 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +77 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +73 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +464 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +1463 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +306 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +98 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +167 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +5 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +239 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +264 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +716 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_astar.py +254 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense.py +212 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_dense_numpy.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_generic.py +511 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_unweighted.py +149 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/tests/test_weighted.py +983 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +625 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +2542 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +2107 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +966 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +404 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +30 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +296 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +374 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +564 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +406 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_asteroidal.py +23 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_boundary.py +154 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_bridges.py +144 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_broadcasting.py +109 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chains.py +136 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_chordal.py +129 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_clique.py +300 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cluster.py +678 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_communicability.py +80 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_core.py +266 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_covering.py +85 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cuts.py +171 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_cycles.py +984 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_d_separation.py +340 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dag.py +835 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_measures.py +831 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_distance_regular.py +85 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominance.py +299 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_dominating.py +115 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_efficiency.py +58 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_euler.py +314 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graph_hashing.py +872 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_graphical.py +163 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hierarchy.py +46 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_hybrid.py +24 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_isolate.py +26 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_link_prediction.py +615 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_lowest_common_ancestors.py +459 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_matching.py +556 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_max_weight_clique.py +179 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_mis.py +62 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_moral.py +15 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_node_classification.py +140 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_non_randomness.py +60 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_perfect_graph.py +27 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planar_drawing.py +274 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_planarity.py +556 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_polynomials.py +57 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_reciprocity.py +37 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_regular.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_richclub.py +149 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_similarity.py +1158 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_simple_paths.py +803 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smallworld.py +76 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_smetric.py +8 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_sparsifiers.py +138 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_structuralholes.py +191 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_summarization.py +642 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_swap.py +179 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_threshold.py +270 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_time_dependent.py +431 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_tournament.py +161 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_triads.py +248 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_vitality.py +41 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_voronoi.py +103 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_walks.py +54 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tests/test_wiener.py +157 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +981 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +142 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +406 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +5 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +90 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +576 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +529 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +185 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +182 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_beamsearch.py +25 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_bfs.py +203 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_dfs.py +307 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgebfs.py +147 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/tests/test_edgedfs.py +131 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +7 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +1042 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +413 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +88 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +219 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +1281 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +106 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +273 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_branchings.py +624 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_coding.py +114 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_decomposition.py +79 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_distance_measures.py +99 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_mst.py +934 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_operations.py +53 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/tests/test_recognition.py +174 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +500 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +76 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +86 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +77 -0
- package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +278 -0
- package/runtime/python/okstra_vendor/networkx/classes/__init__.py +13 -0
- package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +435 -0
- package/runtime/python/okstra_vendor/networkx/classes/digraph.py +1363 -0
- package/runtime/python/okstra_vendor/networkx/classes/filters.py +95 -0
- package/runtime/python/okstra_vendor/networkx/classes/function.py +1549 -0
- package/runtime/python/okstra_vendor/networkx/classes/graph.py +2082 -0
- package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +269 -0
- package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +977 -0
- package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +1294 -0
- package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +1447 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/dispatch_interface.py +192 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/historical_tests.py +476 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_coreviews.py +362 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph.py +331 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_digraph_historical.py +110 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_filters.py +177 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_function.py +1045 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph.py +950 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graph_historical.py +12 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_graphviews.py +349 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_multidigraph.py +459 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_multigraph.py +528 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_reportviews.py +1421 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_special.py +131 -0
- package/runtime/python/okstra_vendor/networkx/classes/tests/test_subgraphviews.py +371 -0
- package/runtime/python/okstra_vendor/networkx/conftest.py +261 -0
- package/runtime/python/okstra_vendor/networkx/convert.py +502 -0
- package/runtime/python/okstra_vendor/networkx/convert_matrix.py +1314 -0
- package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +7 -0
- package/runtime/python/okstra_vendor/networkx/drawing/layout.py +2036 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +470 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +570 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +361 -0
- package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +2978 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_complex.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_empty_graph.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_house_with_colors.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_labels_and_colors.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_display_shortest_path.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/baseline/test_house_with_colors.png +0 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_agraph.py +237 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_image_comparison_pylab_mpl.py +229 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_latex.py +285 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_layout.py +631 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pydot.py +146 -0
- package/runtime/python/okstra_vendor/networkx/drawing/tests/test_pylab.py +1582 -0
- package/runtime/python/okstra_vendor/networkx/exception.py +131 -0
- package/runtime/python/okstra_vendor/networkx/generators/__init__.py +34 -0
- package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
- package/runtime/python/okstra_vendor/networkx/generators/atlas.py +227 -0
- package/runtime/python/okstra_vendor/networkx/generators/classic.py +1091 -0
- package/runtime/python/okstra_vendor/networkx/generators/cographs.py +68 -0
- package/runtime/python/okstra_vendor/networkx/generators/community.py +1070 -0
- package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +886 -0
- package/runtime/python/okstra_vendor/networkx/generators/directed.py +572 -0
- package/runtime/python/okstra_vendor/networkx/generators/duplication.py +174 -0
- package/runtime/python/okstra_vendor/networkx/generators/ego.py +66 -0
- package/runtime/python/okstra_vendor/networkx/generators/expanders.py +499 -0
- package/runtime/python/okstra_vendor/networkx/generators/geometric.py +1037 -0
- package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +163 -0
- package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +443 -0
- package/runtime/python/okstra_vendor/networkx/generators/intersection.py +125 -0
- package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +70 -0
- package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +664 -0
- package/runtime/python/okstra_vendor/networkx/generators/lattice.py +405 -0
- package/runtime/python/okstra_vendor/networkx/generators/line.py +501 -0
- package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +110 -0
- package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +259 -0
- package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +117 -0
- package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +1416 -0
- package/runtime/python/okstra_vendor/networkx/generators/small.py +1070 -0
- package/runtime/python/okstra_vendor/networkx/generators/social.py +554 -0
- package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +120 -0
- package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +54 -0
- package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +131 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_atlas.py +75 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_classic.py +642 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_cographs.py +20 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_community.py +362 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_degree_seq.py +224 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_directed.py +189 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_duplication.py +103 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_ego.py +39 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_expanders.py +182 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_geometric.py +488 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_harary_graph.py +133 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_internet_as_graphs.py +221 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_intersection.py +28 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_interval_graph.py +144 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_joint_degree_seq.py +125 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_lattice.py +264 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_line.py +316 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_mycielski.py +30 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_nonisomorphic_trees.py +82 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_clustered.py +33 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_random_graphs.py +495 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_small.py +220 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_spectral_graph_forge.py +49 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_stochastic.py +72 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_sudoku.py +92 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_time_series.py +64 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_trees.py +195 -0
- package/runtime/python/okstra_vendor/networkx/generators/tests/test_triads.py +15 -0
- package/runtime/python/okstra_vendor/networkx/generators/time_series.py +74 -0
- package/runtime/python/okstra_vendor/networkx/generators/trees.py +1070 -0
- package/runtime/python/okstra_vendor/networkx/generators/triads.py +94 -0
- package/runtime/python/okstra_vendor/networkx/lazy_imports.py +188 -0
- package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +13 -0
- package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +650 -0
- package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +466 -0
- package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +77 -0
- package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +168 -0
- package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +512 -0
- package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +166 -0
- package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +186 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_algebraic_connectivity.py +400 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_attrmatrix.py +108 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_bethehessian.py +40 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_graphmatrix.py +275 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_laplacian.py +334 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_modularity.py +86 -0
- package/runtime/python/okstra_vendor/networkx/linalg/tests/test_spectrum.py +70 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +17 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +330 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +489 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +1084 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +879 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +427 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +1053 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +19 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +156 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +190 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +261 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_adjacency.py +78 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_cytoscape.py +78 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_node_link.py +109 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tests/test_tree.py +48 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +137 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +108 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +393 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +113 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +286 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +379 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_adjlist.py +354 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_edgelist.py +318 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gexf.py +612 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_gml.py +744 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graph6.py +181 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_graphml.py +1531 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_leda.py +30 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_p2g.py +63 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_pajek.py +128 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_sparse6.py +166 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/tests/test_text.py +1742 -0
- package/runtime/python/okstra_vendor/networkx/readwrite/text.py +851 -0
- package/runtime/python/okstra_vendor/networkx/relabel.py +285 -0
- package/runtime/python/okstra_vendor/networkx/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_all_random_functions.py +248 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert.py +321 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_numpy.py +531 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_pandas.py +349 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_convert_scipy.py +281 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_exceptions.py +40 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_import.py +11 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_lazy_imports.py +96 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_relabel.py +349 -0
- package/runtime/python/okstra_vendor/networkx/tests/test_removed_functions_exception_messages.py +8 -0
- package/runtime/python/okstra_vendor/networkx/utils/__init__.py +8 -0
- package/runtime/python/okstra_vendor/networkx/utils/backends.py +2171 -0
- package/runtime/python/okstra_vendor/networkx/utils/configs.py +396 -0
- package/runtime/python/okstra_vendor/networkx/utils/decorators.py +1233 -0
- package/runtime/python/okstra_vendor/networkx/utils/heaps.py +338 -0
- package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +297 -0
- package/runtime/python/okstra_vendor/networkx/utils/misc.py +703 -0
- package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +198 -0
- package/runtime/python/okstra_vendor/networkx/utils/rcm.py +159 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/__init__.py +0 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test__init.py +11 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_backends.py +225 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_config.py +263 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_decorators.py +510 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_heaps.py +131 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_mapped_queue.py +268 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_misc.py +393 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_random_sequence.py +53 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_rcm.py +63 -0
- package/runtime/python/okstra_vendor/networkx/utils/tests/test_unionfind.py +55 -0
- package/runtime/python/okstra_vendor/networkx/utils/union_find.py +106 -0
- package/runtime/skills/okstra-graphify/SKILL.md +161 -0
- package/runtime/skills/okstra-inspect/SKILL.md +17 -9
- package/runtime/templates/reports/settings.template.json +4 -0
- package/src/cli-registry.mjs +7 -0
- package/src/commands/graphify.mjs +32 -0
- package/src/commands/lifecycle/doctor.mjs +9 -0
- package/src/lib/skill-catalog.mjs +1 -0
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Functions for constructing matrix-like objects from graph attributes.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
|
|
7
|
+
__all__ = ["attr_matrix", "attr_sparse_matrix"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _node_value(G, node_attr):
|
|
11
|
+
"""Returns a function that returns a value from G.nodes[u].
|
|
12
|
+
|
|
13
|
+
We return a function expecting a node as its sole argument. Then, in the
|
|
14
|
+
simplest scenario, the returned function will return G.nodes[u][node_attr].
|
|
15
|
+
However, we also handle the case when `node_attr` is None (returns the node)
|
|
16
|
+
or when `node_attr` is a function itself.
|
|
17
|
+
|
|
18
|
+
Parameters
|
|
19
|
+
----------
|
|
20
|
+
G : graph
|
|
21
|
+
A NetworkX graph
|
|
22
|
+
|
|
23
|
+
node_attr : {None, str, callable}
|
|
24
|
+
Specification of how the value of the node attribute should be obtained
|
|
25
|
+
from the node attribute dictionary.
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
value : function
|
|
30
|
+
A function expecting a node as its sole argument. The function will
|
|
31
|
+
returns a value from G.nodes[u] that depends on `edge_attr`.
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
if node_attr is None:
|
|
35
|
+
|
|
36
|
+
def value(u):
|
|
37
|
+
return u
|
|
38
|
+
|
|
39
|
+
elif not callable(node_attr):
|
|
40
|
+
# assume it is a key for the node attribute dictionary
|
|
41
|
+
def value(u):
|
|
42
|
+
return G.nodes[u][node_attr]
|
|
43
|
+
|
|
44
|
+
else:
|
|
45
|
+
# Advanced: Allow users to specify something else.
|
|
46
|
+
#
|
|
47
|
+
# For example,
|
|
48
|
+
# node_attr = lambda u: G.nodes[u].get('size', .5) * 3
|
|
49
|
+
#
|
|
50
|
+
value = node_attr
|
|
51
|
+
|
|
52
|
+
return value
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _edge_value(G, edge_attr):
|
|
56
|
+
"""Returns a function that returns a value from G[u][v].
|
|
57
|
+
|
|
58
|
+
Suppose there exists an edge between u and v. Then we return a function
|
|
59
|
+
expecting u and v as arguments. For Graph and DiGraph, G[u][v] is
|
|
60
|
+
the edge attribute dictionary, and the function (essentially) returns
|
|
61
|
+
G[u][v][edge_attr]. However, we also handle cases when `edge_attr` is None
|
|
62
|
+
and when it is a function itself. For MultiGraph and MultiDiGraph, G[u][v]
|
|
63
|
+
is a dictionary of all edges between u and v. In this case, the returned
|
|
64
|
+
function sums the value of `edge_attr` for every edge between u and v.
|
|
65
|
+
|
|
66
|
+
Parameters
|
|
67
|
+
----------
|
|
68
|
+
G : graph
|
|
69
|
+
A NetworkX graph
|
|
70
|
+
|
|
71
|
+
edge_attr : {None, str, callable}
|
|
72
|
+
Specification of how the value of the edge attribute should be obtained
|
|
73
|
+
from the edge attribute dictionary, G[u][v]. For multigraphs, G[u][v]
|
|
74
|
+
is a dictionary of all the edges between u and v. This allows for
|
|
75
|
+
special treatment of multiedges.
|
|
76
|
+
|
|
77
|
+
Returns
|
|
78
|
+
-------
|
|
79
|
+
value : function
|
|
80
|
+
A function expecting two nodes as parameters. The nodes should
|
|
81
|
+
represent the from- and to- node of an edge. The function will
|
|
82
|
+
return a value from G[u][v] that depends on `edge_attr`.
|
|
83
|
+
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
if edge_attr is None:
|
|
87
|
+
# topological count of edges
|
|
88
|
+
|
|
89
|
+
if G.is_multigraph():
|
|
90
|
+
|
|
91
|
+
def value(u, v):
|
|
92
|
+
return len(G[u][v])
|
|
93
|
+
|
|
94
|
+
else:
|
|
95
|
+
|
|
96
|
+
def value(u, v):
|
|
97
|
+
return 1
|
|
98
|
+
|
|
99
|
+
elif not callable(edge_attr):
|
|
100
|
+
# assume it is a key for the edge attribute dictionary
|
|
101
|
+
|
|
102
|
+
if edge_attr == "weight":
|
|
103
|
+
# provide a default value
|
|
104
|
+
if G.is_multigraph():
|
|
105
|
+
|
|
106
|
+
def value(u, v):
|
|
107
|
+
return sum(d.get(edge_attr, 1) for d in G[u][v].values())
|
|
108
|
+
|
|
109
|
+
else:
|
|
110
|
+
|
|
111
|
+
def value(u, v):
|
|
112
|
+
return G[u][v].get(edge_attr, 1)
|
|
113
|
+
|
|
114
|
+
else:
|
|
115
|
+
# otherwise, the edge attribute MUST exist for each edge
|
|
116
|
+
if G.is_multigraph():
|
|
117
|
+
|
|
118
|
+
def value(u, v):
|
|
119
|
+
return sum(d[edge_attr] for d in G[u][v].values())
|
|
120
|
+
|
|
121
|
+
else:
|
|
122
|
+
|
|
123
|
+
def value(u, v):
|
|
124
|
+
return G[u][v][edge_attr]
|
|
125
|
+
|
|
126
|
+
else:
|
|
127
|
+
# Advanced: Allow users to specify something else.
|
|
128
|
+
#
|
|
129
|
+
# Alternative default value:
|
|
130
|
+
# edge_attr = lambda u,v: G[u][v].get('thickness', .5)
|
|
131
|
+
#
|
|
132
|
+
# Function on an attribute:
|
|
133
|
+
# edge_attr = lambda u,v: abs(G[u][v]['weight'])
|
|
134
|
+
#
|
|
135
|
+
# Handle Multi(Di)Graphs differently:
|
|
136
|
+
# edge_attr = lambda u,v: numpy.prod([d['size'] for d in G[u][v].values()])
|
|
137
|
+
#
|
|
138
|
+
# Ignore multiple edges
|
|
139
|
+
# edge_attr = lambda u,v: 1 if len(G[u][v]) else 0
|
|
140
|
+
#
|
|
141
|
+
value = edge_attr
|
|
142
|
+
|
|
143
|
+
return value
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@nx._dispatchable(edge_attrs={"edge_attr": None}, node_attrs="node_attr")
|
|
147
|
+
def attr_matrix(
|
|
148
|
+
G,
|
|
149
|
+
edge_attr=None,
|
|
150
|
+
node_attr=None,
|
|
151
|
+
normalized=False,
|
|
152
|
+
rc_order=None,
|
|
153
|
+
dtype=None,
|
|
154
|
+
order=None,
|
|
155
|
+
):
|
|
156
|
+
"""Returns the attribute matrix using attributes from `G` as a numpy array.
|
|
157
|
+
|
|
158
|
+
If only `G` is passed in, then the adjacency matrix is constructed.
|
|
159
|
+
|
|
160
|
+
Let A be a discrete set of values for the node attribute `node_attr`. Then
|
|
161
|
+
the elements of A represent the rows and columns of the constructed matrix.
|
|
162
|
+
Now, iterate through every edge e=(u,v) in `G` and consider the value
|
|
163
|
+
of the edge attribute `edge_attr`. If ua and va are the values of the
|
|
164
|
+
node attribute `node_attr` for u and v, respectively, then the value of
|
|
165
|
+
the edge attribute is added to the matrix element at (ua, va).
|
|
166
|
+
|
|
167
|
+
Parameters
|
|
168
|
+
----------
|
|
169
|
+
G : graph
|
|
170
|
+
The NetworkX graph used to construct the attribute matrix.
|
|
171
|
+
|
|
172
|
+
edge_attr : str, optional (default: number of edges for each matrix element)
|
|
173
|
+
Each element of the matrix represents a running total of the
|
|
174
|
+
specified edge attribute for edges whose node attributes correspond
|
|
175
|
+
to the rows/cols of the matrix. The attribute must be present for
|
|
176
|
+
all edges in the graph. If no attribute is specified, then we
|
|
177
|
+
just count the number of edges whose node attributes correspond
|
|
178
|
+
to the matrix element.
|
|
179
|
+
|
|
180
|
+
node_attr : str, optional (default: use nodes of the graph)
|
|
181
|
+
Each row and column in the matrix represents a particular value
|
|
182
|
+
of the node attribute. The attribute must be present for all nodes
|
|
183
|
+
in the graph. Note, the values of this attribute should be reliably
|
|
184
|
+
hashable. So, float values are not recommended. If no attribute is
|
|
185
|
+
specified, then the rows and columns will be the nodes of the graph.
|
|
186
|
+
|
|
187
|
+
normalized : bool, optional (default: False)
|
|
188
|
+
If True, then each row is normalized by the summation of its values.
|
|
189
|
+
|
|
190
|
+
rc_order : list, optional (default: order of nodes in G)
|
|
191
|
+
A list of the node attribute values. This list specifies the ordering
|
|
192
|
+
of rows and columns of the array. If no ordering is provided, then
|
|
193
|
+
the ordering will be the same as the node order in `G`.
|
|
194
|
+
When `rc_order` is `None`, the function returns a 2-tuple ``(matrix, ordering)``
|
|
195
|
+
|
|
196
|
+
Other Parameters
|
|
197
|
+
----------------
|
|
198
|
+
dtype : NumPy data-type, optional
|
|
199
|
+
A valid NumPy dtype used to initialize the array. Keep in mind certain
|
|
200
|
+
dtypes can yield unexpected results if the array is to be normalized.
|
|
201
|
+
The parameter is passed to numpy.zeros(). If unspecified, the NumPy
|
|
202
|
+
default is used.
|
|
203
|
+
|
|
204
|
+
order : {'C', 'F'}, optional
|
|
205
|
+
Whether to store multidimensional data in C- or Fortran-contiguous
|
|
206
|
+
(row- or column-wise) order in memory. This parameter is passed to
|
|
207
|
+
numpy.zeros(). If unspecified, the NumPy default is used.
|
|
208
|
+
|
|
209
|
+
Returns
|
|
210
|
+
-------
|
|
211
|
+
M : 2D NumPy ndarray
|
|
212
|
+
The attribute matrix.
|
|
213
|
+
|
|
214
|
+
ordering : list
|
|
215
|
+
If `rc_order` was specified, then only the attribute matrix is returned.
|
|
216
|
+
However, if `rc_order` was None, then the ordering used to construct
|
|
217
|
+
the matrix is returned as well.
|
|
218
|
+
|
|
219
|
+
Examples
|
|
220
|
+
--------
|
|
221
|
+
Construct an adjacency matrix:
|
|
222
|
+
|
|
223
|
+
>>> G = nx.Graph()
|
|
224
|
+
>>> G.add_edge(0, 1, thickness=1, weight=3)
|
|
225
|
+
>>> G.add_edge(0, 2, thickness=2)
|
|
226
|
+
>>> G.add_edge(1, 2, thickness=3)
|
|
227
|
+
>>> nx.attr_matrix(G, rc_order=[0, 1, 2])
|
|
228
|
+
array([[0., 1., 1.],
|
|
229
|
+
[1., 0., 1.],
|
|
230
|
+
[1., 1., 0.]])
|
|
231
|
+
|
|
232
|
+
Alternatively, we can obtain the matrix describing edge thickness.
|
|
233
|
+
|
|
234
|
+
>>> nx.attr_matrix(G, edge_attr="thickness", rc_order=[0, 1, 2])
|
|
235
|
+
array([[0., 1., 2.],
|
|
236
|
+
[1., 0., 3.],
|
|
237
|
+
[2., 3., 0.]])
|
|
238
|
+
|
|
239
|
+
We can also color the nodes and ask for the probability distribution over
|
|
240
|
+
all edges (u,v) describing:
|
|
241
|
+
|
|
242
|
+
Pr(v has color Y | u has color X)
|
|
243
|
+
|
|
244
|
+
>>> G.nodes[0]["color"] = "red"
|
|
245
|
+
>>> G.nodes[1]["color"] = "red"
|
|
246
|
+
>>> G.nodes[2]["color"] = "blue"
|
|
247
|
+
>>> rc = ["red", "blue"]
|
|
248
|
+
>>> nx.attr_matrix(G, node_attr="color", normalized=True, rc_order=rc)
|
|
249
|
+
array([[0.33333333, 0.66666667],
|
|
250
|
+
[1. , 0. ]])
|
|
251
|
+
|
|
252
|
+
For example, the above tells us that for all edges (u,v):
|
|
253
|
+
|
|
254
|
+
Pr( v is red | u is red) = 1/3
|
|
255
|
+
Pr( v is blue | u is red) = 2/3
|
|
256
|
+
|
|
257
|
+
Pr( v is red | u is blue) = 1
|
|
258
|
+
Pr( v is blue | u is blue) = 0
|
|
259
|
+
|
|
260
|
+
Finally, we can obtain the total weights listed by the node colors.
|
|
261
|
+
|
|
262
|
+
>>> nx.attr_matrix(G, edge_attr="weight", node_attr="color", rc_order=rc)
|
|
263
|
+
array([[3., 2.],
|
|
264
|
+
[2., 0.]])
|
|
265
|
+
|
|
266
|
+
Thus, the total weight over all edges (u,v) with u and v having colors:
|
|
267
|
+
|
|
268
|
+
(red, red) is 3 # the sole contribution is from edge (0,1)
|
|
269
|
+
(red, blue) is 2 # contributions from edges (0,2) and (1,2)
|
|
270
|
+
(blue, red) is 2 # same as (red, blue) since graph is undirected
|
|
271
|
+
(blue, blue) is 0 # there are no edges with blue endpoints
|
|
272
|
+
|
|
273
|
+
"""
|
|
274
|
+
import numpy as np
|
|
275
|
+
|
|
276
|
+
edge_value = _edge_value(G, edge_attr)
|
|
277
|
+
node_value = _node_value(G, node_attr)
|
|
278
|
+
|
|
279
|
+
if rc_order is None:
|
|
280
|
+
ordering = list({node_value(n) for n in G})
|
|
281
|
+
else:
|
|
282
|
+
ordering = rc_order
|
|
283
|
+
|
|
284
|
+
N = len(ordering)
|
|
285
|
+
undirected = not G.is_directed()
|
|
286
|
+
index = dict(zip(ordering, range(N)))
|
|
287
|
+
M = np.zeros((N, N), dtype=dtype, order=order)
|
|
288
|
+
|
|
289
|
+
seen = set()
|
|
290
|
+
for u, nbrdict in G.adjacency():
|
|
291
|
+
for v in nbrdict:
|
|
292
|
+
# Obtain the node attribute values.
|
|
293
|
+
i, j = index[node_value(u)], index[node_value(v)]
|
|
294
|
+
if v not in seen:
|
|
295
|
+
M[i, j] += edge_value(u, v)
|
|
296
|
+
if undirected:
|
|
297
|
+
M[j, i] = M[i, j]
|
|
298
|
+
|
|
299
|
+
if undirected:
|
|
300
|
+
seen.add(u)
|
|
301
|
+
|
|
302
|
+
if normalized:
|
|
303
|
+
M /= M.sum(axis=1).reshape((N, 1))
|
|
304
|
+
|
|
305
|
+
if rc_order is None:
|
|
306
|
+
return M, ordering
|
|
307
|
+
else:
|
|
308
|
+
return M
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
@nx._dispatchable(edge_attrs={"edge_attr": None}, node_attrs="node_attr")
|
|
312
|
+
def attr_sparse_matrix(
|
|
313
|
+
G, edge_attr=None, node_attr=None, normalized=False, rc_order=None, dtype=None
|
|
314
|
+
):
|
|
315
|
+
"""Returns a SciPy sparse array using attributes from G.
|
|
316
|
+
|
|
317
|
+
If only `G` is passed in, then the adjacency matrix is constructed.
|
|
318
|
+
|
|
319
|
+
Let A be a discrete set of values for the node attribute `node_attr`. Then
|
|
320
|
+
the elements of A represent the rows and columns of the constructed matrix.
|
|
321
|
+
Now, iterate through every edge e=(u,v) in `G` and consider the value
|
|
322
|
+
of the edge attribute `edge_attr`. If ua and va are the values of the
|
|
323
|
+
node attribute `node_attr` for u and v, respectively, then the value of
|
|
324
|
+
the edge attribute is added to the matrix element at (ua, va).
|
|
325
|
+
|
|
326
|
+
Parameters
|
|
327
|
+
----------
|
|
328
|
+
G : graph
|
|
329
|
+
The NetworkX graph used to construct the NumPy matrix.
|
|
330
|
+
|
|
331
|
+
edge_attr : str, optional (default: number of edges for each matrix element)
|
|
332
|
+
Each element of the matrix represents a running total of the
|
|
333
|
+
specified edge attribute for edges whose node attributes correspond
|
|
334
|
+
to the rows/cols of the matrix. The attribute must be present for
|
|
335
|
+
all edges in the graph. If no attribute is specified, then we
|
|
336
|
+
just count the number of edges whose node attributes correspond
|
|
337
|
+
to the matrix element.
|
|
338
|
+
|
|
339
|
+
node_attr : str, optional (default: use nodes of the graph)
|
|
340
|
+
Each row and column in the matrix represents a particular value
|
|
341
|
+
of the node attribute. The attribute must be present for all nodes
|
|
342
|
+
in the graph. Note, the values of this attribute should be reliably
|
|
343
|
+
hashable. So, float values are not recommended. If no attribute is
|
|
344
|
+
specified, then the rows and columns will be the nodes of the graph.
|
|
345
|
+
|
|
346
|
+
normalized : bool, optional (default: False)
|
|
347
|
+
If True, then each row is normalized by the summation of its values.
|
|
348
|
+
|
|
349
|
+
rc_order : list, optional (default: order of nodes in G)
|
|
350
|
+
A list of the node attribute values. This list specifies the ordering
|
|
351
|
+
of rows and columns of the array and the return value. If no ordering
|
|
352
|
+
is provided, then the ordering will be that of nodes in `G`.
|
|
353
|
+
|
|
354
|
+
Other Parameters
|
|
355
|
+
----------------
|
|
356
|
+
dtype : NumPy data-type, optional
|
|
357
|
+
A valid NumPy dtype used to initialize the array. Keep in mind certain
|
|
358
|
+
dtypes can yield unexpected results if the array is to be normalized.
|
|
359
|
+
The parameter is passed to numpy.zeros(). If unspecified, the NumPy
|
|
360
|
+
default is used.
|
|
361
|
+
|
|
362
|
+
Returns
|
|
363
|
+
-------
|
|
364
|
+
M : SciPy sparse array
|
|
365
|
+
The attribute matrix.
|
|
366
|
+
|
|
367
|
+
ordering : list
|
|
368
|
+
If `rc_order` was specified, then only the matrix is returned.
|
|
369
|
+
However, if `rc_order` was None, then the ordering used to construct
|
|
370
|
+
the matrix is returned as well.
|
|
371
|
+
|
|
372
|
+
Examples
|
|
373
|
+
--------
|
|
374
|
+
Construct an adjacency matrix:
|
|
375
|
+
|
|
376
|
+
>>> G = nx.Graph()
|
|
377
|
+
>>> G.add_edge(0, 1, thickness=1, weight=3)
|
|
378
|
+
>>> G.add_edge(0, 2, thickness=2)
|
|
379
|
+
>>> G.add_edge(1, 2, thickness=3)
|
|
380
|
+
>>> M = nx.attr_sparse_matrix(G, rc_order=[0, 1, 2])
|
|
381
|
+
>>> M.toarray()
|
|
382
|
+
array([[0., 1., 1.],
|
|
383
|
+
[1., 0., 1.],
|
|
384
|
+
[1., 1., 0.]])
|
|
385
|
+
|
|
386
|
+
Alternatively, we can obtain the matrix describing edge thickness.
|
|
387
|
+
|
|
388
|
+
>>> M = nx.attr_sparse_matrix(G, edge_attr="thickness", rc_order=[0, 1, 2])
|
|
389
|
+
>>> M.toarray()
|
|
390
|
+
array([[0., 1., 2.],
|
|
391
|
+
[1., 0., 3.],
|
|
392
|
+
[2., 3., 0.]])
|
|
393
|
+
|
|
394
|
+
We can also color the nodes and ask for the probability distribution over
|
|
395
|
+
all edges (u,v) describing:
|
|
396
|
+
|
|
397
|
+
Pr(v has color Y | u has color X)
|
|
398
|
+
|
|
399
|
+
>>> G.nodes[0]["color"] = "red"
|
|
400
|
+
>>> G.nodes[1]["color"] = "red"
|
|
401
|
+
>>> G.nodes[2]["color"] = "blue"
|
|
402
|
+
>>> rc = ["red", "blue"]
|
|
403
|
+
>>> M = nx.attr_sparse_matrix(G, node_attr="color", normalized=True, rc_order=rc)
|
|
404
|
+
>>> M.toarray()
|
|
405
|
+
array([[0.33333333, 0.66666667],
|
|
406
|
+
[1. , 0. ]])
|
|
407
|
+
|
|
408
|
+
For example, the above tells us that for all edges (u,v):
|
|
409
|
+
|
|
410
|
+
Pr( v is red | u is red) = 1/3
|
|
411
|
+
Pr( v is blue | u is red) = 2/3
|
|
412
|
+
|
|
413
|
+
Pr( v is red | u is blue) = 1
|
|
414
|
+
Pr( v is blue | u is blue) = 0
|
|
415
|
+
|
|
416
|
+
Finally, we can obtain the total weights listed by the node colors.
|
|
417
|
+
|
|
418
|
+
>>> M = nx.attr_sparse_matrix(G, edge_attr="weight", node_attr="color", rc_order=rc)
|
|
419
|
+
>>> M.toarray()
|
|
420
|
+
array([[3., 2.],
|
|
421
|
+
[2., 0.]])
|
|
422
|
+
|
|
423
|
+
Thus, the total weight over all edges (u,v) with u and v having colors:
|
|
424
|
+
|
|
425
|
+
(red, red) is 3 # the sole contribution is from edge (0,1)
|
|
426
|
+
(red, blue) is 2 # contributions from edges (0,2) and (1,2)
|
|
427
|
+
(blue, red) is 2 # same as (red, blue) since graph is undirected
|
|
428
|
+
(blue, blue) is 0 # there are no edges with blue endpoints
|
|
429
|
+
|
|
430
|
+
"""
|
|
431
|
+
import numpy as np
|
|
432
|
+
import scipy as sp
|
|
433
|
+
|
|
434
|
+
edge_value = _edge_value(G, edge_attr)
|
|
435
|
+
node_value = _node_value(G, node_attr)
|
|
436
|
+
|
|
437
|
+
if rc_order is None:
|
|
438
|
+
ordering = list({node_value(n) for n in G})
|
|
439
|
+
else:
|
|
440
|
+
ordering = rc_order
|
|
441
|
+
|
|
442
|
+
N = len(ordering)
|
|
443
|
+
undirected = not G.is_directed()
|
|
444
|
+
index = dict(zip(ordering, range(N)))
|
|
445
|
+
M = sp.sparse.lil_array((N, N), dtype=dtype)
|
|
446
|
+
|
|
447
|
+
seen = set()
|
|
448
|
+
for u, nbrdict in G.adjacency():
|
|
449
|
+
for v in nbrdict:
|
|
450
|
+
# Obtain the node attribute values.
|
|
451
|
+
i, j = index[node_value(u)], index[node_value(v)]
|
|
452
|
+
if v not in seen:
|
|
453
|
+
M[i, j] += edge_value(u, v)
|
|
454
|
+
if undirected:
|
|
455
|
+
M[j, i] = M[i, j]
|
|
456
|
+
|
|
457
|
+
if undirected:
|
|
458
|
+
seen.add(u)
|
|
459
|
+
|
|
460
|
+
if normalized:
|
|
461
|
+
M *= 1 / M.sum(axis=1)[:, np.newaxis] # in-place mult preserves sparse
|
|
462
|
+
|
|
463
|
+
if rc_order is None:
|
|
464
|
+
return M, ordering
|
|
465
|
+
else:
|
|
466
|
+
return M
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Bethe Hessian or deformed Laplacian matrix of graphs."""
|
|
2
|
+
|
|
3
|
+
import networkx as nx
|
|
4
|
+
from networkx.utils import not_implemented_for
|
|
5
|
+
|
|
6
|
+
__all__ = ["bethe_hessian_matrix"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@not_implemented_for("directed")
|
|
10
|
+
@not_implemented_for("multigraph")
|
|
11
|
+
@nx._dispatchable
|
|
12
|
+
def bethe_hessian_matrix(G, r=None, nodelist=None):
|
|
13
|
+
r"""Returns the Bethe Hessian matrix of G.
|
|
14
|
+
|
|
15
|
+
The Bethe Hessian is a family of matrices parametrized by r, defined as
|
|
16
|
+
H(r) = (r^2 - 1) I - r A + D where A is the adjacency matrix, D is the
|
|
17
|
+
diagonal matrix of node degrees, and I is the identify matrix. It is equal
|
|
18
|
+
to the graph laplacian when the regularizer r = 1.
|
|
19
|
+
|
|
20
|
+
The default choice of regularizer should be the ratio [2]_
|
|
21
|
+
|
|
22
|
+
.. math::
|
|
23
|
+
r_m = \left(\sum k_i \right)^{-1}\left(\sum k_i^2 \right) - 1
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
G : Graph
|
|
28
|
+
A NetworkX graph
|
|
29
|
+
r : float
|
|
30
|
+
Regularizer parameter
|
|
31
|
+
nodelist : list, optional
|
|
32
|
+
The rows and columns are ordered according to the nodes in nodelist.
|
|
33
|
+
If nodelist is None, then the ordering is produced by ``G.nodes()``.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
H : scipy.sparse.csr_array
|
|
38
|
+
The Bethe Hessian matrix of `G`, with parameter `r`.
|
|
39
|
+
|
|
40
|
+
Examples
|
|
41
|
+
--------
|
|
42
|
+
>>> k = [3, 2, 2, 1, 0]
|
|
43
|
+
>>> G = nx.havel_hakimi_graph(k)
|
|
44
|
+
>>> H = nx.bethe_hessian_matrix(G)
|
|
45
|
+
>>> H.toarray()
|
|
46
|
+
array([[ 3.5625, -1.25 , -1.25 , -1.25 , 0. ],
|
|
47
|
+
[-1.25 , 2.5625, -1.25 , 0. , 0. ],
|
|
48
|
+
[-1.25 , -1.25 , 2.5625, 0. , 0. ],
|
|
49
|
+
[-1.25 , 0. , 0. , 1.5625, 0. ],
|
|
50
|
+
[ 0. , 0. , 0. , 0. , 0.5625]])
|
|
51
|
+
|
|
52
|
+
See Also
|
|
53
|
+
--------
|
|
54
|
+
bethe_hessian_spectrum
|
|
55
|
+
adjacency_matrix
|
|
56
|
+
laplacian_matrix
|
|
57
|
+
|
|
58
|
+
References
|
|
59
|
+
----------
|
|
60
|
+
.. [1] A. Saade, F. Krzakala and L. Zdeborová
|
|
61
|
+
"Spectral Clustering of Graphs with the Bethe Hessian",
|
|
62
|
+
Advances in Neural Information Processing Systems, 2014.
|
|
63
|
+
.. [2] C. M. Le, E. Levina
|
|
64
|
+
"Estimating the number of communities in networks by spectral methods"
|
|
65
|
+
arXiv:1507.00827, 2015.
|
|
66
|
+
"""
|
|
67
|
+
import scipy as sp
|
|
68
|
+
|
|
69
|
+
if nodelist is None:
|
|
70
|
+
nodelist = list(G)
|
|
71
|
+
if r is None:
|
|
72
|
+
r = sum(d**2 for v, d in nx.degree(G)) / sum(d for v, d in nx.degree(G)) - 1
|
|
73
|
+
A = nx.to_scipy_sparse_array(G, nodelist=nodelist, format="csr")
|
|
74
|
+
n, m = A.shape
|
|
75
|
+
D = sp.sparse.dia_array((A.sum(axis=1), 0), shape=(m, n)).tocsr()
|
|
76
|
+
I = sp.sparse.eye_array(m, n, format="csr")
|
|
77
|
+
return (r**2 - 1) * I - r * A + D
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Adjacency matrix and incidence matrix of graphs.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import networkx as nx
|
|
6
|
+
|
|
7
|
+
__all__ = ["incidence_matrix", "adjacency_matrix"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@nx._dispatchable(edge_attrs="weight")
|
|
11
|
+
def incidence_matrix(
|
|
12
|
+
G, nodelist=None, edgelist=None, oriented=False, weight=None, *, dtype=None
|
|
13
|
+
):
|
|
14
|
+
"""Returns incidence matrix of G.
|
|
15
|
+
|
|
16
|
+
The incidence matrix assigns each row to a node and each column to an edge.
|
|
17
|
+
For a standard incidence matrix a 1 appears wherever a row's node is
|
|
18
|
+
incident on the column's edge. For an oriented incidence matrix each
|
|
19
|
+
edge is assigned an orientation (arbitrarily for undirected and aligning to
|
|
20
|
+
direction for directed). A -1 appears for the source (tail) of an edge and
|
|
21
|
+
1 for the destination (head) of the edge. The elements are zero otherwise.
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
G : graph
|
|
26
|
+
A NetworkX graph
|
|
27
|
+
|
|
28
|
+
nodelist : list, optional (default= all nodes in G)
|
|
29
|
+
The rows are ordered according to the nodes in nodelist.
|
|
30
|
+
If nodelist is None, then the ordering is produced by G.nodes().
|
|
31
|
+
|
|
32
|
+
edgelist : list, optional (default= all edges in G)
|
|
33
|
+
The columns are ordered according to the edges in edgelist.
|
|
34
|
+
If edgelist is None, then the ordering is produced by G.edges().
|
|
35
|
+
|
|
36
|
+
oriented: bool, optional (default=False)
|
|
37
|
+
If True, matrix elements are +1 or -1 for the head or tail node
|
|
38
|
+
respectively of each edge. If False, +1 occurs at both nodes.
|
|
39
|
+
|
|
40
|
+
weight : string or None, optional (default=None)
|
|
41
|
+
The edge data key used to provide each value in the matrix.
|
|
42
|
+
If None, then each edge has weight 1. Edge weights, if used,
|
|
43
|
+
should be positive so that the orientation can provide the sign.
|
|
44
|
+
|
|
45
|
+
dtype : a NumPy dtype or None (default=None)
|
|
46
|
+
The dtype of the output sparse array. This type should be a compatible
|
|
47
|
+
type of the weight argument, eg. if weight would return a float this
|
|
48
|
+
argument should also be a float.
|
|
49
|
+
If None, then the default for SciPy is used.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
A : SciPy sparse array
|
|
54
|
+
The incidence matrix of G.
|
|
55
|
+
|
|
56
|
+
Notes
|
|
57
|
+
-----
|
|
58
|
+
For MultiGraph/MultiDiGraph, the edges in edgelist should be
|
|
59
|
+
(u,v,key) 3-tuples.
|
|
60
|
+
|
|
61
|
+
"Networks are the best discrete model for so many problems in
|
|
62
|
+
applied mathematics" [1]_.
|
|
63
|
+
|
|
64
|
+
References
|
|
65
|
+
----------
|
|
66
|
+
.. [1] Gil Strang, Network applications: A = incidence matrix,
|
|
67
|
+
http://videolectures.net/mit18085f07_strang_lec03/
|
|
68
|
+
"""
|
|
69
|
+
import scipy as sp
|
|
70
|
+
|
|
71
|
+
if nodelist is None:
|
|
72
|
+
nodelist = list(G)
|
|
73
|
+
if edgelist is None:
|
|
74
|
+
if G.is_multigraph():
|
|
75
|
+
edgelist = list(G.edges(keys=True))
|
|
76
|
+
else:
|
|
77
|
+
edgelist = list(G.edges())
|
|
78
|
+
A = sp.sparse.lil_array((len(nodelist), len(edgelist)), dtype=dtype)
|
|
79
|
+
node_index = {node: i for i, node in enumerate(nodelist)}
|
|
80
|
+
for ei, e in enumerate(edgelist):
|
|
81
|
+
(u, v) = e[:2]
|
|
82
|
+
if u == v:
|
|
83
|
+
continue # self loops give zero column
|
|
84
|
+
try:
|
|
85
|
+
ui = node_index[u]
|
|
86
|
+
vi = node_index[v]
|
|
87
|
+
except KeyError as err:
|
|
88
|
+
raise nx.NetworkXError(
|
|
89
|
+
f"node {u} or {v} in edgelist but not in nodelist"
|
|
90
|
+
) from err
|
|
91
|
+
if weight is None:
|
|
92
|
+
wt = 1
|
|
93
|
+
else:
|
|
94
|
+
if G.is_multigraph():
|
|
95
|
+
ekey = e[2]
|
|
96
|
+
wt = G[u][v][ekey].get(weight, 1)
|
|
97
|
+
else:
|
|
98
|
+
wt = G[u][v].get(weight, 1)
|
|
99
|
+
if oriented:
|
|
100
|
+
A[ui, ei] = -wt
|
|
101
|
+
A[vi, ei] = wt
|
|
102
|
+
else:
|
|
103
|
+
A[ui, ei] = wt
|
|
104
|
+
A[vi, ei] = wt
|
|
105
|
+
return A.asformat("csc")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@nx._dispatchable(edge_attrs="weight")
|
|
109
|
+
def adjacency_matrix(G, nodelist=None, dtype=None, weight="weight"):
|
|
110
|
+
"""Returns adjacency matrix of `G`.
|
|
111
|
+
|
|
112
|
+
Parameters
|
|
113
|
+
----------
|
|
114
|
+
G : graph
|
|
115
|
+
A NetworkX graph
|
|
116
|
+
|
|
117
|
+
nodelist : list, optional
|
|
118
|
+
The rows and columns are ordered according to the nodes in `nodelist`.
|
|
119
|
+
If ``nodelist=None`` (the default), then the ordering is produced by
|
|
120
|
+
``G.nodes()``.
|
|
121
|
+
|
|
122
|
+
dtype : NumPy data-type, optional
|
|
123
|
+
The desired data-type for the array.
|
|
124
|
+
If `None`, then the NumPy default is used.
|
|
125
|
+
|
|
126
|
+
weight : string or None, optional (default='weight')
|
|
127
|
+
The edge data key used to provide each value in the matrix.
|
|
128
|
+
If None, then each edge has weight 1.
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
A : SciPy sparse array
|
|
133
|
+
Adjacency matrix representation of G.
|
|
134
|
+
|
|
135
|
+
Notes
|
|
136
|
+
-----
|
|
137
|
+
For directed graphs, entry ``i, j`` corresponds to an edge from ``i`` to ``j``.
|
|
138
|
+
|
|
139
|
+
If you want a pure Python adjacency matrix representation try
|
|
140
|
+
:func:`~networkx.convert.to_dict_of_dicts` which will return a
|
|
141
|
+
dictionary-of-dictionaries format that can be addressed as a
|
|
142
|
+
sparse matrix.
|
|
143
|
+
|
|
144
|
+
For multigraphs with parallel edges the weights are summed.
|
|
145
|
+
See :func:`networkx.convert_matrix.to_numpy_array` for other options.
|
|
146
|
+
|
|
147
|
+
The convention used for self-loop edges in graphs is to assign the
|
|
148
|
+
diagonal matrix entry value to the edge weight attribute
|
|
149
|
+
(or the number 1 if the edge has no weight attribute). If the
|
|
150
|
+
alternate convention of doubling the edge weight is desired the
|
|
151
|
+
resulting SciPy sparse array can be modified as follows::
|
|
152
|
+
|
|
153
|
+
>>> G = nx.Graph([(1, 1)])
|
|
154
|
+
>>> A = nx.adjacency_matrix(G)
|
|
155
|
+
>>> A.toarray()
|
|
156
|
+
array([[1]])
|
|
157
|
+
>>> A.setdiag(A.diagonal() * 2)
|
|
158
|
+
>>> A.toarray()
|
|
159
|
+
array([[2]])
|
|
160
|
+
|
|
161
|
+
See Also
|
|
162
|
+
--------
|
|
163
|
+
to_numpy_array
|
|
164
|
+
to_scipy_sparse_array
|
|
165
|
+
to_dict_of_dicts
|
|
166
|
+
adjacency_spectrum
|
|
167
|
+
"""
|
|
168
|
+
return nx.to_scipy_sparse_array(G, nodelist=nodelist, dtype=dtype, weight=weight)
|