igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Character Vectors Containing Vertex Names


From: Gábor Csárdi
Subject: Re: [igraph] Character Vectors Containing Vertex Names
Date: Fri, 8 Oct 2010 14:34:56 +0200

Dear Lorenzo,

On Thu, Oct 7, 2010 at 4:36 PM, Lorenzo Isella <address@hidden> wrote:
> 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.

this change does not affect the symbolic edge list -> igraph
conversion as far as I see it. It rather simplifies the opposite:
instead of vertex ids, you can just use your symbolic vertex names to
select/delete/etc. vertices.

Btw. I think that the symbolic edge list -> igraph conversion is not
very difficult, in your code it takes two lines, if you use
read.graph(format="ncol", ...) it takes only one function call. It
cannot really be simpler than that.

Best,
Gabor

> 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
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM



reply via email to

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