WOLFRAM

gives the graph difference of the graphs g1 and g2.

GraphDifference[{vw,},]

uses rules vw to specify the graph g.

Details and Options

  • The graph difference Graph[v1,e1]Graph[v2,e2] is given by Graph[v1v2,e1 e2].
  • GraphDifference works with undirected graphs, directed graphs, multigraphs, and mixed graphs.

Examples

open allclose all

Basic Examples  (1)Summary of the most common use cases

Obtain the graph difference of two graphs:

Out[32]=32

Highlight the graph difference:

Out[33]=33

Scope  (5)Survey of the scope of standard use cases

GraphDifference works with undirected graphs:

Out[1]=1

Directed graphs:

Out[1]=1

Multigraphs:

Out[1]=1

Mixed graphs:

Out[1]=1

Use rules to specify the graph:

Out[1]=1

Properties & Relations  (6)Properties of the function, and connections to other functions

The vertices of the graph difference are the union of the vertices of the graphs:

Out[2]=2

The edges of the graph difference are the complement of the edges of the graphs:

Out[3]=3

The graph difference of any graph and itself is an empty graph:

Out[1]=1
Out[2]=2

The graph difference of any graph and its CompleteGraph is isomorphic to the complement of the graph:

Out[2]=2

The GraphDifference of two graphs has the same vertices as GraphUnion:

Out[1]=1

The GraphDifference of two graphs has the same vertices as GraphIntersection:

Out[1]=1
Wolfram Research (2010), GraphDifference, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDifference.html (updated 2015).
Wolfram Research (2010), GraphDifference, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDifference.html (updated 2015).

Text

Wolfram Research (2010), GraphDifference, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDifference.html (updated 2015).

Wolfram Research (2010), GraphDifference, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDifference.html (updated 2015).

CMS

Wolfram Language. 2010. "GraphDifference." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphDifference.html.

Wolfram Language. 2010. "GraphDifference." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphDifference.html.

APA

Wolfram Language. (2010). GraphDifference. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphDifference.html

Wolfram Language. (2010). GraphDifference. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphDifference.html

BibTeX

@misc{reference.wolfram_2025_graphdifference, author="Wolfram Research", title="{GraphDifference}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GraphDifference.html}", note=[Accessed: 08-July-2025 ]}

@misc{reference.wolfram_2025_graphdifference, author="Wolfram Research", title="{GraphDifference}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GraphDifference.html}", note=[Accessed: 08-July-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_graphdifference, organization={Wolfram Research}, title={GraphDifference}, year={2015}, url={https://reference.wolfram.com/language/ref/GraphDifference.html}, note=[Accessed: 08-July-2025 ]}

@online{reference.wolfram_2025_graphdifference, organization={Wolfram Research}, title={GraphDifference}, year={2015}, url={https://reference.wolfram.com/language/ref/GraphDifference.html}, note=[Accessed: 08-July-2025 ]}