简体   繁体   English

iGraph R将边缘ID转换为顶点集

[英]iGraph R convert edge id to vertex set

I have an igraph graph object (g) in R: 我在R中有一个igraph图形对象(g):

IGRAPH UN-- 50 159 -- 
attr: name (v/c), weight (e/n)

I need to output a list of vertex pairs for each edge - what is the quickest way to do this? 我需要为每个边缘输出一个顶点对列表-最快的方法是什么?

The edge sequence from E(g) is: E(g)的边序列为:

[1]   V11 -- V1  
[2]   V10 -- V2  
[3]   V13 -- V3  
[4]   V34  -- V4  
[5]   V25  -- V4 
...

and I am trying to output: 我正在尝试输出:

[1]   11 1
[2]   10 2
[3]   13 3
[4]   34 4
[5]   25 4

Use get.edgelist , eg: 使用get.edgelist ,例如:

> library(igraph)
> g <- erdos.renyi.game(5, 0.3)
> get.edgelist(g)
     [,1] [,2]
[1,]    2    4
[2,]    3    4
[3,]    2    5
[4,]    3    5
[5,]    4    5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM