Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert list of "vertex sequence" to a vector

Tags:

r

igraph

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?

like image 485
Salvador Dali Avatar asked Apr 12 '13 17:04

Salvador Dali


2 Answers

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

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

like image 104
Salvador Dali Avatar answered Sep 27 '22 16:09

Salvador Dali


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

like image 33
Marcos RF Avatar answered Sep 27 '22 16:09

Marcos RF