how to convert list of “vertex sequence” to a vector

狂风中的少年 提交于 2019-12-01 15:27:36

问题


I am using Igraph package in R and when I am accessing the list of vertices names through V(graph), I am getting the following result:

Vertex sequence:
 [1] "d66cp96igcdnt25brjeics9d11" "bovlonq25tmuaiak6do92v9cj0" "simj1u4714pa07p38vhstusf36" "6t6tnkoh4ftbgt787pvpmp1323"
 [5] "mf987tcmm8u8j3pdo4cts6jml3"

The problem that I need a vectors of these names, but this is structure(1:20, class = "igraph.vs", env = <environment>)

my ideas to transform it with as.vector(), as.factor did not yield a result. Is there a way how to convert it to a vector of strings?


回答1:


.... Ok, I found a way out:

V(graph)$name will give me a vector of names




回答2:


For a more general case, just use the as_ids() function.



来源:https://stackoverflow.com/questions/15977157/how-to-convert-list-of-vertex-sequence-to-a-vector

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!