labeledge
为图边添加标签
说明
示例
添加图边权重标签
创建并绘制一个图。
s = [1 1 1 2 2]; t = [2 3 4 2 5]; G = graph(s,t); h = plot(G);
使用 labeledge
添加边权重标签。
weights = [5 10 15 10 10]; labeledge(h,1:numedges(G),weights)
将文本标签添加到图边
创建并绘制一个图。
s = [1 1 2 2 3]; t = [2 3 3 4 4]; G = graph(s,t); h = plot(G);
将文本标签添加到五条图边中的三条上。
labelText = {'ABC' 'DEF' 'GHI'}; labeledge(h,[1 1 2],[2 3 3],labelText)
输入参数
s,t
— 节点对组(以单独参量指定)
节点索引 | 节点名称
节点对组,指定为单独的节点索引或节点名称参量。s
和 t
中位置类似的元素指定图中边的源和目标节点。
下表显示通过数值节点索引或节点名称引用一个或多个节点的不同方法。
形式 | 单一节点 | 多个节点 |
---|---|---|
节点索引 | 标量 示例: | 向量 示例: |
节点名称 | 字符向量 示例: | 字符向量元胞数组 示例: |
字符串标量 示例: | 字符串数组 示例: |
示例: labeledge(H,[1 2 2],[2 3 4],{'label1' 'label2' 'label3'})
示例: labeledge(H,{'a' 'b' 'b'},{'b' 'c' 'd'},{'label1' 'label2' 'label3'})
idx
— 边索引
标量 | 向量
边索引,指定为标量、正整数向量或逻辑向量。
正整数向量指定与表
G.Edges
中的行对应的图G
的边索引,使得G.Edges(idx,:)
返回边的端节点。在此形式中,idx
的最大值为numedges(G)
,并且所选节点的数量等于idx
中索引的数量。逻辑向量指定是否为每条边添加标签。在此形式中,逻辑向量的长度必须为
numedges(G)
,并且所选节点的数量等于idx
中非零索引的数量。
示例: labeledge(H,[1 3 5 7],{'label1' 'label2' 'label3' 'label4'})
Labels
— 边标签
字符向量 | 字符串标量 | 字符向量元胞数组 | 字符串数组
边标签,指定为字符向量、字符串标量、字符向量元胞数组或字符串数组。
如果
Labels
为字符向量或字符串标量,则labeledge
对每个指定的边使用该标签。如果
Labels
是元胞数组或字符串数组,则它必须包含每个指定边的标签。
数据类型: char
| cell
| string
版本历史记录
在 R2015b 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)