igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Change order of vertices in an igraph object


From: Hermann Norpois
Subject: Re: [igraph] Change order of vertices in an igraph object
Date: Thu, 21 Nov 2013 10:54:30 +0100

Hello,
thanks for your suggestions, but it did not work. Maybe I did not understand how pertmute.vertices work. Maybe I was not clear enough concerning my needs.
This was my approach:

I expected that the new order in my igraph object is the order of my index vector idx after permute.vertices (g, idx).
But this is not the case. For instance:
> gnames <- V (g)$name
> which (gnames=="rs4822754")
[1] 1858
> idx <- order (V (g)$x) # index vector
> idx[1:20]
 [1]    1    2    3    4    5    6    7    8    9 1854   10   11   12 1857 1855
[16]   13 1856 1858   14   15 #according to idx the 1858th element of g is on the 18th position
> gg <- permute.vertices (g, idx) # using the index vector
> ggnames <- V(gg)$name
> which (ggnames=="rs4822754")
[1] 1462 # I expected 18

Could you please comment on this.
Thanks
Hermann





2013/11/20 Gábor Csárdi <address@hidden>
See permute.vertices().

G.

On Wed, Nov 20, 2013 at 10:23 AM, Hermann Norpois <address@hidden> wrote:
> Hello,
>
> having an igraph object sig (see below) I am looking for a way to change the
> order of vertices in reference to x.
> So I guess I have something to use like
> idx -> order (V(sig)$x)
> to get a new index. But how do I insert this index in the igraph object to
> get a newly ordered igraph object?
>
> Thanks Hermann
>
>> dput (sig)
> structure(list(13, TRUE, c(0, 0, 1, 6, 6, 6, 7, 7, 8, 9, 11),
>     c(1, 3, 3, 7, 11, 12, 11, 12, 9, 10, 12), c(0, 1, 2, 3, 4,
>     5, 6, 7, 8, 9, 10), c(0, 1, 2, 3, 8, 9, 4, 6, 5, 7, 10),
>     c(0, 2, 3, 3, 3, 3, 3, 6, 8, 9, 10, 10, 11, 11), c(0, 0,
>     1, 1, 3, 3, 3, 3, 4, 4, 5, 6, 8, 11), list(c(1, 0, 1), structure(list(),
> .Names = character(0)),
>         structure(list(name = c("rs5761629", "rs12628704", "rs2267104",
>         "rs5761630", "rs5761631", "rs4822752", "rs58450956",
>         "rs16982453", "rs5761635", "rs2283843", "rs5997109",
>         "rs16982454", "rs76095025"), x = c(27005470L, 27006136L,
>         27006308L, 27006698L, 27007269L, 27011420L, 27014346L,
>         27014428L, 27014467L, 27017300L, 27017435L, 27017996L,
>         27018001L), y = c(0.887869230924378, 0.654212551439585,
>         0.755969155644639, 0.895054710863134, 0.591152110066053,
>         0.841717655905212, 1, 1, 0.79443719113136, 0.794554251603377,
>         0.435233706137542, 1, 1)), .Names = c("name", "x", "y"
>         )), structure(list(weight = c(0.920156, 0.986379, 0.905977,
>         1, 1, 1, 1, 1, 0.944149, 0.822451, 1)), .Names = "weight"))), class
> = "igraph")
>>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>

_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help


reply via email to

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