如果您从 R 中使用 igraph,请使用此选项
get.edge.ids {igraph} | R 文档 |
查找 igraph 图中具有指定端点的边。此函数处理多重图(具有多个边的图),并且可以考虑或忽略有向图中的边方向。
get.edge.ids(graph, vp, directed = TRUE, error = FALSE, multi = FALSE)
图 |
输入图。 |
vp |
关联顶点,以顶点 ID 或符号顶点名称给出。它们成对解释,即第一个和第二个用于第一条边,第三个和第四个用于第二条边,依此类推。 |
有向 |
逻辑标量,指示是否考虑有向图中的边方向。此参数对于无向图将被忽略。 |
错误 |
逻辑标量,指示如果在图中找不到边是否报告错误。如果 |
multi |
逻辑标量,指示是否正确处理多条边。如果 |
igraph 顶点 ID 是自然数,从一开始,直到图中的顶点数。类似地,边的编号也从一开始,直到边的数量。
此函数允许通过它们的关联顶点查找图的边。
边 ID 的数值向量,每个输入顶点对一个。如果输入图中没有给定顶点对的边,则报告零。(如果 error
参数为 FALSE
。)
Gabor Csardi csardi.gabor@gmail.com
其他结构查询: [.igraph()
, [[.igraph()
, adjacent_vertices()
, are_adjacent()
, ends()
, gorder()
, gsize()
, head_of()
, incident_edges()
, incident()
, is_directed()
, neighbors()
, tail_of()
g <- make_ring(10)
ei <- get.edge.ids(g, c(1,2, 4,5))
E(g)[ei]
## non-existant edge
get.edge.ids(g, c(2,1, 1,4, 5,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
E(g)[eis]
## 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
E(g)[eim]