EdgeContract[g,e]
contracts the edge e of the graph g.
EdgeContract[g,{e1,e2,…}]
contracts a collection of edges e1,e2,….
EdgeContract[{vw,…},…]
uses rules vw to specify the graph g.
EdgeContract
EdgeContract[g,e]
contracts the edge e of the graph g.
EdgeContract[g,{e1,e2,…}]
contracts a collection of edges e1,e2,….
EdgeContract[{vw,…},…]
uses rules vw to specify the graph g.
Details and Options
- EdgeContract is also known as edge collapse.
- EdgeContract[g,e] creates a new graph from g by deleting the edge e and merging vertices of e.
- EdgeContract works with undirected graphs, directed graphs, multigraphs, and mixed graphs.
Examples
open all close allScope (7)
EdgeContract works with undirected graphs:
EdgeContract[[image], 12]EdgeContract[[image], 21]EdgeContract[[image], 12]EdgeContract[[image], 21]Use rules to specify the graph:
EdgeContract[{1 -> 3, 2 -> 1, 3 -> 6, 4 -> 6, 1 -> 5, 5 -> 4, 6 -> 1}, 21]Use patterns to specify a set of edges:
EdgeContract[[image], 3_]EdgeContract works with large graphs:
GridGraph[{10, 10, 10, 10}];VertexCount[EdgeContract[%, {12}]]//TimingProperties & Relations (1)
EdgeContract can be computed using VertexContract:
g = WheelGraph[7];EdgeContract[g, {12, 34}]VertexContract[g, Flatten[List@@@{12, 34}]]Related Guides
Text
Wolfram Research (2014), EdgeContract, Wolfram Language function, https://reference.wolfram.com/language/ref/EdgeContract.html (updated 2015).
CMS
Wolfram Language. 2014. "EdgeContract." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/EdgeContract.html.
APA
Wolfram Language. (2014). EdgeContract. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/EdgeContract.html
BibTeX
@misc{reference.wolfram_2026_edgecontract, author="Wolfram Research", title="{EdgeContract}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/EdgeContract.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_edgecontract, organization={Wolfram Research}, title={EdgeContract}, year={2015}, url={https://reference.wolfram.com/language/ref/EdgeContract.html}, note=[Accessed: 13-June-2026]}