nx_parallel.algorithms.mis#

Functions#

maximal_independent_set(G[, nodes, seed, get_chunks])

Returns a random maximal independent set guaranteed to contain

Module Contents#

nx_parallel.algorithms.mis.maximal_independent_set(G, nodes=None, seed=None, get_chunks='chunks')[source]#

Returns a random maximal independent set guaranteed to contain a given set of nodes.

This parallel implementation processes nodes in chunks across multiple cores.

An independent set is a set of nodes such that the subgraph of G induced by these nodes contains no edges. A maximal independent set is an independent set such that it is not possible to add a new node and still get an independent set.

The parallel computation divides nodes into chunks and processes them in parallel, iteratively building the independent set faster than sequential processing on large graphs.

networkx.maximal_independent_set: https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.mis.maximal_independent_set.html

Parameters#

GNetworkX graph

An undirected graph.

nodeslist or iterable, optional

Nodes that must be part of the independent set. This set of nodes must be independent. If not provided, a random starting node is chosen.

seedinteger, random_state, or None (default)

Indicator of random number generation state. See Randomness.

get_chunksstr, function (default = “chunks”)

A function that takes in a list of nodes and returns chunks. The default chunking divides nodes into n_jobs chunks.

Returns#

indep_nodeslist

List of nodes that are part of a maximal independent set.

Raises#

NetworkXUnfeasible

If the nodes in the provided list are not part of the graph or do not form an independent set, an exception is raised.

NetworkXNotImplemented

If G is directed.

Examples#

>>> import networkx as nx
>>> import nx_parallel as nxp
>>> G = nx.path_graph(5)
>>> nxp.maximal_independent_set(G)
[4, 0, 2]
>>> nxp.maximal_independent_set(G, [1])
[1, 3]

Notes#

This algorithm does not solve the maximum independent set problem. It computes a maximal independent set, which is not guaranteed to be the largest possible independent set in the graph.

The parallel version uses a chunk-based parallel algorithm that provides speedup on large graphs (>= 50000 nodes). For smaller graphs, the NetworkX sequential version is used automatically.

The parallel implementation may produce a maximal independent set with different node ordering than the sequential version, but both are valid maximal independent sets.