rmedge

Removes edges from a graph or digraph.

Category: Mathematics > Graph and Network Algorithms

Syntax

H = rmedge(G, idx)

Removes the edges with the given indices.

H = rmedge(G, s, t)

Removes the edges between s(k) and t(k).

Description

The graph is returned as a new value; G is not changed. Because only edges go, node numbering is unchanged, unlike rmnode. Removing an edge that does not exist is an error.

Input arguments

G
A graph or digraph.
idx
Edge indices, rows of G.Edges.
s, t
End nodes, as indices or names.

Output arguments

H
The graph without those edges. The nodes are kept, even if they become isolated.

Example

By index and by end nodes

G = graph([1 2 3 3], [2 3 1 4]);
H = rmedge(G, 1, 2);
numedges(H)
K = rmedge(G, [1 2]);
disp(K.Edges.EndNodes)
Output
ans = 3
     2     3
     3     4

See also

addedge rmnode findedge graph