Find the edges in an igraph graph that have the specified end points. This function handles multi-graph (graphs with multiple edges) and can consider or ignore the edge directions in directed graphs.
Arguments
- graph
The input graph.
- vp
The incident vertices, given as vertex ids or symbolic vertex names. They are interpreted pairwise, i.e. the first and second are used for the first edge, the third and fourth for the second, etc.
- directed
Logical scalar, whether to consider edge directions in directed graphs. This argument is ignored for undirected graphs.
- error
Logical scalar, whether to report an error if an edge is not found in the graph. If
FALSE
, then no error is reported, and zero is returned for the non-existant edge(s).
Value
A numeric vector of edge ids, one for each pair of input vertices.
If there is no edge in the input graph for a given pair of vertices, then
zero is reported. (If the error
argument is FALSE
.)
Details
igraph vertex ids are natural numbers, starting from one, up to the number of vertices in the graph. Similarly, edges are also numbered from one, up to the number of edges.
This function allows finding the edges of the graph, via their incident vertices.
See also
Other structural queries:
[.igraph()
,
[[.igraph()
,
adjacent_vertices()
,
are_adjacent()
,
ends()
,
gorder()
,
gsize()
,
head_of()
,
incident()
,
incident_edges()
,
is_directed()
,
neighbors()
,
tail_of()
Author
Gabor Csardi csardi.gabor@gmail.com
Examples
g <- make_ring(10)
ei <- get_edge_ids(g, c(1, 2, 4, 5))
E(g)[ei]
#> + 2/10 edges from d937e12:
#> [1] 1--2 4--5
## non-existant edge
get_edge_ids(g, c(2, 1, 1, 4, 5, 4))
#> [1] 1 0 4
## For multiple edges, a single edge id is returned,
## as many times as corresponding pairs in the vertex series.
g <- make_graph(rep(c(1, 2), 5))
eis <- get_edge_ids(g, c(1, 2, 1, 2))
eis
#> [1] 5 5
E(g)[eis]
#> + 2/5 edges from bde6b35:
#> [1] 1->2 1->2