如果您从 R 中使用 igraph,请使用此选项
igraph-es-attributes {igraph} | R 文档 |
$
操作符是一个语法糖,用于查询和设置边序列中边的属性。
## S3 replacement method for class 'igraph.es'
x[[i]] <- value
## S3 replacement method for class 'igraph.es'
x[i] <- value
## S3 method for class 'igraph.es'
x$name
## S3 replacement method for class 'igraph.es'
x$name <- value
E(x, path = NULL, P = NULL, directed = NULL) <- value
x |
一个边序列。对于 |
i |
索引。 |
value |
边序列中边属性的新值。 |
name |
要查询或设置的边属性的名称。 |
path |
选择沿着路径的边,路径由顶点序列给出。参见 |
P |
通过顶点对选择边。参见 |
有向 |
是否对 |
$
的查询形式是 edge_attr
的快捷方式,例如 E(g)[idx]$attr
等价于 edge_attr(g, attr, E(g)[idx])
。
$
的赋值形式是 set_edge_attr
的快捷方式,例如 E(g)[idx]$attr <- value
等价于 g <- set_edge_attr(g, attr, E(g)[idx], value)
。
一个向量或列表,包含序列中边属性 name
的值。对于数值、字符或逻辑属性,它是一个适当类型的向量,否则它是一个列表。
其他顶点和边序列:E()
, V()
, igraph-es-indexing2
, igraph-es-indexing
, igraph-vs-attributes
, igraph-vs-indexing2
, igraph-vs-indexing
, print.igraph.es()
, print.igraph.vs()
其他顶点和边序列:E()
, V()
, igraph-es-indexing2
, igraph-es-indexing
, igraph-vs-attributes
, igraph-vs-indexing2
, igraph-vs-indexing
, print.igraph.es()
, print.igraph.vs()
# color edges of the largest component
largest_comp <- function(graph) {
cl <- components(graph)
V(graph)[which.max(cl$csize) == cl$membership]
}
g <- sample_(gnp(100, 1/100),
with_vertex_(size = 3, label = ""),
with_graph_(layout = layout_with_fr)
)
giant_v <- largest_comp(g)
E(g)$color <- "orange"
E(g)[giant_v %--% giant_v]$color <- "blue"
plot(g)