Skip to content

Make forceatlas2_layout dispatchable - #7794

Merged
dschult merged 1 commit into
networkx:mainfrom
eriknw:dispatch_forceatlas2_layout
Jan 16, 2025
Merged

dschult merged 1 commit into
networkx:mainfrom
eriknw:dispatch_forceatlas2_layout

Conversation

@eriknw

@eriknw eriknw commented Jan 15, 2025

Copy link
Copy Markdown
Contributor

This was requested as a dispatchable function: rapidsai/nx-cugraph#63

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why hasn't this function been marked as dispatchable before?
Are the layout algorithms not marked as dispatchable?
What's the current state of dispatchable usage in the repo?

@eriknw

eriknw commented Jan 15, 2025

Copy link
Copy Markdown
Contributor Author

Why hasn't this function been marked as dispatchable before?

Hasn't been requested before, and wasn't part of previous "dispatch almost everything" PRs.

Are the layout algorithms not marked as dispatchable?

Correct. ForceAtlas2 is the first (and still only). Most of the other layout algorithms accept G as a graph or a list of nodes. I think this would probably work with the current dispatch machinery, but I'd like to verify. I'd be happy to add @nx._dispatchable to other layout algorithms if you'd like.

What's the current state of dispatchable usage in the repo?

$ git grep nx._dispatchable networkx/ | sed 's/:.*//g' | sort | uniq
networkx/algorithms/approximation/clique.py
networkx/algorithms/approximation/clustering_coefficient.py
networkx/algorithms/approximation/connectivity.py
networkx/algorithms/approximation/density.py
networkx/algorithms/approximation/distance_measures.py
networkx/algorithms/approximation/dominating_set.py
networkx/algorithms/approximation/kcomponents.py
networkx/algorithms/approximation/matching.py
networkx/algorithms/approximation/maxcut.py
networkx/algorithms/approximation/ramsey.py
networkx/algorithms/approximation/steinertree.py
networkx/algorithms/approximation/traveling_salesman.py
networkx/algorithms/approximation/treewidth.py
networkx/algorithms/approximation/vertex_cover.py
networkx/algorithms/assortativity/connectivity.py
networkx/algorithms/assortativity/correlation.py
networkx/algorithms/assortativity/mixing.py
networkx/algorithms/assortativity/neighbor_degree.py
networkx/algorithms/assortativity/pairs.py
networkx/algorithms/asteroidal.py
networkx/algorithms/bipartite/basic.py
networkx/algorithms/bipartite/centrality.py
networkx/algorithms/bipartite/cluster.py
networkx/algorithms/bipartite/covering.py
networkx/algorithms/bipartite/edgelist.py
networkx/algorithms/bipartite/extendability.py
networkx/algorithms/bipartite/generators.py
networkx/algorithms/bipartite/matching.py
networkx/algorithms/bipartite/matrix.py
networkx/algorithms/bipartite/projection.py
networkx/algorithms/bipartite/redundancy.py
networkx/algorithms/bipartite/spectral.py
networkx/algorithms/boundary.py
networkx/algorithms/bridges.py
networkx/algorithms/broadcasting.py
networkx/algorithms/centrality/betweenness.py
networkx/algorithms/centrality/betweenness_subset.py
networkx/algorithms/centrality/closeness.py
networkx/algorithms/centrality/current_flow_betweenness.py
networkx/algorithms/centrality/current_flow_betweenness_subset.py
networkx/algorithms/centrality/current_flow_closeness.py
networkx/algorithms/centrality/degree_alg.py
networkx/algorithms/centrality/dispersion.py
networkx/algorithms/centrality/eigenvector.py
networkx/algorithms/centrality/flow_matrix.py
networkx/algorithms/centrality/group.py
networkx/algorithms/centrality/harmonic.py
networkx/algorithms/centrality/katz.py
networkx/algorithms/centrality/laplacian.py
networkx/algorithms/centrality/load.py
networkx/algorithms/centrality/percolation.py
networkx/algorithms/centrality/reaching.py
networkx/algorithms/centrality/second_order.py
networkx/algorithms/centrality/subgraph_alg.py
networkx/algorithms/centrality/trophic.py
networkx/algorithms/centrality/voterank_alg.py
networkx/algorithms/chains.py
networkx/algorithms/chordal.py
networkx/algorithms/clique.py
networkx/algorithms/cluster.py
networkx/algorithms/coloring/equitable_coloring.py
networkx/algorithms/coloring/greedy_coloring.py
networkx/algorithms/communicability_alg.py
networkx/algorithms/community/asyn_fluid.py
networkx/algorithms/community/centrality.py
networkx/algorithms/community/community_utils.py
networkx/algorithms/community/divisive.py
networkx/algorithms/community/kclique.py
networkx/algorithms/community/kernighan_lin.py
networkx/algorithms/community/label_propagation.py
networkx/algorithms/community/louvain.py
networkx/algorithms/community/lukes.py
networkx/algorithms/community/modularity_max.py
networkx/algorithms/community/quality.py
networkx/algorithms/components/attracting.py
networkx/algorithms/components/biconnected.py
networkx/algorithms/components/connected.py
networkx/algorithms/components/semiconnected.py
networkx/algorithms/components/strongly_connected.py
networkx/algorithms/components/tests/test_connected.py
networkx/algorithms/components/weakly_connected.py
networkx/algorithms/connectivity/connectivity.py
networkx/algorithms/connectivity/cuts.py
networkx/algorithms/connectivity/disjoint_paths.py
networkx/algorithms/connectivity/edge_augmentation.py
networkx/algorithms/connectivity/edge_kcomponents.py
networkx/algorithms/connectivity/kcomponents.py
networkx/algorithms/connectivity/kcutsets.py
networkx/algorithms/connectivity/stoerwagner.py
networkx/algorithms/connectivity/utils.py
networkx/algorithms/core.py
networkx/algorithms/covering.py
networkx/algorithms/cuts.py
networkx/algorithms/cycles.py
networkx/algorithms/d_separation.py
networkx/algorithms/dag.py
networkx/algorithms/distance_measures.py
networkx/algorithms/distance_regular.py
networkx/algorithms/dominance.py
networkx/algorithms/dominating.py
networkx/algorithms/efficiency_measures.py
networkx/algorithms/euler.py
networkx/algorithms/flow/boykovkolmogorov.py
networkx/algorithms/flow/capacityscaling.py
networkx/algorithms/flow/dinitz_alg.py
networkx/algorithms/flow/edmondskarp.py
networkx/algorithms/flow/gomory_hu.py
networkx/algorithms/flow/maxflow.py
networkx/algorithms/flow/mincost.py
networkx/algorithms/flow/networksimplex.py
networkx/algorithms/flow/preflowpush.py
networkx/algorithms/flow/shortestaugmentingpath.py
networkx/algorithms/flow/utils.py
networkx/algorithms/graph_hashing.py
networkx/algorithms/graphical.py
networkx/algorithms/hierarchy.py
networkx/algorithms/hybrid.py
networkx/algorithms/isolate.py
networkx/algorithms/isomorphism/isomorph.py
networkx/algorithms/isomorphism/tree_isomorphism.py
networkx/algorithms/isomorphism/vf2pp.py
networkx/algorithms/link_analysis/hits_alg.py
networkx/algorithms/link_analysis/pagerank_alg.py
networkx/algorithms/link_prediction.py
networkx/algorithms/lowest_common_ancestors.py
networkx/algorithms/matching.py
networkx/algorithms/minors/contraction.py
networkx/algorithms/mis.py
networkx/algorithms/moral.py
networkx/algorithms/node_classification.py
networkx/algorithms/non_randomness.py
networkx/algorithms/operators/all.py
networkx/algorithms/operators/binary.py
networkx/algorithms/operators/product.py
networkx/algorithms/operators/unary.py
networkx/algorithms/planarity.py
networkx/algorithms/polynomials.py
networkx/algorithms/reciprocity.py
networkx/algorithms/regular.py
networkx/algorithms/richclub.py
networkx/algorithms/shortest_paths/astar.py
networkx/algorithms/shortest_paths/dense.py
networkx/algorithms/shortest_paths/generic.py
networkx/algorithms/shortest_paths/unweighted.py
networkx/algorithms/shortest_paths/weighted.py
networkx/algorithms/similarity.py
networkx/algorithms/simple_paths.py
networkx/algorithms/smallworld.py
networkx/algorithms/smetric.py
networkx/algorithms/sparsifiers.py
networkx/algorithms/structuralholes.py
networkx/algorithms/summarization.py
networkx/algorithms/swap.py
networkx/algorithms/threshold.py
networkx/algorithms/time_dependent.py
networkx/algorithms/tournament.py
networkx/algorithms/traversal/beamsearch.py
networkx/algorithms/traversal/breadth_first_search.py
networkx/algorithms/traversal/depth_first_search.py
networkx/algorithms/traversal/edgebfs.py
networkx/algorithms/traversal/edgedfs.py
networkx/algorithms/tree/branchings.py
networkx/algorithms/tree/coding.py
networkx/algorithms/tree/decomposition.py
networkx/algorithms/tree/mst.py
networkx/algorithms/tree/operations.py
networkx/algorithms/tree/recognition.py
networkx/algorithms/triads.py
networkx/algorithms/vitality.py
networkx/algorithms/voronoi.py
networkx/algorithms/walks.py
networkx/algorithms/wiener.py
networkx/classes/function.py
networkx/convert.py
networkx/convert_matrix.py
networkx/drawing/layout.py
networkx/drawing/nx_agraph.py
networkx/drawing/nx_pydot.py
networkx/generators/atlas.py
networkx/generators/classic.py
networkx/generators/cographs.py
networkx/generators/community.py
networkx/generators/degree_seq.py
networkx/generators/directed.py
networkx/generators/duplication.py
networkx/generators/ego.py
networkx/generators/expanders.py
networkx/generators/geometric.py
networkx/generators/harary_graph.py
networkx/generators/internet_as_graphs.py
networkx/generators/intersection.py
networkx/generators/interval_graph.py
networkx/generators/joint_degree_seq.py
networkx/generators/lattice.py
networkx/generators/line.py
networkx/generators/mycielski.py
networkx/generators/nonisomorphic_trees.py
networkx/generators/random_clustered.py
networkx/generators/random_graphs.py
networkx/generators/small.py
networkx/generators/social.py
networkx/generators/spectral_graph_forge.py
networkx/generators/stochastic.py
networkx/generators/sudoku.py
networkx/generators/time_series.py
networkx/generators/trees.py
networkx/generators/triads.py
networkx/linalg/algebraicconnectivity.py
networkx/linalg/attrmatrix.py
networkx/linalg/bethehessianmatrix.py
networkx/linalg/graphmatrix.py
networkx/linalg/laplacianmatrix.py
networkx/linalg/modularitymatrix.py
networkx/linalg/spectrum.py
networkx/readwrite/adjlist.py
networkx/readwrite/edgelist.py
networkx/readwrite/gexf.py
networkx/readwrite/gml.py
networkx/readwrite/graph6.py
networkx/readwrite/graphml.py
networkx/readwrite/json_graph/adjacency.py
networkx/readwrite/json_graph/cytoscape.py
networkx/readwrite/json_graph/node_link.py
networkx/readwrite/json_graph/tree.py
networkx/readwrite/leda.py
networkx/readwrite/multiline_adjlist.py
networkx/readwrite/p2g.py
networkx/readwrite/pajek.py
networkx/readwrite/sparse6.py
networkx/relabel.py
networkx/utils/backends.py
networkx/utils/tests/test_backends.py

and we don't yet dispatch everything in these files:

networkx/classes/function.py
networkx/drawing/layout.py

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me! The force-directed layouts seem like good candidates for dispatching since they most often use arrays under the hood. This one will be a nice for backends w.r.t. partial kwarg handiling!

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the answers. (I was looking for more than a list of modules, but I get the jist. Are there others not listed?)

I approve this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants