$
operator is a syntactic sugar to query and set
edge attributes, for edges in an edge sequence.## S3 method for class 'igraph.es':
[[(x, i) <- value## S3 method for class 'igraph.es':
[(x, i) <- value
## S3 method for class 'igraph.es':
$(x, name)
## S3 method for class 'igraph.es':
$(x, name) <- value
E(x, path = NULL, P = NULL, directed = NULL) <- value
E<-
it is a graph.E
.E
.path
or
P
arguments.name
for the edges in the sequence. For numeric, character or
logical attributes, it is a vector of the appropriate type, otherwise
it is a list.$
is a shortcut for edge_attr
,
e.g. E(g)[idx]$attr
is equivalent to edge_attr(g, attr,
E(g)[idx])
.The assignment form of $
is a shortcut for
set_edge_attr
, e.g. E(g)[idx]$attr <- value
is
equivalent to g <- set_edge_attr(g, attr, E(g)[idx], value)
.
$.igraph.vs
,
$<-.igraph.vs
, V<-
,
[<-.igraph.vs
,
[[<-.igraph.vs
,
igraph-vs-attributes
,
igraph-vs-attributes
,
igraph-vs-attributes
,
igraph-vs-attributes
,
igraph-vs-attributes
; E
;
V
; [.igraph.es
,
%--%
, %->%
,
%<-%
, igraph-es-indexing
;
[.igraph.vs
,
igraph-vs-indexing
;
[[.igraph.es
,
igraph-es-indexing2
;
[[.igraph.vs
,
igraph-vs-indexing2
;
print.igraph.es
;
print.igraph.vs
Other vertex and edge sequences: $.igraph.vs
,
$<-.igraph.vs
, V<-
,
[<-.igraph.vs
,
[[<-.igraph.vs
,
igraph-vs-attributes
,
igraph-vs-attributes
,
igraph-vs-attributes
,
igraph-vs-attributes
,
igraph-vs-attributes
; E
;
V
; [.igraph.es
,
%--%
, %->%
,
%<-%
, igraph-es-indexing
;
[.igraph.vs
,
igraph-vs-indexing
;
[[.igraph.es
,
igraph-es-indexing2
;
[[.igraph.vs
,
igraph-vs-indexing2
;
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)
Run the code above in your browser using DataLab