igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] How to rename vertices with contract.vertices() according t


From: Gábor Csárdi
Subject: Re: [igraph] How to rename vertices with contract.vertices() according to names of mapping vector
Date: Sun, 24 Nov 2013 00:43:17 -0500

On Sun, Nov 24, 2013 at 12:20 AM,  <address@hidden> wrote:
>      g2 <- contract.vertices(g, factor(V(g)$category))
>
> still gives
>
>    print(get.data.frame(g2, what="vertices"))
>                name
>
>    c("A", "B") A, B
>    c("1", "2") 1, 2

Yes, 'A' and 'B' are contracted into 'A, B' and '1' and '2' are
contracted into '1, 2'. Isn't this what you wanted?

Gabor

>
>
>
> Il 24.11.2013 05:12 Gábor Csárdi ha scritto:
>>
>> On Sun, Nov 24, 2013 at 12:08 AM,  <address@hidden> wrote:
>>>
>>> Hello list,
>>>
>>> Please consider the following graph with vertices of two categories
>>> ("digit"
>>> and "char"):
>>>
>>>     id <- c("1","2","A","B")
>>>     category <- c("digit","digit","char","char")
>>>     from <- c("1","1","2","A","A","B")
>>>     to <- c("2","A","A","B","1","2")
>>>
>>>     nodes <- cbind(id,category)
>>>     edges <- cbind(from,to)
>>>
>>>     g <- graph.data.frame(edges, directed=TRUE, vertices=nodes)
>>>
>>> Now I want to contract the vertices based on the attribute "category":
>>
>>
>> Try this:
>>
>> g2 <- contract.vertices(g, factor(V(g)$category))
>>
>> Gabor
>>
>> [...]
>>
>> _______________________________________________
>> 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]