Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Graph::removeEdge

Removes one or several edges from a graph

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

Graph::removeEdge(G, e)
Graph::removeEdge(G, l)

Description

Graph::removeEdge(G, [e1, ..., en]) removes edges e1...en from graph G.

Graph::removeEdge deletes one or several edges from a graph. An edge is represented by a list containing two vertices of the graph. A warning is printed if the specified edge is not contained in the graph.

Graph::removeEdge(G, e) removes the edge e from the graph G.

Graph::removeEdge(G, l) removes all edges in list l from graph G.

Examples

Example 1

Removing an edge from a cyclic graph results in a (degenerated) tree:

G1 := Graph::createCircleGraph(5):
Graph::printGraphInformation(G1)
Vertices: [1, 2, 3, 4, 5]
Edges: [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]
Vertex weights: no vertex weights.
Edge descriptions: no edge descriptions.
Edge weights: no edge weights.
Edge costs: no edge costs.
Adjacency list (out): 1 = [2], 2 = [3], 3 = [4], 4 = [5], 5 = [1]
Adjacency list (in): 1 = [5], 2 = [1], 3 = [2], 4 = [3], 5 = [4]
Graph is directed.
plot(Graph::plotCircleGraph(G1))

G2 := Graph::removeEdge(G1, [[5, 1]]):
Graph::printGraphInformation(G2)
Vertices: [1, 2, 3, 4, 5]
Edges: [[1, 2], [2, 3], [3, 4], [4, 5]]
Vertex weights: no vertex weights.
Edge descriptions: no edge descriptions.
Edge weights: no edge weights.
Edge costs: no edge costs.
Adjacency list (out): 1 = [2], 2 = [3], 3 = [4], 4 = [5], 5 = []
Adjacency list (in): 1 = [], 2 = [1], 3 = [2], 4 = [3], 5 = [4]
Graph is directed.
plot(Graph::plotCircleGraph(G2))

If more than one edge is to be removed they must also be specified in a list:

edges := [[2, 3], [4, 5]]: 
G3 := Graph::removeEdge(G1, edges):
Graph::printGraphInformation(G3)
Vertices: [1, 2, 3, 4, 5]
Edges: [[1, 2], [3, 4], [5, 1]]
Vertex weights: no vertex weights.
Edge descriptions: no edge descriptions.
Edge weights: no edge weights.
Edge costs: no edge costs.
Adjacency list (out): 1 = [2], 2 = [], 3 = [4], 4 = [], 5 = [1]
Adjacency list (in): 1 = [5], 2 = [1], 3 = [], 4 = [3], 5 = []
Graph is directed.
plot(Graph::plotCircleGraph(G3))

Parameters

l

A list of edges

e

An edge

G

A graph

Return Values

Graph

Was this topic helpful?