igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] why use floating point for graph nodes?


From: Gábor Csárdi
Subject: Re: [igraph] why use floating point for graph nodes?
Date: Thu, 12 Nov 2015 10:59:05 +0000

On Thu, Nov 5, 2015 at 9:48 AM, Szabolcs Horvát <address@hidden> wrote:
> On 5 November 2015 at 10:17, Gábor Csárdi <address@hidden> wrote:
>>
>> so that you don't need to copy between C and R.
>>
>
> Oh, so does the R interface avoid copying data structures that are
> also exposed to R?  (I don't know anything about R internals or how to
> extend R with C.)
>
> In which situations does it manage to avoid copies?  I am interested
> in this because a major bottleneck of the Mathematica interface is all
> the copying it needs to do and currently I'm trying to speed things
> up.

We copy once from C to R, when the object is created. This could be avoided
by using our own memory allocator, but we don't do that currently.

> When igraph functions return an igraph_vector_t, does it need to be
> copied to get exposed as an R numerical vector?

Yes.

> If not, did you need
> to make changes to igraph's memory allocation to make it usable in
> conjunction with R?
>
> I know that copies can be avoided when sending data *to* igraph, e.g.
> often we can use igraph_vector_view()

Yes, that's what we use to create a view on the graph.

> Does igraph offer anything similar to a "vector view" for an igraph_t?
>  I.e. if I already have an igraph_vector_t for the "from" vertices and
> "to" vertices, can I safely re-use them inside of a graph?  I never
> really looked at the internal structure and I don't know what oi, ii,
> os, is do ...  If igraph wasn't designed for this, it's probably not a
> good idea for me to push it though.

It is done manually, by creating a bunch of vector view. See here:
https://github.com/igraph/rigraph/blob/dev/tools/stimulus/rinterface.c.in#L3073

This is fine as long as the function(s) you call with it take a
'const' igraph_t.
Otherwise you need to copy.

Gabor

> _______________________________________________
> 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]