## S3 method for class 'igraph':
[(x, i, j, ..., from, to,
sparse = igraph_opt("sparsematrices"), edges = FALSE, drop = TRUE,
attr = if (is_weighted(x)) "weight" else NULL)
to
argument, it can be used to
query/set a sequence of edges. See details below. This argument cannot
be present together with any of the i
and j
from
argument, it can be used to
query/set a sequence of edges. See details below. This argument cannot
be present together with any of the i
and j
NULL
, then it should be the name of an edge
attribute. This attribute is queried and returned.from
andto
arguments can be used to check
the existence of many edges. In this case, bothfrom
andto
must be present and they must have the same length. They
must contain vertex ids or names. A numeric vector is returned, of
the same length asfrom
andto
, it contains ones
for existing edges edges and zeros for non-existing ones.
Example:graph[from=1:3, to=c(2,3,5)].[
operator returns the edge
weights. For non-esistent edges zero weights are returned. Other
edge attributes can be queried as well, by giving theattr
argument.TRUE
):graph[1, 2] <- 1
graph[1:3,1] <- 1
graph[from=1:3, to=c(2,3,5)] <- TRUEThis does not affect edges that are already present in the graph,
i.e. no multiple edges are created.attr
argument
contains the name of the edge attribute to set, so it does not
have to beattr="weight"
setting is implicit, and
one does not need to give it explicitly.FALSE
orNULL
as the
replacement value:graph[v, w] <- FALSEremoves the edge from vertex$v$to vertex$w$.
As this can be used to delete edges between two sets of vertices,
either pairwise:graph[from=v, to=w] <- FALSEor not:graph[v, w] <- FALSEif$v$and$w$are vectors of edge ids or names.[
Of course, the indexing operators support vertex names,
so instead of a numeric vertex id a vertex can also be given to
[
[[
[[.igraph
;
adjacent_vertices
;
are.connected
, are_adjacent
;
ecount
, gsize
;
ends
, get.edge
,
get.edges
; get.edge.ids
;
gorder
, vcount
;
head_of
; incident_edges
;
incident
; is.directed
,
is_directed
; neighbors
;
tail_of