Domanda

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
È stato utile?

Soluzione

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 set vs$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).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top