主要内容

RMEDGE

Remove edge from graph

描述

例子

H= rmedge(G英石的)removes the edges specified by the node pairssandtfrom graphG。如果有多个边缘sandt,然后全部被删除。

例子

H= rmedge(GIDX的)指定哪些边缘用边缘索引删除IDX。边缘索引是行中的行号G.Edges桌子。

例子

全部收缩

创建并绘制图形。

s = [1 1 1 2 2 3 4 5 5 6 7];t = [2 4 5 3 6 4 7 8 6 8 7 8];G =图(S,T);图(g)

图包含轴对象。轴对象包含类型图形图的对象。

Remove several edges from the graph and plot the result.

g = rmedge(g,[1 2 3 4],[5 6 7 8]);图(g)

图包含轴对象。轴对象包含类型图形图的对象。

创建图形并查看边缘列表。

s = {“bo”'NYC''NYC''NYC''LAX'};t = {'NYC''LAX''den''las''DCA'};g = digraph(s,t);G.Edges
ans =5×1桌endnodes __________________ {'bos'} {'nyc'} {'nyc'} {'lax'} {'nyc'} {'den'} {'nyc'} {'nyc'} {'las'} {'las'}'}

Remove the edge between nodes'NYC'and'den'使用边缘索引。

G= rmedge(G那3); G.Edges
ans =4×1桌endnodes __________________ {'bos'} {'nyc'} {'nyc'} {'lax'} {'nyc'} {'las'} {'lax'} {'lax'} {'dca'}

This example shows how to remove all of the self-loops from a graph. Self-loops are edges that connect a node to itself.

创建一个具有两个自宽的图形。

g =图([1 1 1 2],[1 2 3 2]);图(g)

图包含轴对象。轴对象包含类型图形图的对象。

采用RMEDGE从图形中删除所有自由。虽然G该技术只有两个自宽,可以从任何定向或无方向的图中删除所有自由。

g = rmedge(g,1:numnodes(g),1:numnodes(g));图(g)

图包含轴对象。轴对象包含类型图形图的对象。

输入参数

全部收缩

输入图,指定为图形orDigraph目的。采用图形创建一个无向图或Digraph创建有向图。

例子:G =图(1,2)

例子:g = digraph([1 2],[2 3])

节点对,指定为节点索引或节点名称的单独参数。类似位置的元素sandt指定图中边缘的源节点和目标节点。

该表显示了通过其数字节点索引或通过其节点名称引用一个或多个节点的不同方法。

形式 单节点 多个节点
节点索引

标量

例子:1

向量

例子:[1 2 3]

节点名称

角色向量

例子:'一种'

Cell array of character vectors

例子:{'a''b''c'}

字符串标量

例子:“一种”

字符串数组

例子:[“ a”“ b”“ c”]

例子:g = rmedge(g,1,2)从图中删除节点1和节点2之间的边缘G

例子:G= rmedge(G那{'a' 'b'},{'d' 'c'})从图中删除两个边缘G那the first of which is between node'一种'和节点'D'

边缘索引那specified as a scalar or vector. The edge indices are nonnegative integers that are row numbers in theG.Edges桌子。

例子:g = rmedge(g,[1 3 5])从中删除第一个,第三和第五边(行)G.Edges

输出参数

全部收缩

输出图,返回为图形orDigraph目的。

扩展功能

版本历史记录

Introduced in R2015b