Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Graph::removeEdge

Removes one or several edges from a graph

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

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?