igraph-help
[Top][All Lists]

## Re: [igraph] combining communities

 From: Claudia Muller-Birn Subject: Re: [igraph] combining communities Date: Wed, 11 Aug 2010 14:56:25 -0400

```Hi Gabor,

On Aug 9, 2010, at 4:48 PM, Gábor Csárdi wrote:

> On Mon, Aug 9, 2010 at 2:19 PM, Claudia Muller-Birn <address@hidden> wrote:
>> Hi Gabor,
>>
>> On Aug 9, 2010, at 4:16 AM, Gábor Csárdi wrote:
>>
>>> Sorry this was not complete yet, I mean
>>>
>>> g <-  simplify(as.undirected(ba.game(100, 3)))
>>> sc <- spinglass.community(g)\$membership
>>> el <- get.edgelist(g)
>>> for (i in seq_len(max(sc)+1)-1) {
>>>  w <- which(sc==i)-1
>>>  el[ el %in% w ] <- w[1]
>>> }
>>> mode(el) <- "character"
>>> el <- unique(el)
>>> graph.edgelist(el, dir=FALSE)
>>>
>>> You can remove the loop edges before creating the graph:
>>> el <- el[ el[,1] != el[,2], ]
>>
>> Interesting solution. But unfortunately, I am not experienced enough to
>> understand every step. Do you mind to extend your code by some comment lines
>> (starting with the for loop)? That would be great. Thank you very much!
>
> The loops iterates over the communities. From each community we the
> take the id of the first vertex and replace the ids of all other
> vertices with this one in the edge list.
>
> The rest is not very important, the "mode(el)" line is needed because
> the vertex ids are not consecutive any more in the edge list matrix
> and thus we want to use them as symbolic vertex names. The "unique"
> line removes the duplicate edges.

Thank you very much. I'll try to apply this for my problems as soon as possible
:)

Regards,
Claudia

>
> Best,
> Gabor
>
>>> Best,
>>> Gabor
>>
>> Claudia
>>
>>>
>>> On Mon, Aug 9, 2010 at 10:07 AM, Gábor Csárdi <address@hidden> wrote:
>>>> Hi,
>>>>
>>>> in igraph 0.6 we have a function for that (contract.vertices in R),
>>>> but it should not be too hard to code a quick solution in R. E.g.
>>>>
>>>> g <- erdos.renyi.game(100, 1/100)
>>>> sc <- spinglass.community(g)\$membership
>>>> el <- get.edgelist(g)
>>>> for (i in seq_len(max(sc)+1)-1) {
>>>>
>>>> }
>>>>
>>>> On Mon, Aug 9, 2010 at 2:33 AM, Stuart Kininmonth
>>>>> Hi,
>>>>>
>>>>> just wondering if anyone has written any code to take a community
>>>>> membership identity list and combine the nodes and arcs to create a
>>>>> community network?
>>>>>
>>>>> thanks,
>>>>>
>>>>> Stuart Kininmonth
>>>>> Spatial Ecologist
>>>>> Australian Institute of Marine Science
>>>>>
>>>>>
>>>>> --
>>>>> ------------------------------------------------------------------------
>>>>> The information contained within this transmission is for the
>>>>> use of the intended recipient only and may contain confidential
>>>>> and/or legally privileged material and/or material the subject
>>>>> of copyright and/or personal information and/or sensitive
>>>>> information that is subject to the Privacy Act 1988. Any review,
>>>>> re-transmission, disclosure, dissemination or other use of, or
>>>>> taking of any action in reliance upon, this information by
>>>>> persons or entities other than the intended recipient is
>>>>> notify the AIMS Privacy Officer on (07) 4753 4444 and delete
>>>>> all copies of this transmission together with any attachments.
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> igraph-help mailing list
>>>>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Gabor Csardi <address@hidden>     UNIL DGM
>>>>
>>>
>>>
>>>
>>> --
>>> Gabor Csardi <address@hidden>     UNIL DGM
>>>
>>> _______________________________________________
>>> igraph-help mailing list
>>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>>
>>
>> _______________________________________________
>> igraph-help mailing list
>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>>
>
>
>
> --
> Gabor Csardi <address@hidden>     UNIL DGM
>
> _______________________________________________
> igraph-help mailing list