Graph.complement

Graph.complement()[source]

Generate the complement of a graph.

The complement of a graph G is the graph H with the same vertices but whose edges consists of the edges not present in the graph G [1].

Returns:
compas.datastructures.Graph

The complement graph.

References

[1]

Wolfram MathWorld. Graph complement. Available at: http://mathworld.wolfram.com/GraphComplement.html.

Examples

>>> import compas
>>> from compas.datastructures import Graph
>>> graph = Graph.from_obj(compas.get('lines.obj'))
>>> complement = graph.complement()
>>> any(complement.has_edge(u, v, directed=False) for u, v in graph.edges())
False