igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] graph representation in memory: igraph_vector_t


From: Gábor Csárdi
Subject: Re: [igraph] graph representation in memory: igraph_vector_t
Date: Tue, 24 Mar 2009 16:08:21 +0100

Mati,

(Maybe we will create an igraph-devel mailing list for the questions
about igraph internals.)

This is basically the C++ vector model. The goal is to have a flexible
vector that can be resized without much copying. The data starts at
'stor_begin', it ends at (just before) 'end' and storage is allocated
(just before) until 'stor_end'.

This way you can do something like:
...
igraph_vector_resize(&v, 0);
igraph_vector_reserve(&v, 100);
for (i=0;i<99; i++) igraph_vector_push_back(&v, i);
...
and all memory is allocated by the _reserve call. Or with smart memory
allocation you can also do
...
igraph_vector_init(&v, 0);
for (i=0;i<n;i++) igraph_vector_push_back(&v, i);
...
in linear time. G.

On Tue, Mar 24, 2009 at 4:01 PM, Mati Vait <address@hidden> wrote:
> Hello again!
>
> I have a question about igraph_vector_t.
>
>
> What is the purpose of stor_begin, stor_end, end in igraph_vector_t (it
> is defined in vector.h)?
> Following is from vector.h:
>  ...
>  22 */
>  23
>  24 /**
>  25  * Vector, dealing with arrays efficiently.
>  26  * \ingroup types
>  27  */
>  28
>  29 typedef struct TYPE(igraph_vector) {
>  30   BASE* stor_begin;
>  31   BASE* stor_end;
>  32   BASE* end;
>  33 } TYPE(igraph_vector);
>  34
>  ...
>
> Was there any specific data structure in mind while designing it?
>
>
> Thank you for your time,
> Mati
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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