Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

networkx.algorithms.operators.unary.complement

complement(G)[source]

Return the graph complement of G.

Parameters:G (graph) – A NetworkX graph
Returns:GC
Return type:A new graph.

Notes

Note that complement() does not create self-loops and also does not produce parallel edges for MultiGraphs.

Graph, node, and edge data are not propagated to the new graph.