igraph-help
[Top][All Lists]
Advanced

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

[igraph] Character Vectors Containing Vertex Names


From: Lorenzo Isella
Subject: [igraph] Character Vectors Containing Vertex Names
Date: Thu, 07 Oct 2010 16:36:17 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.11pre) Gecko/20100623 Spicebird/0.8

Dear All,
I have just updated my igraph installation.
When I looked at the news in the R interface, I read the following

All functions that have vertex id input parameters, handle character vectors 
containing vertex names now.

I remember (though I cannot find the precise email) that this was anticipated some months ago in a reply to an email of mine on this very mailing list. In particular, I wonder if this could be useful to simplify a bit the procedure I follow when translating an edge list stored into a text file, where every node is given by a symbolic ID (just a number in this case, but it could be something else) into an igraph graph.

To fix the ideas, see the code snippet below followed by the corresponding input file.
Any thoughts are appreciated.
Cheers

Lorenzo


########################################################

library(igraph)
library(Cairo)


tab <- read.table("my_net.dat", header=FALSE)



g <- graph.data.frame(tab, dir=FALSE) #create graph where the numbers providing the visitor ID are

g <- simplify(g)

d <- get.diameter(g,weights=NA)




l <- layout.fruchterman.reingold(g)

l <- layout.norm(l, -1,1, -1,1)


CairoPDF("large_network.pdf")

plot(g, layout=l,
     vertex.label.dist=0.5,   vertex.color="#ff000033",
vertex.frame.color="#ff000033", edge.color="#55555533",vertex.label=NA, vertex.size=4
     #, main=week[sel_day]
#as.expression(c(sprintf("Power = %.3f", power))) ,cex=1.2)
     #,ylab=as.expression(c(sprintf("Week %1d",k)))
     )



V(g)$id <- seq(vcount(g))-1
g2 <- subgraph(g, d)


plot(g2, layout=l[ V(g2)$id+1, ],
vertex.color="blue", vertex.frame.color="blue",
   edge.color="blue",vertex.label=NA, edge.width=2, vertex.size=4,
   add=TRUE, rescale=FALSE)



dev.off()


##################################


124 32446
124 35189
124 36449
124 36457
124 36458
124 37555
124 73463
124 79284
124 112384
124 115931
124 151467
124 151705
124 157527
124 211969
125 51527
125 113089
125 114845
129 10429
129 25544
129 176890
137 24104
137 46727
137 46828
137 58684
137 73581
137 86343
137 100193
137 122312
137 151957
137 162758
137 189259
137 190695
137 190710
137 191269
137 195373
137 195417
137 215854
137 218625
167 32444
177 6797
177 28748
177 42221
177 42831
177 56883
177 67142
177 73463
177 76510
177 81143
177 98083
177 99014
177 104988
177 109857
177 119490
177 120912
177 121061
177 121184
177 124115
177 147264
177 151961
177 161294
177 163787
177 163972
177 164179
177 165988
177 166287
177 167886
177 167969
177 168995
177 175546
177 206447
177 209176
177 214456
177 214634
177 215493
177 215584
177 219335
177 226260
177 228193
178 91137
178 92607
179 76767
179 134139
179 221628
189 94638
189 98441
189 100961
189 188756
189 207935
190 105796
190 106954
190 203976
190 212513
199 28656
199 213717
203 191075
229 25430
331 170348
350 8987
382 160480



reply via email to

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