networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
maximal_independent_set(G, nodes=None, seed=None)

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.

Notes

This algorithm does not solve the maximum independent set problem.

Parameters

G : NetworkX graph
nodes : list or iterable

Nodes that must be part of the independent set. This set of nodes must be independent.

seed : integer, random_state, or None (default)

Indicator of random number generation state. See Randomness<randomness> .

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.

Returns

indep_nodes : list

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

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

Examples

>>> G = nx.path_graph(5)
... nx.maximal_independent_set(G) # doctest: +SKIP [4, 0, 2]
>>> nx.maximal_independent_set(G, [1])  # doctest: +SKIP
[1, 3]
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.mis.maximal_independent_set

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/mis.py#12
type: <class 'function'>
Commit: