igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] How to get the vertex itself not the index


From: Fatemeh a
Subject: [igraph] How to get the vertex itself not the index
Date: Sat, 15 Nov 2014 15:26:48 +0330

Hi,
I would like to get the neighborhood of each vertex and get the community membership of each of them and the size of the each community which each vertex belong to , please consider this example :

karate <- graph.famous("Zachary")
karate <-as.matrix(karate)
wckarate <- walktrap.community(karate) 
neigh_com <-sapply(graph.neighborhood(karate,1,nodes=V(karate)),function(g,x) {
        membership(wckarate)[V(g)] })
neigh_size <-sapply(graph.neighborhood(karate,1,nodes=V(karate)), function(g) {
   sizes(wckarate)[membership(wckarate)[V(g)] })

the problem is that it is working with the index rather than the each vertex id itself, and when I use graph.neighborhood it will index each vertex all over again so it is all wrong how to avoid this ?

thank you in advance,
fatemeh

--
regards
F..A

reply via email to

[Prev in Thread] Current Thread [Next in Thread]