跳到内容

查询图的边属性

用法

edge_attr(graph, name, index = E(graph))

参数

graph

name

要查询的属性的名称。 如果缺失,则以列表形式返回所有边属性。

index

一个可选的边序列,用于查询边的子集的边属性。

边属性的值,如果 name 缺失,则返回所有边属性的列表。

示例

g <- make_ring(10) %>%
  set_edge_attr("weight", value = 1:10) %>%
  set_edge_attr("color", value = "red")
g
#> IGRAPH 960b462 U-W- 10 10 -- Ring graph
#> + attr: name (g/c), mutual (g/l), circular (g/l), weight (e/n), color
#> | (e/c)
#> + edges from 960b462:
#>  [1] 1-- 2 2-- 3 3-- 4 4-- 5 5-- 6 6-- 7 7-- 8 8-- 9 9--10 1--10
plot(g, edge.width = E(g)$weight)