Reputation: 6796
In below code, how can I copy content of final_list
into a list or into a new data frame?
final_list
is "igraph.vs"
class object and the last line of the code is giving me an error: Error in V(final_list) : Not a graph object
library("igraph", lib.loc="C:/Users/njog/Documents/R/win-library/3.0")
g1 <- graph.formula(a-+d, a-+b, a-+c, c-+b, b-+e)
E(g1)
V(g1)
succesors=neighborhood(g1,"a",order=vcount(g1), mode="out")[[1]]
predecessors=neighborhood(g1,"e",order=vcount(g1), mode="in")[[1]]
final_list_numbers=intersect(succesors,predecessors)
final_list=V(g1)[final_list_numbers]
class(final_list)
final_list
V(final_list)$names
Upvotes: 0
Views: 964
Reputation: 56935
Try final_list$name
to get the names of the vertices.
> final_list$name
[1] "a" "b" "c" "e"
See ?igraph::attributes
.
Near the bottom:
Similarly is
vs
is a vertex setvs$name
gives the values of the name attribute for the vertices in the vertex set.
(In ?V
you can see that V
returns a vertex set).
Upvotes: 1