contracts a collection of vertices v1, v2, into a single vertex of the graph g.


contracts several collections of vertices.


uses rules vw to specify the graph g.

Details and Options

  • VertexContract is also known as vertex identification.
  • VertexContract[g,{v1,v2,}] creates a new graph from g by removing all edges between vi and vj and merging them into the single vertex v1.
  • VertexContract works with undirected graphs, directed graphs, multigraphs, and mixed graphs.


open allclose all

Basic Examples  (1)

Contract vertices of a graph:

Scope  (7)

VertexContract works with undirected graphs:

Directed graphs:


Mixed graphs:

Use rules to specify the graph:

Use patterns to specify a set of vertices:

VertexContract works with large graphs:

Applications  (2)

Find the connectivity between communities in a network:

Condensation graph:

List all possible vertex identifications between two RNA tree models to model RNA bonding:

Gather all isomorphic graphs into groups and show non-isomorphic trees:

Properties & Relations  (2)

Using VertexReplace to contract vertices:

EdgeContract can be computed using VertexContract:

Wolfram Research (2014), VertexContract, Wolfram Language function, (updated 2015).


Wolfram Research (2014), VertexContract, Wolfram Language function, (updated 2015).


Wolfram Language. 2014. "VertexContract." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015.


Wolfram Language. (2014). VertexContract. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_vertexcontract, author="Wolfram Research", title="{VertexContract}", year="2015", howpublished="\url{}", note=[Accessed: 18-June-2024 ]}


@online{reference.wolfram_2024_vertexcontract, organization={Wolfram Research}, title={VertexContract}, year={2015}, url={}, note=[Accessed: 18-June-2024 ]}