Find the edge ids based on the incident vertices of the edgesSource:
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.
The input graph.
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.
Logical scalar, whether to consider edge directions in directed graphs. This argument is ignored for undirected graphs.
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).
Logical scalar, whether to handle multiple edges properly. If
FALSE, and a pair of vertices are given twice (or more), then always the same edge id is reported back for them. If
TRUE, then the edge ids of multiple edges are correctly reported.
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
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.
Other structural queries:
Gabor Csardi firstname.lastname@example.org
g <- make_ring(10) ei <- get.edge.ids(g, c(1, 2, 4, 5)) E(g)[ei] #> + 2/10 edges from ac662d8: #>  1--2 4--5 ## non-existant edge get.edge.ids(g, c(2, 1, 1, 4, 5, 4)) #>  1 0 4 ## multiple edges ## multi = FALSE, 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), multi = FALSE) eis #>  5 5 E(g)[eis] #> + 2/5 edges from 1a846d5: #>  1->2 1->2 ## multi = TRUE, as many different edges, if any, ## are returned as pairs in the vertex series. eim <- get.edge.ids(g, c(1, 2, 1, 2, 1, 2), multi = TRUE) eim #>  5 4 3 E(g)[eim] #> + 3/5 edges from 1a846d5: #>  1->2 1->2 1->2