igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] how to "collapse" a network


From: Gábor Csárdi
Subject: Re: [igraph] how to "collapse" a network
Date: Wed, 7 Mar 2012 13:00:59 -0500

Peter,

you can download a 0.6 windows binary R package here:
http://win-builder.r-project.org/Zh7vo2amfgck/

Best,
Gabor

On Wed, Mar 7, 2012 at 7:36 AM, Wet Bell Diver <address@hidden> wrote:
>
> Dear Tamás and Jeremy,
>
> Thanks for your help, both solutions (=the code) work wonderfully.
>
> For the solution using igraph directly, I am having trouble installing it
> into my windows (win7, x64) setup, as the both the command line (R INSTALL
> etc...) and install.packages("igraph_nightly_0.6-2646-20120229.tar.gz", type
> = "source") give me the error: "ERROR: configuration failed for package
> 'igraph'"
> That is a pity, perhaps you have a solution?
>
> Apart from that, the code you provide does the trick as well, and I am
> grateful for that.
>
> best,
> Peter
>
>
> Op 6-3-2012 10:36, Tamás Nepusz schreef:
>
>> Hello Peter,
>>
>>> It happens frequently that the same companies engage in multiple deals
>>> together, but each deal is represented by a line in my data. As a
>>> result, you see that 'COMP 1' -- 'COMP 2' occurs twice.
>>> I would like to be able to collapse this to a weighted edge list where
>>> 'COMP 1' -- 'COMP 2' occurs only once but with value 2, 'COMP 1' --
>>> 'COMP 3' occurs only once having value 3, et cetera.
>>> There must be a very simple way of doing this, but how?
>>
>> I assume that you are using igraph from R. The "simplify" function in
>> igraph 0.6 will sum up numeric edge attributes when it eliminates multiple
>> edges, so I guess the easiest for you is to upgrade to the development
>> version of igraph (that is, 0.6). Since it has not been released officially
>> yet, you can download it from the page of our nightly builds:
>>
>> http://code.google.com/p/igraph/downloads/list
>>
>> Download the latest "GNU R source package", and install it in R. If you
>> happen to use Windows and need a pre-compiled package, let us know - Gabor
>> can probably prepare one for you.
>>
>> Unfortunately if you cannot upgrade to igraph 0.6 for any reason, then the
>> only option is to use count.multiple to find the "multiplicity" of each
>> edge, and then construct a new graph manually; e.g., like this (not sure if
>> there is a simpler solution):
>>
>> mul <- count.multiple(g)
>> df <- as.data.frame(get.edgelist(g))
>> df$weight <- cm
>> g <- graph.data.frame(unique(df))
>>
>>> Second, each company has several attributes, including industry. One of
>>> the things I would like to do is to collapse the entire
>>> company*company network into a weigted industry*industry network. This
>>> would reduce the network from approx. 2000*2000 to 40*40.
>>> How can I construct such a weighted network in igraph?
>>
>> igraph 0.6 will also have a function called contract.vertices which lets
>> you contract many vertices into a single one, so you could proceed by first
>> contracting the vertices by industry using contract.vertices, followed by
>> simplify.
>>
>> --
>> T.
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help



-- 
Gabor Csardi <address@hidden>     MTA KFKI RMKI



reply via email to

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