[英]How to get the vertices of a selected edge in igraph R
How do I get the index of the two vertices of a selected edge, using the graph package in R? 如何使用R中的图形包获取选定边的两个顶点的索引?
set.seed(5)
g <- igraph::erdos.renyi.game(1000, 1/1000)
E(g)[100]
This returns 这返回
+ 1/473 edge from e82dd81:
[1] 112--483
What I would like to have returned is 112
. 我想返回的是112
。 How do I do that? 我怎么做?
We can try 我们可以试试
get.edgelist(g)[100,]
#[1] 112 483
get.edgelist(g)[100,][1]
#[1] 112
Or 要么
get.edges(g, es = 100)[,1]
#[1] 112
Another way: 其他方式:
as.integer(V(g)[inc(E(g)[100])][1]) # get vertices incident on an edge
#[1] 112
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.