Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Refactor Parallel Graph Algorithms to Use a Centralized Parallel Configuration with Flexible Iterators #86

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: remove explicit dunder methods for handling state/ attr on Para…
…llelGraph interface, instead making execute_parallel more dynamic
  • Loading branch information
dPys committed Oct 25, 2024
commit 0a12b19468c9f72af7384b06215940ebed7ff712
12 changes: 0 additions & 12 deletions nx_parallel/interface.py
Original file line number Diff line number Diff line change
@@ -65,18 +65,6 @@ def is_directed(self):
def __str__(self):
return f"Parallel{self.graph_object}"

def __getattr__(self, attr):
"""Delegate attribute access to the underlying NetworkX graph."""
return getattr(self.graph_object, attr)

def __getstate__(self):
"""Support pickling by returning the state of the underlying graph."""
return self.graph_object

def __setstate__(self, state):
"""Support unpickling by restoring the underlying graph."""
self.graph_object = state


def assign_algorithms(cls):
"""Class decorator to assign algorithms to the class attributes."""
7 changes: 5 additions & 2 deletions nx_parallel/utils/chunk.py
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ def get_n_jobs(n_jobs=None):


def execute_parallel(
G: nx.Graph,
G,
process_func,
iterator_func,
get_chunks="chunks",
@@ -95,7 +95,7 @@ def execute_parallel(

Parameters
----------
G : networkx.Graph
G : networkx.Graph or ParallelGraph
The graph on which the algorithm operates.
process_func : callable
The function to process each chunk. Should accept (G, chunk, **kwargs).
@@ -117,6 +117,9 @@ def execute_parallel(
"""
n_jobs = nxp.get_n_jobs()

if hasattr(G, "graph_object"):
G = G.graph_object

data = iterator_func(G)

if get_chunks in {"chunks", "nodes"}:
Loading