igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Feedback on network animation code?


From: Jeff Hemsley
Subject: Re: [igraph] Feedback on network animation code?
Date: Tue, 4 Dec 2012 09:35:50 -0800

Very cool. Thank you.

On Thu, Nov 29, 2012 at 1:58 PM, Gábor Csárdi <address@hidden> wrote:
> On Thu, Nov 29, 2012 at 10:52 AM, Jeff Hemsley <address@hidden>
> wrote:
> [...]
>>
>> The area of code that I'm actually interested in making more efficient
>> is where I am fading out the colors of links/vertex because it is a
>> loop in a loop and I was hoping there was a way to vectorize it.
>
>
> You can replace the inner loop with something like this:
>
> alpha.vec.idx <- match(E(g)$date, possible.dates) - date.fade.index[1] + 1
> alpha.vec.idx <- ifelse(alpha.vec.idx < 1 | alpha.vec.idx >
> length(alpha.vec),
>                         1, alpha.vec.idx)
> E(g)$alpha <- alpha.vec[alpha.vec.idx]
> V(g)$alpha <- sapply(V(g), function(v) { max(E(g)$alpha[incident(g, v)]) })
>
> It requires that the first element in alpha.vec is zero.
>
> This is still a loop, though, because of the sapply, but I believe that it
> is faster. Actually I would think that the bottleneck is exporting the PNG
> files, but I might be wrong....
>
> Gabor
>
>>
>>
>> The reason I ask is because these networks are small, but I have far
>> larger ones I'd like to automate.
>>
>> Thoughts on that?
>>
>> On Thu, Nov 29, 2012 at 7:05 AM, Gábor Csárdi <address@hidden> wrote:
>> > Hi Jeff, I think it looks great!
>> >
>> > What exactly do you want to improve on the code? It all looks very
>> > reasonable for me, so unless you desire another feature or the code is
>> > slow,
>> > why change it? Do not change code that does everything you want. :)
>> >
>> > Btw. the igraph wiki turned out to be not very efficient to share igraph
>> > related code snipplets, so maybe we will start a blog that aggregates
>> > them,
>> > or move to gists at github. I want to put code like yours on the igraph
>> > homepage somehow.
>> >
>> > Best
>> > Gabor
>> >
>> >
>> > On Wed, Nov 28, 2012 at 3:53 PM, Jeff Hemsley
>> > <address@hidden>
>> > wrote:
>> >>
>> >> I'm somewhat new to iGraph, and pretty good at R, but I am still
>> >> learning. I found a way to animate an evolving network with iGraph in
>> >> R and would love to get any feedback on how to improve the code.
>> >>
>> >> The code, well commented, is here:
>> >>
>> >>
>> >>
>> >> http://somelab.net/2012/11/how-to-create-a-network-animation-with-r-and-the-igraph-package/
>> >>
>> >> Any feedback, suggestions, comments are welcome.
>> >> Thanks!
>> >>
>> >> --
>> >> Jeff Hemsley
>> >> Doctoral Student
>> >> The iSchool
>> >> University of Washington
>> >> http://ischool.uw.edu/
>> >> address@hidden
>> >>
>> >> _______________________________________________
>> >> igraph-help mailing list
>> >> address@hidden
>> >> https://lists.nongnu.org/mailman/listinfo/igraph-help
>> >
>> >
>> >
>> >
>> > --
>> > Gabor Csardi <address@hidden>     MTA KFKI RMKI
>> >
>> >
>> > _______________________________________________
>> > igraph-help mailing list
>> > address@hidden
>> > https://lists.nongnu.org/mailman/listinfo/igraph-help
>> >
>>
>>
>>
>> --
>> Jeff Hemsley
>> Doctoral Candidate
>> The Information School
>> University of Washington
>> http://ischool.uw.edu/
>> address@hidden
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
>
>
> --
> Gabor Csardi <address@hidden>     MTA KFKI RMKI
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Jeff Hemsley
Doctoral Candidate
The Information School
University of Washington
http://ischool.uw.edu/
address@hidden



reply via email to

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