nxbench.backends package

Submodules

nxbench.backends.core module

class nxbench.backends.core.BackendManager[source]

Bases: object

A registry for dynamically registering and configuring networkx backends.

The registry maps:
backend_name (str) ->

(import_name, conversion_func, teardown_func)

where:
  • import_name (str) is the actual module name to import

  • conversion_func(nx_graph, num_threads) -> typed backend graph

  • teardown_func() -> None (optional)

__init__()[source]
configure_backend(name, original_graph, num_threads)[source]

Convert the given networkx.Graph to the backend-specific representation.

Return type:

Any

Parameters:
  • name (str)

  • original_graph (Any)

  • num_threads (int)

get_version(name)[source]

Retrieve the version for the given backend by its import_name. If not installed, returns “unknown”.

Return type:

str

Parameters:

name (str)

is_available(name)[source]

Check if the registered backend is actually installed (importable).

Return type:

bool

Parameters:

name (str)

is_registered(name)[source]
Return type:

bool

Parameters:

name (str)

register_backend(name, import_name, conversion_func, teardown_func=None)[source]

Register a new backend with a given name, import_name, conversion function, and optional teardown function.

Example:
register_backend(

name=”networkx”, import_name=”networkx”, conversion_func=convert_networkx, teardown_func=teardown_networkx

)

Parameters:
teardown_backend(name)[source]

If a teardown function is registered, call it. Otherwise, do nothing.

Parameters:

name (str)

nxbench.backends.core.get_backend_version(backend_name)[source]

Attempt to retrieve backend_name’s version. - First, check __version__ attribute. - If that fails, fallback to importlib.metadata.get_version(). - If everything fails, return “unknown”.

Return type:

str

Parameters:

backend_name (str)

nxbench.backends.core.is_available(backend_name)[source]

Return True if backend_name is importable; False otherwise. E.g., ‘networkx’, ‘nx_cugraph’, ‘graphblas_algorithms’, etc.

Return type:

bool

Parameters:

backend_name (str)

nxbench.backends.registry module

nxbench.backends.registry.convert_cugraph(original_graph, num_threads)[source]
Parameters:
  • original_graph (Graph)

  • num_threads (int)

nxbench.backends.registry.convert_graphblas(original_graph, num_threads)[source]
Parameters:
  • original_graph (Graph)

  • num_threads (int)

nxbench.backends.registry.convert_networkx(original_graph, num_threads)[source]
Parameters:
  • original_graph (Graph)

  • num_threads (int)

nxbench.backends.registry.convert_parallel(original_graph, num_threads)[source]
Parameters:
  • original_graph (Graph)

  • num_threads (int)

nxbench.backends.registry.teardown_cugraph()[source]
nxbench.backends.registry.teardown_graphblas()[source]
nxbench.backends.registry.teardown_networkx()[source]
nxbench.backends.registry.teardown_parallel()[source]

Module contents