GraphTheory
DeleteVertex
delete vertex from graph
Calling Sequence
Parameters
Description
Examples
DeleteVertex(G, V)
G
-
graph
V
vertex or a list or set of vertices
The DeleteVertex command returns a copy of the graph G with the specified vertex, or list of vertices, deleted. The graph G is not changed. The resulting graph is the subgraph of G induced by the remaining vertices. Any edges adjacent to V are removed.
with⁡GraphTheory:
G≔CycleGraph⁡5
G≔Graph 1: an undirected graph with 5 vertices and 5 edge(s)
H≔DeleteVertex⁡G,1,4
H≔Graph 2: an undirected graph with 3 vertices and 1 edge(s)
Edges⁡H
2,3
J≔InducedSubgraph⁡G,2,3,5
J≔Graph 3: an undirected graph with 3 vertices and 1 edge(s)
Edges⁡J
The next example raises an error because graph G only has five vertices.
DeleteVertex⁡G,6
Error, (in GraphTheory:-DeleteVertex) second argument expected to be a vertex or a list of vertices of the graph
See Also
CycleGraph
Edges
Graph
InducedSubgraph
Download Help Document