gives the graph complement of the graph g.
GraphComplement[{vw,…}]
uses rules vw to specify the graph g.
GraphComplement
gives the graph complement of the graph g.
GraphComplement[{vw,…}]
uses rules vw to specify the graph g.
Details and Options
- GraphComplement is also known as edge-complementary graph.
- The graph complement has the same vertices and edges defined by two vertices being adjacent only if they are not adjacent in g.
- GraphComplement works with undirected graphs, directed graphs, multigraphs, and mixed graphs.
Examples
open all close allBasic Examples (2)
Graph complement of cycle graphs:
Table[CycleGraph[n], {n, 4, 6}]GraphComplement /@ %Graph complement of directed graphs:
Table[CycleGraph[n, DirectedEdges -> True, EdgeStyle -> Arrowheads[0.1]], {n, 4, 6}]GraphComplement /@ %Scope (6)
GraphComplement works with undirected graphs:
GraphComplement[[image]]GraphComplement[[image]]GraphComplement[[image]]GraphComplement[[image]]Use rules to specify the graph:
GraphComplement[{1 -> 2, 1 -> 6, 2 -> 3, 3 -> 4, 4 -> 5, 5 -> 6}]GraphComplement works with large graphs:
g = GridGraph[{10, 10, 10, 10}];GraphComplement[g]//EdgeCount // TimingProperties & Relations (7)
The complement of a CompleteGraph is an edgeless graph:
{CompleteGraph[5], GraphComplement[CompleteGraph[5]]}The complement of the complement is the original graph (for simple graphs):
NestList[GraphComplement, CycleGraph[6], 2]The complement of the graph can be obtained from its adjacency matrix:
g = CycleGraph[5];m = AdjacencyMatrix[g];{GraphComplement[g], AdjacencyGraph[1 - IdentityMatrix[Length[m]] - m]}Equal@@(AdjacencyMatrix /@ %)An independent vertex set of the graph is a clique of its complement graph:
g = PetersenGraph[5, 2]FindIndependentVertexSet[%]FindClique[GraphComplement[g]]The complement of the line graph of
is a Petersen graph:
{GraphComplement[LineGraph@CompleteGraph[5]], PetersenGraph[5, 2]}IsomorphicGraphQ@@%The graph union of any simple graph and its complement is a complete graph:
g = [image];CompleteGraphQ[GraphUnion[g, GraphComplement[g]]]The graph intersection of any graph and its complement is an empty graph:
g = [image];EmptyGraphQ[GraphIntersection[g, GraphComplement[g]]]Related Guides
Text
Wolfram Research (2010), GraphComplement, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphComplement.html (updated 2015).
CMS
Wolfram Language. 2010. "GraphComplement." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphComplement.html.
APA
Wolfram Language. (2010). GraphComplement. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphComplement.html
BibTeX
@misc{reference.wolfram_2026_graphcomplement, author="Wolfram Research", title="{GraphComplement}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GraphComplement.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_graphcomplement, organization={Wolfram Research}, title={GraphComplement}, year={2015}, url={https://reference.wolfram.com/language/ref/GraphComplement.html}, note=[Accessed: 15-June-2026]}